|
dragonheart Beginner
Joined: 09 Jun 2002 Posts: 15 Location: Norway
|
Posted: Fri Apr 28, 2006 1:42 pm
Newbie with a complex problem (maybe) |
Hi wizards and high capacity people.
I have encountered a problem which I need help with.
Normally I'll use manual commands to solve this, but when encountered with the number of names (which far surpasses 1000), it's not a manual job anymore. It should be made a script. So, here is what i want to do:
citizens I get a list of names where all are separated with commas (,).
I would like to be able to take those names, and process the following for each and every one of them automatically:
checktime (name)(to see how many days they've been away). If that is more than 90 days then
checkaccount (name) to see if they got anything in the bank. If
they do then
bankaccount (name) 0 to clear the account
writelog "cleared account for (name) (date)"
end
if their account is 0, then end
if they have been in the lands less than 90 days ago then end
and proceed to next name
end when all names has been processed
So now the question is if any of you would be brave and kind enough to help me with this script?
I know it's asking alot, but it would really make my days easier when processing that many names every day... |
|
_________________ Best regards,
Dragonheart |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Fri Apr 28, 2006 2:21 pm |
Output will be required to provide you with anything as we need to know what things look like when you issue those commands in order to process your logic correctly.
|
|
_________________ Taz :) |
|
|
|
dragonheart Beginner
Joined: 09 Jun 2002 Posts: 15 Location: Norway
|
Posted: Fri Apr 28, 2006 3:34 pm |
Commands are in bold, response in italic.
citizens all
Citizens of the City of Mercinae.
Zaphod, Merlin, Ichabod, Baalbek, Semia, Guenhwyvar, Perrin, Elektra, Xandra,
Kyla, Shade, Chronos, Gandulf, Elle, Tryn, Allahah, Boron, Nido, Sederien,
Conan, Johnald, Sarik, Sterne, Kandar, Brucos, Vanderghast, Senrar, Locksley,
Gumball, Galdor, Kaye, Turin, Thalion, Heru, Khaine, Roy, Twiga, Inolus,
Harper, Craig, Tristram, Tuxon, Sioned, Shaundra, Thyrza, Elena, Lleu, Korik.
The City of Mercinae has 1330 citizens.
city status Nekojin
Apprentice Bard Nekojin of Mercinae is a citizen of Mercinae.
Apprentice Bard Nekojin of Mercinae is a friend to Mercinae.
Apprentice Bard Nekojin of Mercinae is a friend to Thakria.
Apprentice Bard Nekojin of Mercinae is a friend to Parrius.
Apprentice Bard Nekojin of Mercinae is a friend to Springdale.
Apprentice Bard Nekojin of Mercinae has the city rank of Commoner.
Nekojin is a member of the Bards Guild.
It has been 1053 day(s) since he last entered Avalon.
It's the last sentence here that is interesting
bank account Nekojin
Nekojin now has an account holding 0 gold coins.
Eventually bank account Nekojin 0 to clear the account and the need to make a log of it
|
|
_________________ Best regards,
Dragonheart |
|
|
|
Vodoc Apprentice
Joined: 11 Apr 2003 Posts: 119 Location: Sweden
|
Posted: Fri Apr 28, 2006 6:06 pm |
Code: |
#TRIGGER {^Citizens of the City of Mercinae.$} {#var citizens "";#t+ capture_citizens}
#COND {^The City of Mercinae has %d citizens.$} {#t- capture_citizens;#deln citizens 1;#say {Processing %numitems( @citizens) citizens.};#forall @citizens {city status %i}}
#TRIGGER "capture_citizens" {^(*)$} {#forall {%replace( %leftback( "%1", 1), ",", "|")} {#additem citizens {%i}}} "" {disable}
#TRIGGER {^(%w) is a member of the * Guild.$} {#var citizen {%1}}
#COND {^It has been (%n) day~(s~) since {he|she|it} last entered Avalon.$} {#if (%1 > 90) {bank account @citizen}}
#TRIGGER {^(%w) now has an account holding (%d) gold coins.$} {#if (%2 > 0) {bank account %1 0}} |
I have assumed that there is no space at the end of each row but that there is a newline straight away, if this is not the case then change the triggers accordingly.
So, some explaining of the script:
- The first trigger+cond activates the capturing of all the citizens and later processes all the captured names (by issuing city status <name> for all names).
- The second trigger is activated/deactivated by the first one. This trigger captures all lines, splits them up and stores all names in a string list.
- The third trigger captures the relevant output from the command city status <name> and issues a bank account <name> where appropriate.
- The last trigger checks the output from the bank and setts the account to zero if it ain't already.
I hope this is easy enough to understand and modify where needed. |
|
|
|
dragonheart Beginner
Joined: 09 Jun 2002 Posts: 15 Location: Norway
|
Posted: Wed May 03, 2006 9:13 am |
Vodoc wrote: |
[code]#TRIGGER {^Citizens of the City of Mercinae.$} {#var citizens "";#t+ capture_citizens}
#COND {^The City of Mercinae has %d citizens.$} {#t- capture_citizens;#deln citizens 1;#say {Processing %numitems( @citizens) citizens.};#forall @citizens {city status %i}}
|
I put this into Zmud, but got two distinct faults.
One was where I'm not sure the #COND was included, and at the end it had counted 0 citizens and nobody got processed.
Then I added the #COND to the end of the triggerso it looks like this:
#var citizens ""
#t+ capture_citizens
#COND {^The City of Mercinae has %d citizens.$} {#t- capture_citizens;#deln citizens 1;#say {Processing %numitems( @citizens) citizens.};#forall @citizens {city status %i}}
I then got access violations and all kinds of strange errors.
What can this be? (I haven't used #cond before so I don't know how it works)
Thanks again |
|
_________________ Best regards,
Dragonheart |
|
|
|
Vodoc Apprentice
Joined: 11 Apr 2003 Posts: 119 Location: Sweden
|
Posted: Wed May 03, 2006 10:24 am |
Just using the first trigger/cond combo doesn't do much since all it does is to reset the variable capturing citizens and then activating the trigger that capture new citizens (trigger nr 2).
So you need to add both the first and second trigger to actually see if it captures stuff.
#COND is used to build multi state triggers and you can't add a #COND statement in the value for a trigger. If you are using the GUI then change state with the dropdown list to the right.
You can read a little bit more about #COND here.
Edit:
Ok, so adding triggers and stuff with newlines between wasn't the best of ideas. It made zMUD freak out. Copy and paste this instead into your commandline (and be sure to remove/disable any remains of the first script first to avoid confusion)
Code: |
#TRIGGER {^Citizens of the City of Mercinae.$} {#var citizens "";#t+ capture_citizens}
#COND {^The City of Mercinae has %d citizens.$} {#t- capture_citizens;#deln citizens 1;#say {Processing %numitems( @citizens) citizens.};#forall @citizens {city status %i}}
#TRIGGER "capture_citizens" {^(*)$} {#forall {%replace( %leftback( "%1", 1), ",", "|")} {#additem citizens {%i}}} "" {disable}
#TRIGGER {^(%w) is a member of the * Guild.$} {#var citizen {%1}}
#COND {^It has been (%n) day~(s~) since {he|she|it} last entered Avalon.$} {#if (%1 > 90) {bank account @citizen}}
#TRIGGER {^(%w) now has an account holding (%d) gold coins.$} {#if (%2 > 0) {bank account %1 0}} |
|
|
|
|
dragonheart Beginner
Joined: 09 Jun 2002 Posts: 15 Location: Norway
|
Posted: Wed May 03, 2006 11:05 am |
This actually worked.
Ok, last question then: Whenever I do something with an account,- in this case change it to 0,- is there any way I can put that in a separate external textfile? Like a log of some sorts?
I will try to tweak this so that I will be able to start the script, enter dormancy days and then amount left on the accounts. But this looks promising...
Thanks |
|
_________________ Best regards,
Dragonheart |
|
|
|
Vodoc Apprentice
Joined: 11 Apr 2003 Posts: 119 Location: Sweden
|
Posted: Wed May 03, 2006 7:50 pm |
dragonheart wrote: |
Ok, last question then: Whenever I do something with an account,- in this case change it to 0,- is there any way I can put that in a separate external textfile? Like a log of some sorts? |
Sure there is, read the helpfile on #WRITE or use a solution where you send text to another #WINDOW and start a #LOG in that window. |
|
|
|
|
|
|
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
|
|