[TF] Rand()
Brought to you by:
kenkeys
|
From: james at zephyr-works.c. (J. West) - 2003-02-09 15:31:35
|
Yes, but this is just an example function. What I really wanted to do was
something like this:
/def ran_move = /let rannum=$[rand(1,8)]%;/echo %{rannum}%;/if (%{rannum} ==
1) north%;/elseif (%{rannum} == 2) south%; \
/elseif (%{rannum} == 3) east%;/elseif (%{rannum} == 4)
south%;/elseif (%{rannum} == 5) northwest%; \
/elseif (%{rannum} == 6) northeast%;/elseif (%{rannum} == 7)
southwest%;/elseif (%{rannum} == 8) southeast%; \
/endif%;/set norats=0%;
Which of course is a random movement generator, I have another trigger set
up to rerun it if there is no exit in a certain
direction.
-----Original Message-----
From: Nuutti Kotivuori [mailto:na...@ik...]
Sent: Sunday, February 09, 2003 9:04 AM
To: Drake Wilson
Cc: James West; tin...@tc...
Subject: Re: [TF] Rand()
Drake Wilson wrote:
> Quoth James West <ja...@ze...>, on Sun 09 Feb 2003:
>> I'm trying to assign the result of rand() to a variable and failing
>> horribly, I assumed that:
>>
>> /def getrandom = /let var1=rand(0,9)%;/echo %(var1}
>
> This sets var1 to the string "rand(0,9)". To evaluate it as an
> expression, you need to put $[...] around it, like so:
>
> /def getrandom =/let var1=$[rand(0,9)]%;/echo %{var1}
Ofcourse,
/def getrandom = /result rand(0,9)
Might be a little easier.
-- Naked
|