ID:271411
 
okay I want to put this code
        Enter()
input("What is the room pass?","") as num
if(<Pass will go here>)
usr<<"You are grantted accsess"
return
else
usr<<"You are not allowed in."


into my code where there is no pass but instead its a mud(Text game, with text map and all that.) and I want to know how to make passworded rooms.

Heres the code(s) that have to deal with the text map

mob
Login() //overrides mob's Login() proc
Move(locate("Lounge")) //finds the Lounge, and puts mobs there
..() //calls the parent
new /obj/certificate (usr)
Move(area/A) //overrides mob's Move() proc
..() //calls the parent
src << "<b>[A.name]</b>"
src << A.desc //displays room description
src << "People here: \..."
for (var/mob/M in A) //loops through mobs in room, displaying each
if (M == src) src << "You \..."
else src << "[M] \..."

src << "\nExits: \..." //displays any exits
if (A.north) src << "north \..."
if (A.south) src << "south \..."
if (A.east) src << "east \..."
if (A.west) src << "west \..."
src << "" //forces carriage return

Then the next code
area
var //declare new area variables
north
south
east
west

Courtyard
desc = "Hushed noises from the lounge drift out into this pleasant-smelling courtyard."
east = "Lounge"
Kitchen
desc = "A refrigerator is here stocked with snacks and drinks for hardworking BYOND coders."
south = "Lounge"
Lounge //create a new area prototype
desc = "It is very comfy here. The walls are edged in bean bag chairs, and there is a benevolent-looking portrait of Zilal overhead."
west = "Courtyard"
north = "Kitchen"

Code is not discrete. There is not "a code" or "many codes" or "multiple codes," any more than there is "a water" or "many waters" or "multiple waters." On another note: that first block of code you posted won't do what you want it to, because Enter() should always return a value. See: http://developer.byond.com/docs/ref/info.html#/atom/proc/ Enter

However, if you want to know how to create passworded rooms, then what you've got there is about right. Just slap that Enter() proc onto whatever area you want passworded, once you fix the if() statement, the input (which currently doesn't do anything with the input), and the return values. However, in your Move() proc, you want to do .=..() instead of just ..() (. is the default return value), then if(.) before telling them about the new room. That way, if you can't move into a new room (. will be 0), it won't tell you about it, and Move() will be returning a value as it should be (see http://developer.byond.com/docs/ref/info.html#/atom/movable/ proc/Move ).
In response to Garthor
THis is a bit diffrent from icon games so im going to ask you if a example of what I think you mean are right okay?

    Kitchen
desc = "A refrigerator is here stocked with snacks and drinks for hardworking BYOND coders."
south = "Lounge"
Enter(atom/movable/O)
input("What is the room pass?","") as text
if(text = "Kitchen")
usr<<"You are grantted accsess"
return
else
usr<<"You are not allowed in."

In response to Black Wolf Production
Read the entry in the reference about Enter() to find out what it's supposed to do and how it behaves.

Check if ismob(O) before you try to do anything, because I assume you don't want inanimate objects to be asked for a password.

DO NOT USE USR. The argument (O, in your case) is the atom/movable being moved into the area. Usr is definitely not the mob you're looking for.

DO SOMETHING with the input you receive. As it is now, you're just getting the input and expecting it to magically appear in the variable "text" which you apparently haven't defined, either. See: http://developer.byond.com/docs/ref/
In response to Garthor
this is a text game, no icons... no npcs(yet) and when there will be npcs they wont move
In response to Black Wolf Production
It has nothing to do with moving NPCs.
In response to Garthor
no moving objs either. just moving people
In response to Black Wolf Production
Not what I'm talking about either.

Just fix it.
In response to Garthor
      
Kitchen
desc = "This is the kitchen
south
Enter(mob/player)
input("What is the room pass?","") as num
if(124)
usr<<"You are grantted accsess"
return
else
usr<<"You are not allowed in."
move(locate("Lounge"))

but when i do that you get into the room, and even if you get the passs wrong it lets you in and the move() proc wont move you to the "Lounge"
In response to Black Wolf Production
I'm not sure why it's not returning them to the lounge, its probably an effect of the if() statement being wrong, and it doesn't allow or disallow according to if you have the password right. The DM editor doesn't know what "124" means.

Kitchen
desc="This is the kitchen."
south
Enter(mob/player)
var/p=input("What is the room pass?")as num
if(p==124)
usr<<"You are granted acess."
return
else
usr<<"You are not allowed in."
usr.Move(locate(Lounge))
In response to Tweelik
Fix one thing, break another, ignore a third and a fourth.

1) p==124 is right. The if(124) was always true and so was a useless if() statement
2) locate(Lounge) is wrong. I'm assuming he's using tags to locate rooms, so locate("Lounge") would be right.
3) he's still using usr, which is, once again, WRONG.
4) Enter() still needs to return something.
In response to Garthor
REturn what, what the heck do you want me to return there? I cna't figure out what you want there.

There is nothing wrong with using usr there. because it sends a message to the palyer say weather they got it right or if they didn't


Edit: Tweeliks code worked using usr so don't tell me it is wrong, Thanks Tweelik
In response to Black Wolf Production
I'm telling you it's wrong because usr is the wrong variable to be using in Enter(). Whether it's working for your insufficient test cases is irrelevant, it's wrong. Wrong wrong wrong. If EVER a player moves for a reason OTHER than hitting NORTH/SOUTH/EAST/WEST, then usr will be completely unknown. And even if that NEVER happens, you might change it so it DOES. And this is all irrelevant because THE ARGUMENT TO ENTER() IS THE EXACT VARIABLE YOU WANT. It's like saying, "Yes, I have a steak knife, but I'm fine with cutting my steak with my butter knife, thankyouverymuch." It's just dumb and wrong.

And, once again, read the reference entry on the Enter() proc.
In response to Garthor
Garthor wrote:
I'm telling you it's wrong because usr is the wrong variable to be using in Enter(). Whether it's working for your insufficient test cases is irrelevant, it's wrong. Wrong wrong wrong. If EVER a player moves for a reason OTHER than hitting NORTH/SOUTH/EAST/WEST, then usr will be completely unknown. And even if that NEVER happens, you might change it so it DOES. And this is all irrelevant because THE ARGUMENT TO ENTER() IS THE EXACT VARIABLE YOU WANT. It's like saying, "Yes, I have a steak knife, but I'm fine with cutting my steak with my butter knife, thankyouverymuch." It's just dumb and wrong.

And, once again, read the reference entry on the Enter() proc.

For one I notice how you always critisize(sp?) other peopls code instead of try to help, I read the freaking entry on the Enter() proc 4 times over it made no sence to me, plus this effects nothing with moving, it effects the rooms, not movent. Try helping instead of critisizing(sp?) other people just to make yourself feel good.
In response to Black Wolf Production
I make criticisms because helping people includes telling them what they've done wrong. For example, you've done wrong by using usr in a proc where it's not safe to use it. Thus, I'm criticizing you for that.

I don't "help" people if your definition of "help" is to interpret their vague and poorly-worded pleas and give them everything they could possibly want, all nearly put together in code, along with exact instructions on how to plug them into their umpteenth anime rip. I DO help people if you have a PROPER definition of "help," such as "assist people in no longer needing to return to the help forums every single time they have the slightest problem." My goal isn't to fix problems, my goal is to teach people HOW to fix problems.

Enter() has EVERYTHING to do with movement. Before any movement Enter() is called. If both oldloc.Exit() and newloc.Enter() don't return 1, then movement doesn't occur. That's why it's important. Your Enter() proc returns nothing, ever. Therefore, it is not working properly.

You seem to be hung up on the fact that you are using areas instead of turfs. That doesn't matter, not in the slightest. A mob can occupy and move between areas in EXACTLY the same manner as it moves between turfs.

I'm more hostile with you than many other people, however, because you consistently refuse to take advice, ignore people, and steer other newbies astray by providing bad advice. You refuse to do things the PROPER way under some misguided notion that you know better than people who have more experience. You don't. That's why you're here. Take advice or get out.
In response to Garthor
Ya and half the time of your "helping" people don't understand you,they have to wait for other people to come and practically translate what your sayign so that they may be able to undertand it.
In response to Black Wolf Production
Only because they're not willing to put in the effort that SHOULD be required of them.
In response to Garthor
I read half your post 10 times befor I can understand them. Not all people have been coding for years like you and don't know what you mean.
In response to Black Wolf Production
He is indeed correct.

I looked over some things that should be fixed.
You shouldn't use usr, even if it works...its bad practice, and what you want to return for Enter() would be 1, obviously, if you read the DM reference of it, it simply states:

"return
1 to permit; 0 to deny"

In response to Tweelik
Tweelik wrote:
He is indeed correct.

I looked over some things that should be fixed.
You shouldn't use usr, even if it works...its bad practice, and what you want to return for Enter() would be 1, obviously, if you read the DM reference of it, it simply states:

"return
1 to permit; 0 to deny"


if I wanted it to permit all the time I wouldn't even need the code in the first place, leaving it just as
Enter(mob/player)
works great, and i changed those usr's to src and it still works
Page: 1 2