|
kent Beginner
Joined: 03 Apr 2006 Posts: 29
|
Posted: Sat Jun 02, 2012 7:08 pm
Trying to redesign a Daily Reward from cmud to zmud 7.21 |
I know this is probably going to get me yelled and but I am trying to make a cmud class work in zmud 7.21
#class {daily_rewards}
<trigger priority="16000" regex="true" id="2">
<pattern>^A representative from the (.+) Tourism Board gives you
(.+).$</pattern>
<value>daily_item = %replace(%2, ",", "")
daily_item = %replace(@daily_item, " ","_")
daily.@daily_item = @daily.@daily_item +1
#SHOW @daily.@daily_item
#if (%1 = Tellerium) {dailyr.tellerium = %time(aaa~ hh:nn)}
#if (%1 = New Rigel) {dailyr.rigel = %time(aaa~ hh:nn)}
#if (%1 = Xaventry) {dailyr.xaventry = %time(aaa~ hh:nn)}
#if (%1 = Sigil) {dailyr.sigil = %time(aaa~ hh:nn)}</value>
</trigger>
<alias name="dr" id="3">
<value>#SWITCH (%1="reset") {
daily = ""
} (%1="") {
#show ""
#show %ansi( 9, 0)Daily rewards totals:
#loopdb @daily {#show %ansi(9,0)Rewarded %ansi( 8, 0)%val %ansi( 9, 0)of %ansi(
8, 0)%replace(%key,"_"," ")%ansi( 9, 0)~.}
#cr
}</value>
</alias>
<var name="daily" type="Record" sorted="1" id="4">
<value>a_cackling_Baba_Yaga_plushie=1|a_bar_of_silver=1|a_non-
existent_payroll_stub_with_a_scribbled_’300000’_at_the_bottom=1</value>
<json>{"a_cackling_Baba_Yaga_plushie":1,"a_non-
existent_payroll_stub_with_a_scribbled_’300000’_at_the_bottom":1
,"a_bar_of_silver":1}</json>
</var>
<var name="daily_item" id="5">a_non-
existent_payroll_stub_with_a_scribbled_’300000’_at_the_bottom</var>
<alias name="drt" id="6">
<value>#show ""
#show %ansi( 9, 0)Daily rewards timers:
#loopdb @dailyr {#show %ansi(9,0)Rewarded at %ansi( 8, 0)%val %ansi( 9, 0)from
%ansi( 8, 0)%key%ansi( 9, 0)~.}
#cr</value>
</alias>
<var name="dailyr" type="Record" sorted="1" id="7">
<value>rigel=Tue 02:38|sigil=Sat 18:13|tellerium=Tue 02:47|xaventry=Tue
03:48</value>
<json>{"rigel":"Tue 02:38","sigil":"Sat 18:13","tellerium":"Tue
02:47","xaventry":"Tue 03:48"}</json>
</var>
#class 0 |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Jun 02, 2012 8:04 pm |
1)remove the xml (you will need to replace it with the equivalent zscript syntax, which can be found in the helpfiles)
2)ZMud doesn't know what #SWITCH is, so convert that to the necessary nested #IF commands.
3)surround all %1 stuff in double quotes. In ZMud, these were preprocessed, so there was no way to tell where the value ended and the script began/continued (any whitespace would thus interfere with the parsing). This might apply to other predefined variables like %key and %val, but I don't remember.
Beyond that, it's a change in how the function operates in ZMud versus CMud rather than a syntax issue. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Tue Jul 24, 2012 2:44 pm |
Code: |
#CLASS {daily_rewards}
#ALIAS drt {
#SHOW ""
#SHOW %ansi( 9, 0)Daily rewards timers:
#LOOPDB @dailyr {#SHOW %ansi(9,0)Rewarded at %ansi( 8, 0)%val %ansi( 9, 0)from%ansi( 8, 0)%key%ansi( 9, 0)~.}
#CR
}
#ALIAS dr {
#IF (%1="reset") {daily = ""} {
#IF (%1="") {
#SHOW ""
#SHOW %ansi( 9, 0)Daily rewards totals:
#LOOPDB @daily {#SHOW %ansi(9,0)Rewarded %ansi( 8, 0)%val %ansi( 9, 0)of %ansi(8, 0)%replace(%key,"_"," ")%ansi( 9, 0)~.}
#CR
}
}
}
#VARIABLE daily {a_cackling_Baba_Yaga_plushie=1|a_bar_of_silver=1|a_non-existent_payroll_stub_with_a_scribbled_’300000’_at_the_bottom=1}
#VARIABLE daily_item {a_non-existent_payroll_stub_with_a_scribbled_’300000’_at_the_bottom}
#VARIABLE dailyr {rigel=Tue 02:38|sigilSat=18:13|tellerium=Tue 02:47|xaventry=Tue 03:48}
#REGEX {^A representative from the (.+) Tourism Board gives you (.+).$} {
daily_item = %replace(%2, ",", "")
daily_item = %replace(@daily_item, " ","_")
@daily.@daily_item = @daily.@daily_item +1
#SHOW @daily.@daily_item
#IF (%1 = Tellerium) {dailyr.tellerium = %time(aaa~ hh:nn)}
#IF (%1 = New Rigel) {dailyr.rigel = %time(aaa~ hh:nn)}
#IF (%1 = Xaventry) {dailyr.xaventry = %time(aaa~ hh:nn)}
#IF (%1 = Sigil) {dailyr.sigil = %time(aaa~ hh:nn)}
}
#CLASS 0
|
Untested as I have no idea what mud... but no syntax errors in 7.21 :P
Edit: oh, and the 2 variables daily & dialyr will need to be reset as data records... firefox or the forum doesn't retain the special chars that a txt export would.
here is the .txt file...
daily_rewards.txt |
|
|
|
kent Beginner
Joined: 03 Apr 2006 Posts: 29
|
Posted: Wed Jul 25, 2012 4:49 am |
Thank you I think this is going to work
|
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Sat Jul 28, 2012 7:31 am |
it should, no syntax errors in 7.2.1 but I have been known to use things that just work even if it ain't totally proper :P
Might have to add some double quotes to #IF clauses here and there though... if in doubt... quote it.
like:
#IF (%1 = Xaventry) {dailyr.xaventry = %time(aaa~ hh:nn)}
might need:
#IF (%1 = "Xaventry") {dailyr.xaventry = %time(aaa~ hh:nn)} |
|
|
|
|
|
|
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
|
|