mob
verb
Talk(mob/M as mob in get_step(usr,dir))
for(M)
switch(alert("Do you want to talk to [usr]?",,"Yes","No"))
if("Yes")
..()
if("No")
..()
(This code will send you a switch and will ask continuously)
ID:158621
Jul 29 2009, 2:47 am
|
|
How do i send a switch to a mob by using a verb for example :
mob (This code will send you a switch and will ask continuously) |
In response to GhostAnime
|
|
No,you got me wrong I'm trying to send a switch to the mob in front of me.But instead it asks me.
|
In response to Destrojer
|
|
Then make it ask M, look up the input() procedure in the DM reference (or switch src and M in the snippet I have shown).
|
In response to Destrojer
|
|
switch() is a control statement, like if(). You want to send an alert() to another mob. Look it up in the reference, it says right there.
|
Lately I've been noticing a lot of people confuse the switch() proc to be the one showing an options popup. If you actually read the reference instead of using it without knowing about it(most likely due to seeing it in a source or a demo), you'd see it doesn't do anything special for alert() and input() rather than any other value.
var/random = rand(1,10) Bad example really, since it could simply be achieved with an if/else, but that's what switches are. They are condensed if/else-if chains that compare things to constant values. The alert() and input() procs just return a value. var/result = input("blah")in list(1,2,3,4,5) Rather than using switch() for an alert() with only two options, just use a simple if() statement, like Ghost showed. |
In response to Kaiochao
|
|
It's ok,it's ok....i managed to get it to work....thx ^^
|
And you can use a simple if-else for that: