ID:272939
 
I'm slowly building a text MUD, and the way I originally had it set up was to use the arrow keys to move between rooms.
Then I figured that the odds of someone leaning on their keyboard and accidentally shifting rooms when they don't want to is a bit high.

What I would like to have happen would be for the verb to bring up a dialoguebox that displays the direction (north, south, east, west) and name of every available exit, with the option to cancel if you don't want to move.

And no, I've never coded before. >w<; hence the nubby question. Sorry.
Uh, failing that, just learning how to make a popup box would be useful... >w<;
In response to Axel Wildfire
Check alert() and input()
In response to Ruben7
Thanks. *goes to check*

I hate being new to something. XD
In response to Axel Wildfire
Yeah, that helped a lot. Thankyou.
In response to Axel Wildfire
Oh look, triple posting just to irk people. >w>;;;;

So, say it's this format being used:

mob
verb
move()
alert("Where do you wish to move to?",,


What I'd like to get it to do is:

1. Display the name of all available exits, and the direction they are in. I.e. North: Lounge, South: Kitchen, etc, as well as displaying a cancel button that will kill the popupbox
2. Move the user to the area that they select.

... and I have no idea how to. ^^;
In response to Axel Wildfire
For multiple options, it's more useful to use input() than alert, which has a maximum of 3 and looks not as cool.
In response to Kaiochao
So in that case, would it be possible to use it as

usr.loc = input


and if so, how would I go about making it context-sensitive to the room and it's exits?
In response to Axel Wildfire
You could do something like have each room have a list of exits, and use them as the input, like

var/list/ExitList = list("NORTH","WEST","Cancel")
var/Decision = input("Which Direction?","MOVE","Cancel")in ExitList

if(Decision == "NORTH")
//Code for going to the north room/tile/whatever
else if(Decision == "WEST")
//Code for going west


and modify it to your needs
In response to Morialis
You could also have an associative list. And to not need a Cancel option and have a Cancel button instead, use "input() as null|anything in ExitList". The null part adds the Cancel button. The anything part lets you choose anything in the list, which it does by default.
//Associative list:
var/list/Fruit=list("Apple"=50,"Banana"=75)
var/c=input("What fruit do you want to buy?","Fruit Salesman")as null|anything in Fruit
if(c) //check if they didn't click Cancel, which returns null.
var/price = Fruit[c] //Get the associated value of c in Fruit, which is the number.
//fruit-buying stuff here.

In your case, you'd want an associative list containing the direction and description.
In response to Kaiochao
That part about the not needing cancel helps me a bit =p
In response to Morialis
Thanks for the help. ^^;
In response to Axel Wildfire
Tch, I need just a little more help... using a combination of ideas here:

    Courtyard
desc = "Hushed noises from the lounge drift out into this pleasant-smelling courtyard."
east = "Lounge"
var/list/ExitList = list ("east")
var/Decision = input("Which direction?")as null|anything in ExitList
if(Decision == East) usr.Move(locate(A.east)


But I'm not entirely sure how to phrase the 'else' statement so that the usr won't move anywhere. Sorry for the nubbishness. ^^;
In response to Axel Wildfire
I don't think you even need an else statement to do nothing, also you should make sure you capitalizations match, i see East and east.
In response to Morialis
I thought if statements required an else statement? owo;
And also, thanks, I thought I'd fixed that already but apparently not. It's fixed now alright. XD

Ah, hell, the problem was a missing rightparen, which now that it's fixed has given rise to a whole host of problems. Back to adventure >w>;;;
In response to Axel Wildfire
good luck lol
In response to Morialis
Thanks XD I think I'll need it.
In response to Axel Wildfire
Okay, I know I'm screwing something up here. What I've tried to do (and failed miserably at xD) is to have a proc that calls the ExitList whenever it's needed. So for example:

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"
var/list/ExitList = list ("east")

mob
verb
move
Move

proc
Move
var/area/A = usr.loc
var/list/ExitList
var/Decision = input("Which direction?")as null|anything in ExitList
if(Decision == east) client.Move(locate(A.east))
else if(Decision == west) client.Move(locate(A.west))
else if(Decision == north) client.Move(locate(A.north))
else if(Decision == south) client.Move(locate(A.south))


The three else if statements give me this when I try to compile:

error: client: expected end of statement

And I have no idea why... though I'm pretty sure I've goofed elsewhere, which is part of what's causing this. XD
In response to Axel Wildfire
area
bedroom
desc="A nicely decorated bedroom"
Exit(mob/M)
if(M.dir!=SOUTH && M.client) //really, any dir is safe
//make sure it's a mob with a client that's leaving
return 0 //don't allow it
else
M<<"You have left the bedroom."
return 1

Any time the player enters the bedroom area, they have to exit south or they can't leave.
You could do the same thing for entering areas (using Enter()), too.
In response to Axel Wildfire
Not sure if this is causing the problem, but try changin:

Move
var/area/A = usr.loc
var/list/ExitList
var/Decision = input("Which direction?")as null|anything in ExitList
if(Decision == east) client.Move(locate(A.east))
else if(Decision == west) client.Move(locate(A.west))
else if(Decision == north) client.Move(locate(A.north))
else if(Decision == south) client.Move(locate(A.south))


to this:

Move
var/area/A = usr.loc
var/list/ExitList
var/Decision = input("Which direction?")as null|anything in ExitList
if(Decision == east) client.Move(locate(A.east))
else if(Decision == west) client.Move(locate(A.west))
else if(Decision == north) client.Move(locate(A.north))
else if(Decision == south) client.Move(locate(A.south))


there was an unneeded indenting starting at var/Decision line
Page: 1 2 3