ID:142051
 
Code:
mob/verb
Test_When()
when(Test == 0,10)
world << "It works!"

Change_Test()
Test = !Test
world << "Test: [Test]"

proc
when(var/Condition,var/Sleep)
while(!Condition)
world << "Sleeping. Condition: [Condition], Sleep: [Sleep]."
sleep(Sleep)


Problem description:
The problem, if you can tell, is that Condition is never updated. Once the when() proc gets it's initial Condition, the value never changes. For example:

var/Test = 5
when(Test > 11)

Once received, the while() statement will continually check to see if 5 > 11. Regardless of whether or not it's value increases, the while() statement will never receive the updated value. I'm wondering if there's a way to get passed this problem so that the while() statement can update it's check.
Note that this bit of code:
Test == 0

Is going to be evaluated in the argument. Depending on whether or not Test actually does equal zero, it will evaluate to 1 or 0. In order to do something like this, you'll have to pass it as a string and use something like SET or SET_mod.
This occurs because the statement Test == 0 is evaluated instantly and the value sent through the arg (whether it is 0 or 1) will never change because an arbituary value, not a condition, is being sent. If you want to use a condition, then you would have better luck using a macro.

#define when(condition, time) while(!(condition)) { sleep(time) }
In response to Unknown Person
Thanks, I've got it working now. =)