TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Unrandom behavior of dice rolls in WinTin++

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Anarajado



Joined: 08 Sep 2010
Posts: 6

PostPosted: Wed Sep 08, 2010 1:48 am    Post subject: Unrandom behavior of dice rolls in WinTin++ Reply with quote

I'm working on a script to choose a random direction, but I'm not getting what I expect from a 1d8 die roll in an #action statement.

#math result 1d8 seems to work fine if I type it into the console.

Here's the script I tried(modified to try and figure out what's wrong, I was swtiching on 1d8)

Code:
#action {setDir}
{
  #math result 1d8;
  #switch {$result}
  {
    #case {1} {#var result n};
    #case {2} {#var result ne};
    #case {3} {#var result e};
    #case {4} {#var result se};
    #case {5} {#var result s};
    #case {6} {#var result sw};
    #case {7} {#var result w};
    #case {8} {#var result nw};
  }
}

I'm only getting 2 values back when I #showme setDir, but it can vary. If I execute #math result 1d8, then I can get slightly different results when I run the action again, but it quickly gets caught between two numbers. If I'm just doing something silly with my code, let me know.
Back to top
View user's profile Send private message
Chicomecoatl



Joined: 08 Sep 2009
Posts: 73
Location: Kansas

PostPosted: Wed Sep 08, 2010 9:08 pm    Post subject: Reply with quote

I had a similar issue when i did something like it, i eventually resorted to using an array vs #switch, and it seems to work ok.

Code:


#var {exits} {{1}{n}{2}{s}{3}{w}{4}{e}{5}{u}{6}{d}}

#alias {randex}
{
    #math {randex} {1d6};
    #send {$exits[$randex]}
}



I tested for quite a while with it, and haven't seen it mess up yet Smile I haven't seen a tendancy for it to prefer any number yet, either.
_________________
Chico
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Thu Sep 09, 2010 2:23 pm    Post subject: Reply with quote

Your #switch code produces a random result for me. Math is valid in tables, so the following will work as well:

Code:

#var {exits} {{1}{n}{2}{s}{3}{w}{4}{e}{5}{u}{6}{d}}

#alias {randex}
{
    #send {$exits[1d6]}
}
Back to top
View user's profile Send private message Send e-mail
Anarajado



Joined: 08 Sep 2010
Posts: 6

PostPosted: Sat Sep 11, 2010 6:47 pm    Post subject: Thanks Reply with quote

Thanks for the feedback. I'll use your approach. Nod
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group