Can a proc called within a verb end the verb before the verb can continue? I ask this because I want to make it so all of a user's verbs check to see if that user is dead before it continues. If the user is dead I don't want the verbs to continue.
If it's possible how would you suggest I write it?
ID:154365
Nov 23 2001, 3:58 pm
|
|
In response to FIREking
|
|
How would I make it NOT finish test 1?
|
In response to Evilkevkev
|
|
Evilkevkev wrote:
How would I make it NOT finish test 1?return 0 |
In response to Air _King
|
|
Reading the original post would help too, Air_King.
|
Evilkevkev wrote:
Can a proc called within a verb end the verb before the verb can continue? I ask this because I want to make it so all of a user's verbs check to see if that user is dead before it continues. If the user is dead I don't want the verbs to continue. If it's very simple to check if the usr is dead, for instance if you have a "dead" variable, all you need to do is: mob/verb/say(msg as text) if (dead == "yes") return 0 world << "[usr]: [msg]" But since you wanted to know about procs, with a proc you'd do this: mob/verb/say(msg as text) if (Dead()) return 0 world << "[usr]: [msg]" mob/proc/Dead() if (dead == "yes") return 1 if (dead == "no") return 0 Z |
In response to GateGuardian
|
|
You'd think so, but time and time again, FireKing has proven otherwise.
|
In response to LexyBitch
|
|
LexyBitch wrote:
You'd think so, but time and time again, FireKing has proven otherwise. hehe |
Evilkevkev wrote:
Can a proc called within a verb end the verb before the verb can continue? I ask this because I want to make it so all of a user's verbs check to see if that user is dead before it continues. If the user is dead I don't want the verbs to continue. It sounds to me like you're looking for a Java-style exception that will just end whole layers of procs if one condition changes. Unfortunately, I don't think this is possible in BYOND. What you're going to have to do is check for the user's death at different points within the proc and the verb. At which point you check depends on when and how things can change. In an ideal world, the user's death status is not going to change during the verb, so a single if() at the beginning ought to be sufficient. However, if the proc calls sleep(), that's all out the window; you'll need to check again. To return from multiple levels, you'll have to return out of your proc as soon as the user is dead, then within the verb that called it, check again to see if the user is dead, and if so then call return again from there. It's the most inelegant solution possible, but it's about the only way to do it. Lummox JR |
mob/verb/Climb(obj/O as obj in oview(1)) Good luck! |
example
mob
verb
test()
src << "test1 Starting..."
test2()
src << "test1 Done!"
proc
test2()
src << "Test2 started"
sleep(30)
src << "Test2 done!"
when test is clicked, it will say
test1 starting
then test2 will be called, and it will say
test2 started
it will then sleep for 3 seconds, and then carry out the rest of the actions in test2, then in test1, then its done.
FIREking