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

#math modulo

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



Joined: 16 Jul 2006
Posts: 65

PostPosted: Thu Jul 12, 2007 6:20 pm    Post subject: #math modulo Reply with quote

I have this script.
Code:
#VARIABLE         {balance_arm}        {2}

#ali arm_ready {
        #math balance_arm {${balance_arm} + 1};
        #math tmp1 {$balance_arm/3};
        #math tmp2 {$balance_arm%3};
        #math balance_arm {${balance_arm}/3 + ${balance_arm}%3};
}


I just put the #math tmp lines in for debugging purposes. What I'm trying to do is keep balance_arm to either 1 or 2.

For example:
balance_arm = 1
1+1 = 2
2/3 + 2%3 = 0 + 2 = 2

balance_arm = 2
2+1 = 3
3/3 + 3%3 = 1 + 0 = 1

The commands will work fine if I input them manually but they don't work the way I expected inside of an alias. I hope I didn't miss anything. Thanks.
Back to top
View user's profile Send private message
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Thu Jul 12, 2007 6:26 pm    Post subject: Reply with quote

It looks like the problem is that it isn't taking the modulo at all but just returning the operand ($balance_arm).
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Thu Jul 12, 2007 6:28 pm    Post subject: Reply with quote

You could try:

#math balance_arm {$balance_arm % 2 + 1}

That would keep $balance_arm at either 1 or 2.
Back to top
View user's profile Send private message Send e-mail
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Thu Jul 12, 2007 6:29 pm    Post subject: Reply with quote

It's probably the %3 which is seen as a variable in an alias. Try % 3 instead.
Back to top
View user's profile Send private message Send e-mail
louipc



Joined: 16 Jul 2006
Posts: 65

PostPosted: Thu Jul 12, 2007 10:42 pm    Post subject: Reply with quote

Aah Doh. So I did miss something. Thanks.

Hmm I wonder why I used 3. Maybe because balance_arm can actually be 0, 1, or 2. But only 1 or 2 arms can ever be 'ready'. That's a much nicer way to do it. Big Smile
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