|
Thunderbuster Novice
Joined: 07 Nov 2001 Posts: 45 Location: USA
|
Posted: Mon Sep 27, 2004 5:22 pm
Pulling items randomly from a varable list. |
Once again I go ACK TTTTHHHHHPPPPPPTTTTTTT!
Ok, here is what I have...
I am randomly creating a list of room exits. (There are reasons for not using paths)
For example the mud output will be like the following...
Obvious exits:
East - A Jade Trail
West - A Jade Trail
I trigger "Obvious exits", "North -", "South -", "East -", and "West -"
each of these I give a boolean value to represent if this is a viable direction at the present time.
I then set a TICK TIMER to display #SH Moving right along
I trigger that with the following code...
----------------------------------------------------------
#GAG
ExitList=""
ItemCount=0
#if (@ExitEast) {
#ADDITEM ExitList {East}
#ADD ItemCount 1
}
#if (@ExitWest) {
#ADDITEM ExitList {West}
#ADD ItemCount 1
}
#if (@ExitNorth) {
#ADDITEM ExitList {North}
#ADD ItemCount 1
}
#if (@ExitSouth) {
#ADDITEM ExitList {South}
#ADD ItemCount 1
}
@ExitList.%random( 1, @ItemCount) <---- Here is problem
ExitNorth=0
ExitSouth=0
ExitEast=0
ExitWest=0
----------------------------------------------------------
The results I get from this is "East|West.2" or "East|West.1", not the desired "East" or "West" that I would get from #SHOW @ExitList.1 or #SHOW @ExitList.2
Would someone plz kick me in the right direction here.
Thanks and Regards... |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Sep 27, 2004 8:57 pm |
%item( @ExitList, %random( 1, %numitems( @ExitList)))
EDIT: Changed %len to %numitems. |
|
_________________ LightBulb
Senior member
Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Last edited by LightBulb on Tue Sep 28, 2004 5:52 am; edited 1 time in total |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Mon Sep 27, 2004 9:10 pm |
Try this
Change line to #EXEC @ExitList.%random( 1, %numitems(@exitlist))
and get rid of the #ADD lines as it is no longer needed
And if your using Lightbulbls example I think you want %numitems() and not %len
And here is a Complete rewrite using alarms and stringlist:
#CLASS Exits
#TR "exitstr" {Obvious exits:} {
exits=""
#TEMP "exitstemp" {^$} {
#STATE exitstr 0
#ALARM "exits" {+5} {#EXEC %item(@exits,%random(1,%numitems(@exits))}
}
}
#COND {(%w) - *} {
#ADDITEM Exits "%1"
} {looplines|param=10}
#CLASS 0 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Sep 28, 2004 5:53 am |
Oops.
Good catch. I fixed it. |
|
_________________ LightBulb
Senior member
Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious. |
|
|
|
|
|