Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
guganslof
Beginner


Joined: 05 Apr 2008
Posts: 19

PostPosted: Wed Jan 23, 2013 7:57 pm   

[2.37] #waitfor
 
Im trying to make a trigger/script for exploring that searches every room exit not available.

<trigger priority="5100" id="510">
<pattern>~[ obvious exits: (%w) (%w) ~]$</pattern>
<value>#echo %1
#echo %2
#IF ((%1 != S) AND (%2 != S)) {search south;#WAITFOR {You didn't find anything.} @searchtime {} {}}
#IF ((%1 != N) AND (%2 != N)) {search north;#WAITFOR {You didn't find anything.} @searchtime {} {}}
#IF ((%1 != E) AND (%2 != E)) {search east;#WAITFOR {You didn't find anything.} @searchtime {} {}}
#IF ((%1 != W) AND (%2 != W)) {search west;#WAITFOR {You didn't find anything.} @searchtime {} {}}
#IF ((%1 != U) AND (%2 != U)) {search up;#WAITFOR {You didn't find anything.} @searchtime {} {}}
#IF ((%1 != D) AND (%2 != D)) {search down;#WAITFOR {You didn't find anything.} @searchtime {#echo Done searching.} {}}</value>
</trigger>

Now i've used the #waitfor command because I want it to continue to the next search option when 'You didnt find anything.' right away. But incase you do find something, it times out and keeps searching.

But for some reason it'l search 1 or 2 rooms then completely stop. I can re-enter the room and it will search it fully. Any idea whats up?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4772
Location: Pensacola, FL, USA

PostPosted: Wed Jan 23, 2013 8:42 pm   
 
you would need an ugly nested if for that
waitfor only pauses the current block of code (in this case, the rest of a single if statement) before continuing
it wont pause things outside of said code block

you would do better to turn your list of exits into a stringlist and do something like....

$testExits=N|S|E|W|U|D
#FORALL $testExits {#IF ((%1 != %i) AND (%2 != %i)) {search %i;#WAITFOR {You don't find anything.} @searchtime {}}}
_________________
Discord: Shalimarwildcat
Reply with quote
guganslof
Beginner


Joined: 05 Apr 2008
Posts: 19

PostPosted: Thu Jan 24, 2013 7:22 pm   
 
Ah, didnt know about the #FORALL, thats pretty handy and much cleaner, thanks.

Tried it out and it only does one search though and then stops, doesnt complete the rest.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4772
Location: Pensacola, FL, USA

PostPosted: Thu Jan 24, 2013 7:48 pm   
 
does @searchtime have an integer value?
might be better to just stick a real number there
_________________
Discord: Shalimarwildcat
Reply with quote
guganslof
Beginner


Joined: 05 Apr 2008
Posts: 19

PostPosted: Fri Jan 25, 2013 8:50 am   
 
Figued it out, was missing some brackets :)

#FORALL $testExits {#IF ((%1 != %i) AND (%2 != %i)) {search %i;#WAITFOR {You didn't find anything.} @searchtime {}{}}}


Another question, when I get more then 2 room exits, can it logically check for more than 1 and?

Pattern: ~[ obvious exits: (%w) (%w) (%w) ~]$
$testExits=N|S|E|W|U|D
#FORALL $testExits {#IF ((%1 != %i) AND (%2 != %i) AND (%3 != %1)) {search %i;#WAITFOR {You didn't find anything.} @searchtime {} {}}}

Every time it searches for the 3rd exit as if it's not checking for it.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4772
Location: Pensacola, FL, USA

PostPosted: Fri Jan 25, 2013 8:57 am   
 
you used %1 in the third instead of %i
but there is a better way....


Pattern: ~[ obvious exits: ([%w%s]) ~]$
$testExits=N|S|E|W|U|D
$myExits=%replace(%trim(%1), " ", "|")
#FORALL $testExits {#IF (!%ismember(%i, $myExits)) {search %i;#WAITFOR {You didn't find anything.} @searchtime {} {}}}
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net