ID:150838
 
mob
verb
test()
sleep(10)
src << "Test"

If I use this as a macro, tapping the macro button, it works fine. Yet if I hold down the macro button, the sleep magically disappears (The test message still displays, scrolling down the screen).

Some input on the problem? Better alternative to sleep?
On 7/19/01 1:59 pm Cinnom wrote:
mob
verb
test()
sleep(10)
src << "Test"

If I use this as a macro, tapping the macro button, it works fine. Yet if I hold down the macro button, the sleep magically disappears (The test message still displays, scrolling down the screen).

Are your sure you aren't just seeing the results of your previous calls? The expected output would be:

[hold down macro key]
[1 second pause]
Test
Test
Test
...
Test
...

Because the keypress isn't slept, the proc is. You are still sending tons of messages to the server.

The alternative is to put some kind of delay in, eg:

var/const/test_delay = 10 // 1 second delay

mob
var/tmp/test_time
verb/test()
if(world.time-test_time >= test_delay)
test_time = world.time
usr << "Test"

In response to Tom
On 7/19/01 2:11 pm Tom wrote:
Are your sure you aren't just seeing the results of your previous calls? The expected output would be:

[hold down macro key]
[1 second pause]
Test
Test
Test
...
Test
...

Because the keypress isn't slept, the proc is. You are still sending tons of messages to the server.

Well, I guess I'm not sure what exactly goes on there. All I knew was that I wasn't getting the pause I wanted at each test.

The alternative is to put some kind of delay in, eg:

var/const/test_delay = 10 // 1 second delay

mob
var/tmp/test_time
verb/test()
if(world.time-test_time >= test_delay)
test_time = world.time
usr << "Test"

That works perfectly. Thanks.