I've been trying to figure out how to solve this problem, but I can't quite. Help, please!
I'm converting a Zmud script to Mushclient. In the Zmud version, up to 5 variables are filled up with a value and then however many have a value are then randomized up, so that one of the things is executed.
So this randomly sends "guard @guard1", "guard @guard2", or "guard @guard3", where @guard1 through @guard 3 are variables with locations like "head" or "right arm".
Right now, in my script, I've got it set up so guard is an array, and it can have up to 5 elements with values.
I've got a few if's to check the highest element with a value, but that's where I'm stuck.
Example:
As soon as I see how to do that, I'll be able to figure out how to make it work for all the other possibilities (between 3 random choices, 4, 5, etc).
Thanks for your time!
I'm converting a Zmud script to Mushclient. In the Zmud version, up to 5 variables are filled up with a value and then however many have a value are then randomized up, so that one of the things is executed.
#EXEC %item( "guard @guard1|guard @guard2|guard @guard3", %random( 1, 3))
So this randomly sends "guard @guard1", "guard @guard2", or "guard @guard3", where @guard1 through @guard 3 are variables with locations like "head" or "right arm".
Right now, in my script, I've got it set up so guard is an array, and it can have up to 5 elements with values.
I've got a few if's to check the highest element with a value, but that's where I'm stuck.
Example:
if guard[3] = "" then
-- I'd like to randomly select between Send("guard " .. guard[1])
-- and Send("guard " .. guard[2]) here, but I don't know how.
return
end
As soon as I see how to do that, I'll be able to figure out how to make it work for all the other possibilities (between 3 random choices, 4, 5, etc).
Thanks for your time!