ID:149677
 
Awhile back somewhere maybe reading someone else's code or perhaps a tutorial I saw where someone did a simple Yes/No Alert window pop-up. Can someone post the code to do this? I know alert << "My text here." part, but not how to add the buttons Yes/No instead of just OK.

LJR
switch(alert("Yes or no?",,"Yes","No"))
In response to Nadrew
SWEET!!! I knew there had to be an easier way! ;)

LJR
In response to Nadrew
Ok and how would I get the result if Yes?? Do an if? but how?

LJR
In response to LordJR
mob/verb/Test()
switch(alert("Yes or no?",,"Yes","No"))
if("Yes")
usr << "YES!"
else
usr << "NO!"
In response to Nadrew
ah.. I see no == just if("Yes") cool cool.. thanks man

LJR

ps. Keep on the look out for Star Traders ;)
In response to LordJR
When you use switch() it allows you to use if("Condition") instead of if(var == "condition")


mob/verb/Test()
var/promptbox = alert("Yes or no?",,"Yes","No")
if(promptbox == "Yes")
usr << "YES!"
else
usr << "NO!"


Is the same as the code I gave you. You could also do
switch(promptbox)
if("Condition")
...
In response to LordJR
Just a little lesson, you could have avoided this question by looking up alert() in the reference! It has the following example:

mob/verb/self_destruct()
switch(alert("Would you like to die?",,"Yes","No","Maybe"))
if("Yes")
del usr
if("No")
usr << "You have second thoughts."
if("Maybe")
usr << "You flip a coin..."
if(rand(0,1))
usr << "Heads -- you lose."
del usr
else
usr << "Tails -- you win!"

In response to Foomer
hehehe Well golly Gee Jinkins! Thats where I saw it before!!! I just couldn't remember where.

LJR