counter variables 01/01/2014 12:29 PM CST
I was wondering about the use of counter variables. What I'm trying to do is set up a script to repeat a certain amount of times. In this case with weapon forging. So lets say I start the script and I have 6 work orders. So I type ".weapon broadsword 6", that way the script knows it's making a broadsword and repeating 6 times. I know that this can be done with actual code (by setting an integer variable to 1 and then adding 1 at the end of the code and repeat until int. variable = 6), but with script for DR I'm not sure if counter variables work like this, or if another method exists for that purpose. Does anyone know if this can be done?
Reply
Re: counter variables 01/05/2014 10:27 AM CST
I found a long way to go about making this work, but surely there has to be an easier way than copying the script 6 times. lol
Anyone able to help?
Reply
Re: counter variables 02/12/2014 12:17 PM CST
nope

a single "temporary" (non temporary, but unused for anything else) variable that you use to count things is useful here.

just create a counti or whatever variable you can use as a temporary variable over and over again, and just use that.

script specific variables don't exist in cmud.

.. and hopefully you are using cmud and not zmud
Reply
Re: counter variables 02/12/2014 12:23 PM CST
>I found a long way to go about making this work, but surely there has to be an easier way than copying the script 6 times. lol


there's lots of ways to do things like this, remember cmud is a trigger language.

<trigger priority="226000" id="4308">
<pattern>^You %x crush* (%x) {into some|in your}</pattern>
<value>#var crushit %1</value>
<trigger>
<pattern>^Roundtime: (%x) sec.</pattern>
<value>#alarm +%int(%1) {crush @crushit in mor with my pes}</value>
</trigger>
</trigger>

so this will crush something, then the script ends, but wait! it resets to the begin, and the new text comes in, and boom it activates again! then..

<trigger priority="228260" enabled="false" id="4310">
<pattern>^Crush what~?</pattern>
<value>put pes in mor;get pow from mor;put pow in my bag;#alarm +1 {order dra cry;offer 375;order dra cry;offer 375;#alarm +1 {combine cry;order dra cry;offer 375;combine cry;#alarm +1 {order dra cry;offer 375;combine cry;put cry in mor;#alarm +1 {get pes from mor;crush cry in mor with pes}}}}</value>
</trigger>


when there's nothing left to crush it does something else.



so make a trigger that does smoething like this.. i wrote this on the fly, it doesnt even make sense, but it gives the idea.


Alias:
startdoingmystuff
Script:
#var thecounter 1
#send "crush that stuff with my pes!"

Trigger:
^you did the stuff, this is text on the screen
Script:
#add thecounter 1
if (@thecounter < 6) {
#send "crush that stuff with my pes!"
} else {
#send "do something else!"
}
Reply
Re: counter variables 02/12/2014 12:32 PM CST
>I was wondering about the use of counter variables. What I'm trying to do is set up a script to repeat a certain amount of times. In this case with weapon forging. So lets say I start the script and I have 6 work orders. So I type ".weapon broadsword 6", that way the script knows it's making a broadsword and repeating 6 times. I know that this can be done with actual code (by setting an integer variable to 1 and then adding 1 at the end of the code and repeat until int. variable = 6), but with script for DR I'm not sure if counter variables work like this, or if another method exists for that purpose. Does anyone know if this can be done?

one last comment here.

Remember, cmud isnt a scripting language in the way that stormfront or wizard is.

stormfront and wizard are GOTO languages. cmud is a trigger language.

While stormfront and wizard use GOTO's to navigate the code, and only use pattern matching to determine what goto to use, CMUD its completely trigger based.

Every trigger is basically active all the time.
For example one of my triggers looks like this :

<trigger priority="3690" id="3343">
<pattern>^dotheappraisal$</pattern>
<value>#gag
#var train appraisal
#send "app my knife quick"</value>
<trigger>
<pattern>^Roundtime:%s(%d) seconds.$</pattern>
<value>#gag
#alarm +%int( %int( %1)) {
#send "turn my knife"
#send "app my scrap quick"
}</value>
</trigger>
<trigger>
<pattern>^Roundtime:%s(%d) seconds.$</pattern>
<value>#gag
#alarm +%int( %int( %1)) {
#send "turn my scrap"
#send "app my knife quick"
}</value>
</trigger>
<trigger>
<pattern>^Roundtime:%s(%d) seconds.$</pattern>
<value>#gag
#alarm +%int( %int( %1)) {
#send "turn my knife"
#send "app my scrap quick"
}</value>
</trigger>
<trigger>
<pattern>^Roundtime:%s(%d) seconds.$</pattern>
<value>#gag
#alarm +%int( %int( %1)) {
#send "turn my scrap"
#send "skill appraisal"
}</value>
</trigger>
<trigger>
<pattern>Appraisal:%s%d%s%d.%d~%%s({@mindstates})%s~((%d)~/34~)</pattern>
<value>#gag
#if (@stoptrainingnow == "yes") {
put my knife in my knap
echo donetrain
} {#if (%2 < 25) {echo dotheappraisal} {
put my knife in my knap
echo donetrain
}}</value>
</trigger>
</trigger>


this triggers off of the keyphrase dotheapprisal, then performs an action, waits for the roundtime, and continues down the subtriggers until the entire trigger is complete. so for my client to "activate" this trigger, another script would "echo dotheappraisal" when it was time for that trigger to activate.

here's another example (these are color scripts for talking, whispering, etc) (ignore the #noop line, noop means dont do this command, but the tts.speak would otherwise actually speak the text through the speaker)

<class name="color" id="2">
<trigger priority="20" id="3">
<pattern>^%x {whispers to your group|whispers}~, ~"(*)~"$</pattern>
<value>#CO limegreen
#NOOP @TTS.Speak(%line, 1)
</value>
</trigger>
<trigger priority="20" id="4">
<pattern>^%x {asks|says|exclaims}~, ~"(*)~"$</pattern>
<value>#CO powderblue
#NOOP @TTS.Speak(%line, 1)
</value>
</trigger>
<trigger priority="40" id="5">
<pattern>^~[*~]$</pattern>
<value>#CO violet</value>
</trigger>
<trigger priority="20" id="6">
<pattern>^%x %x {asks|says|exclaims}~, ~"(*)~"$</pattern>
<value>#CO powderblue
#NOOP @TTS.Speak(%line, 1)
</value>
</trigger>
<alias name="startspeech" id="7">
<value>#var TTS %comcreate( "Sapi.SpVoice")</value>
</alias>
<alias name="stopspeech" id="8">
<value>#var TTS ""</value>
</alias>
</class>
Reply
Re: counter variables 02/12/2014 12:39 PM CST
no reason to stop here.

here's some more help for cmud. example scripts below

GSL triggers :
<trigger type="GSL" priority="7540" id="4271">
<pattern>({l|m|p})</pattern>
<value>#if (%1 == "m") {#BU righthand %gsl( m) {glance}}
#if (%1 == "l") {#BU lefthand %gsl( l) {glance}}
#if (%1 == "p") {
#BU roomname %gsl( p) {glance}
#win roomnamedesc " "
#win roomnamedesc "[ " %gsl( p) " ] "
}</value>
</trigger>


this trigger captures the lefthand/righthand and roomname/description.
It puts the hands up in buttons, and the roomname in its own small window (i have these in my layout to all be on the same screen, in a little grid).

and...

<trigger priority="7560" id="4275">
<pattern>^Your mind hears (%x) thinking, ~"(*)~"$</pattern>
<value>#gag
#win thought %concat( %time( "h:nn:ss:am/pm "), %1, " - ", %2)</value>
</trigger>

This captures thoughts through gweths andputs them in a gweth window.
dont forget albredine rings!

<trigger priority="40820" id="4267">
<pattern>^Your mind hears (%x) thinking, ~"~<to you~>~" (*)$</pattern>
<value>#gag
#win thought %concat( %time( "h:nn:ss:am/pm "), %1, " - to you - ", %2)</value>
</trigger>

now lets do more. lets say you were being paged by a GM. (this wont help against script checks, but if a GM was using the page command to page you..)

<trigger priority="64480" id="4290">
<pattern>{PAGE!|SEND|PAGE}~[%x~]</pattern>
<value>#co 32
#beep;#alarm +1 {#beep;#alarm +1 {#beep;#alarm +1 {#beep;#alarm +1 {#beep;#alarm +1 {#beep}}}}}
#call @TTS.Speak("Answer the send! Answer the send! Answer the send!", 1)</value>
</trigger>


how about a logging script?

<trigger priority="7500" id="4287">
<pattern>^Please wait for connection to game server.</pattern>
<value>#var TTS %comcreate( "Sapi.SpVoice")
#lo %concat( "c:\zmudlogs\main", %time( "ddd-mmmm-d-yyyy-h-nn-ss-am/pm"))
#alarm +5 {store default sable knapsack}</value>
</trigger>
Reply
Re: counter variables 02/12/2014 12:44 PM CST
there's just so much you can do with cmud.

you can create actual databases of information, manipulate text and numbers in any way, it has float precision.

while cmud wasent made specifically for DR like genie,and doesnt have all the neat variables and automatic things like genie has for DR, it is a VERY powerful scripting engine.

You just have to get use to the whole trigger system.

One last tip. When i train or do things, i have a variable that stores what action i am currently performing.
So if i am trianing appraisal, i have the variable "train" set to app. If i am swimming, the "train" variable is set to swim.

So when my triggers activate, they know wether they were activated by text they need to respond to, or just random text and the script can just prevent itself from running by a simple. "if (@train == "swim") {#send "do next command"}
Reply
Re: counter variables 02/12/2014 03:13 PM CST
>>one last comment here.

>>Remember, cmud isnt a scripting language in the way that stormfront or wizard is.

>>stormfront and wizard are GOTO languages. cmud is a trigger language.

>>While stormfront and wizard use GOTO's to navigate the code, and only use pattern matching to determine what goto to use, CMUD its completely trigger based.

This makes sense now. Probably why I had issues with zmud and cmud. Have to see if I still have my license for cmud and revisit it. Thanks for posting that.

Gniloi
Reply
Re: counter variables 11/14/2016 03:13 PM CST


>This makes sense now. Probably why I had issues with zmud and cmud. Have to see if I still have my license for cmud and revisit it. Thanks for posting that.


you'll be able to get your license reemailed to you from the website.
Something i go through everytime i return from a break
Reply