|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Wed Nov 27, 2013 10:25 pm
Using a variable to store credits on hand |
Quote: |
[ Con: 18 ] [ Kills: 1216 ] [ Credits: $ 5365 ] |
This is an example of the line on the score sheet for the mud I'm playing on. I want to be able to store the current credits on hand, and then call on that value in a command to give X credits person. I've tried a few things, and it either results in it not properly calling on the variable, or sending a whole bunch of parse error messages on the score sheet. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Nov 27, 2013 11:03 pm |
Code: |
#TRIGGER {^~[ Con: %d ~] ~[ Kills: %d ~] ~[ Credits: ~$ (%d) ~]$} {credits = %1} |
That'll store the number of credits in a variable named credits, you can then reference it in other triggers/aliases/etc with @credits. |
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Wed Nov 27, 2013 11:09 pm |
If I just forget about the con and kills section and do
Code: |
#TRIGGER {[ Credits: ~$ (%d) ~]$} {credits = %1} |
Would that work too?
|
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Wed Nov 27, 2013 11:28 pm |
using your trigger, I then tried to call on the variable (renamed sakecredits) (sake is char name). the line of code I have is
Code: |
give @sakecredits credits krom |
. I've tried $sakecredits, &sakecredits, and just sakecredits, but it's always returning a blank.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Nov 28, 2013 1:38 am |
I assume that when you changed the variable's name you also changed all references to that variable to whatever you namechanged to? Renaming the variable sakecredits does no good if the trigger is still using "credits = %1".
Beyond that, try putting a #PRINT command into the trigger to see if it's even firing. We don't know the context of your line, but it could be that the space between the $ and the numbers is optional based on the length of the number (ie, "Credits: $ 5000" versus "Credits: $10000"). |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Fri Nov 29, 2013 2:40 am |
MattLofton wrote: |
I assume that when you changed the variable's name you also changed all references to that variable to whatever you namechanged to? Renaming the variable sakecredits does no good if the trigger is still using "credits = %1".
Beyond that, try putting a #PRINT command into the trigger to see if it's even firing. We don't know the context of your line, but it could be that the space between the $ and the numbers is optional based on the length of the number (ie, "Credits: $ 5000" versus "Credits: $10000"). |
Currently I have the following:
Code: |
#TRIGGER {^~[ Con: %d ~] ~[ Kills: %d ~] ~[ Credits: ~$ (%d) ~]} {sakecredits = %1} |
And the alias I'm trying to use it in is:
Code: |
give @sakecredits credits krom |
Using #PRINT @sakecredits is returning zilch. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Nov 29, 2013 3:03 am |
I just tested it and that pattern works perfectly on this line:
Quote: |
[ Con: 18 ] [ Kills: 1216 ] [ Credits: $ 5365 ] |
You're sure that's the entire line, start to finish? As Matt said, there's no spacing inconsistencies, etc? |
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Fri Nov 29, 2013 4:05 am |
Actually yeah, there are spacing inconsistencies. It aligns the credit number to the right, so there can be variable spaces before the $..
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Nov 29, 2013 6:28 pm |
Use %s in your pattern to match any number of spaces.
|
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Fri Nov 29, 2013 9:46 pm |
So like %s instead of %d?
|
|
|
|
hogarius Adept
Joined: 29 Jan 2003 Posts: 221 Location: islands.genesismuds.org
|
Posted: Fri Nov 29, 2013 10:04 pm |
Something like this:
#TRIGGER {^~[ Con: %d ~] ~[ Kills: %d ~] ~[ Credits: ~$%s(%d) ~]} {sakecredits = %1}
Note that the "%s" indicates 0 or more spaces between the literal-quoted dollar sign and the digits.
Here's some more information on trigger pattern wildcards:
http://forums.zuggsoft.com/modules/mx_kb/kb.php?page=3&mode=doc&k=2684 |
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Fri Nov 29, 2013 10:19 pm |
Here's a screenshot of the score screen itself. A lot of the spaces didn't translate right I guess.
http://i.imgur.com/6L93oz5.jpg |
|
|
|
hogarius Adept
Joined: 29 Jan 2003 Posts: 221 Location: islands.genesismuds.org
|
Posted: Fri Nov 29, 2013 11:22 pm |
Ah. Not only do you have a various number of spaces between the $ sign and the digits, but you also have spaces between the word "Credits:" and the $ sign.
When copy-pasting text into this forum, you should use [ code ] and [ \code ] tags (remove the spaces) at the beginning and end of the text. If you don't use the code tags, the forum will delete extra spaces between words.
You should set the pattern of your trigger like this:
Code: |
#TRIGGER {~[ Credits~:%s~$%s(%d) ~]} {sakecredits = %1} |
|
|
|
|
skeen77 Novice
Joined: 25 Oct 2010 Posts: 31
|
Posted: Sat Nov 30, 2013 1:53 am |
Sir, you are an officer and a gentleman. That worked, and now I'll study it so I full understand it. Thank you.
|
|
|
|
|
|