Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Pwent
Newbie


Joined: 25 Aug 2004
Posts: 7

PostPosted: Wed Aug 25, 2004 4:11 pm   

Gold Splitter problems
 
Ok I am making a gold splitter for the MUD Chalacyn Nights, and well it kind of works and kind of doesn't.

Triggers:

Pattern: You get %1 gold coins.
Value: #math sgold (%1/@tmem))
splitit

Variables:
@sgold
@tmem
@plist

Aliases:
Name: splitit
Value: give $@sgold @plist
[This alias just hands out the gold to each member]

Name: +pm
Value: #math tmem (1+@tmem)
#VA plist {%1}
'Added %1 to list. Number of members @tmem
[This alias adds a player to the variable plist and adds 1 to the variable tmem]

Name: -pm
Value: #math plist %1-%1
#math tmem @tmem-1
'Removed %1 from list. Number of members @tmem.
[This alias removes a player from the varibale plist and subracts 1 from the varible
tmem]

Ok with the code as is, I cannot figure out how to set the variable @tmem to = 1 to start and step one when I add another member (the = 1 meaning myself). Another problem I am having is when I add another member (2 or more) the @plist variable adds them like so [KasumiBalthamos] so if there are 3 members it trys to give the gold to member KasumiBalthamos instead of 2 other seperate members. If this is hard to understand, I'm a newb at zMud and trying to learn...if you have answers or comments you can email me at more2minds@yahoo.com

Thanks, and Help if you can
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Thu Aug 26, 2004 12:42 am   
 
Is plist a string list, or is it set as text?
Reply with quote
Pwent
Newbie


Joined: 25 Aug 2004
Posts: 7

PostPosted: Thu Aug 26, 2004 1:51 am   
 
It's set as text, i dont know how to set it as a string list
Reply with quote
Pwent
Newbie


Joined: 25 Aug 2004
Posts: 7

PostPosted: Thu Aug 26, 2004 11:50 am   
 
Ok i solved the first problem about the splitter not including me, it does now, the variable tmem stats at 1 and steps from there when i had players. i used

#var tmem {1} and it works now, I just can't figure out how to set @plist to a string list.
Reply with quote
Pwent
Newbie


Joined: 25 Aug 2004
Posts: 7

PostPosted: Thu Aug 26, 2004 12:14 pm   
 
Ok I now have figured out how to make plist a string list,

#var plist {%1}
#additem {%1}

but know I can't figure out how to make it write to the next value so i could have

1 Balthamos
2 Kasumi

instead of overwriting the value of 1 like it's doing now....

1 Balthamos becomes 1 Kasumi when i try to add Kasumi to the group.

Help please if you could.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Aug 26, 2004 1:10 pm   
 
How about a complete rewrite (untested but its from me so it should work :P) Disable your current triggers and copy/paste this script in the command line (where you type mud commands) and hit enter. Please read the corresponding help files for all commands used to get a better grasp on how this script works
COMMANDS USED:
#TRIGGER, #VARIABLE, #ADDITEM, #DELITEM, #FORALL, #ALIAS
FUNTIONS USED:
%eval (basicly like #MATH but Im addicted to using %eval)

#TRIGGER {You get (%d) gold coins.} {#VAR sgold {%eval(%1/%eval(%numitem(@plist)+1))};splitit}
#NOOP This trigger correctly divides the gold for your @plist and YOU (+1)
#ALIAS splitit {#forall @plist {give ~$@sgold %i}}
#NOOP loops through plist and gives @sgold to each member
#ALIAS +pm {#ADDITEM plist {%1}}
#ALIAS -pm {#DELITEM plist {%1}}
#NOOP Adds and deletes members to and from @plist stringlist
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Pwent
Newbie


Joined: 25 Aug 2004
Posts: 7

PostPosted: Thu Aug 26, 2004 7:08 pm   
 
Wow thanks nexela it worked i added a lil bit of my own style and had to fix 1 error in your code but it worked. Thanks your your help. BTW your error was:

#TRIGGER {You get (%d) gold coins.} {#VAR sgold {%eval(%1/%eval(%numitems(@plist)+1))};splitit} ^
|
You forgot an 's'
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net