|
aliensurfer Beginner
Joined: 11 Apr 2005 Posts: 17
|
Posted: Thu Jun 02, 2005 12:43 pm
Items in an Array |
Hello,
I have the following problem:
I can construct bombs and set timers for them to explode after a given time limit. The problem is if i make 2 web bombs and use the MUD syntax "Timer webbomb 30" (30 is the timer in seconds ) it will only set the time on the first bomb, if i run the command again, it states the bomb already has the timer set. The bombs have a unique id which is shown when you run a full inventory list, so i could use "timer bomb12345 30" Also, there are 4 different types of bombs.
Would I like is to run the inventory list, add the unique bomb ID's to an array and them set the timer on each bomb with a single alias. The example MUD output is:
You are holding:
"bomb12345"
"bomb12346"
"bomb12347"
"bomb12348"
I have done the following, and although I'm not currenty in a position to test it, I would like someone to look over it to see if it is right. I have a very strong suspicion it isn't.
#VAR bombs {}
#TRIGGER {^{"bomb%d"}} {#ADDITEM bombs {%1}}
#ALIAS bang {timer bomb%item}
So:
bang 25
gives the MUD the syntax of "timer bomb(Unique ID) 25" and would set all bombs with a 25 second timer.
Thanks in advance
AS |
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Thu Jun 02, 2005 1:23 pm |
#ALIAS bang {#LOOP 1,%numitems( @bombs) {timer bomb%item( @bombs, %i)}}
bang 30
timer bomb12345 30
timer bomb12346 30
timer bomb12347 30
timer bomb12348 30 |
|
_________________
Last edited by DeathDealer on Thu Jun 02, 2005 1:50 pm; edited 2 times in total |
|
|
|
aliensurfer Beginner
Joined: 11 Apr 2005 Posts: 17
|
Posted: Thu Jun 02, 2005 1:27 pm |
Thank you DeathDealer, so my #VAR and #TRIGGER lines are ok, just need to add this #ALIAS line?
|
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Thu Jun 02, 2005 1:51 pm |
For some reason i can't get the adding of the bombs to the variable to work the way you have it.
Tried a few diff things as well.
I added them manually to get the results above.
I know i'm missing something obvious with the trigger, but damned if i know what...
Question, does the inventory literally say:
You are holding:
"bomb12345"
"bomb12346"
"bomb12347"
"bomb12348"
with the "'s in there?
Also, i think it should be
#TRIGGER {^~"bomb%d~"} |
|
_________________
|
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Thu Jun 02, 2005 1:58 pm |
OH WAIT!! damn i'm an idiot...
#var bombs {}
#TRIGGER {^~"bomb(%d)~"} {#ADDITEM bombs {%1}}
need the () around the %d
Also, as a side note, the alias should be changed to clear the bombs var otherwise you'll just keep adding to it.
#CLASS {BOMBS}
#ALIAS bang {
#LOOP 1,%numitems( @bombs) {timer bomb%item( @bombs, %i) %1}
#VARIABLE bombs {}
}
#VARIABLE bombs {}
#TRIGGER {^~"bomb(%d)~"} {#ADDITEM bombs {%1}}
#CLASS 0
Edited to correct clearing syntax and add alias correction |
|
_________________
|
|
|
|
aliensurfer Beginner
Joined: 11 Apr 2005 Posts: 17
|
Posted: Thu Jun 02, 2005 8:40 pm |
Works a treat Thanks!
|
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Thu Jun 02, 2005 11:28 pm |
Yer welcome :-) Glad to be helping rather than sounding like the feeble minded fool i usually am :-)
damn, why do i feel a sense of dejavu?.... |
|
_________________
|
|
|
|
|
|