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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Nov 02, 2007 9:56 pm   

Converting my old AutoEat Script to cMUD
 
Trying to convert my Old Autoeat script to cMUD and it isn't triggering on the inventory command. Any ideas?
Code:

<?xml version="1.0" encoding="UTF-8" ?>
<cmud>
<module name="AutoEat" global="true">
  <uid>{41A6B894-7A16-4B04-BEDE-CAC5E777C471}</uid>
  <packages>Common|English Keypad|English Directions|ShadowsofIsildur</packages>
  <class name="AutoEatAliases">
    <alias name="checkcontainers">
      <value>#ADD loopcount 1
#T+ FoodTypeTrig
look in %item( @havecontainer, @loopcount)
#ALARM +@AlarmTime {checkmorecontainers}



</value>
    </alias>
    <alias name="checkmorecontainers">
      <value><![CDATA[#T- FoodTypeTrig
#IF ( %numitems( @havefood) ~> 0 ) {
  get %item( @havefood, 1) %item( @havecontainer, @loopcount)
  eat %item( @havefood, 1)
  #NEWVAR stillhungry 0
} {
  #CR
  #SHOW <color cyan>I have no food in my %item( @havecontainer, @loopcount)!</color>
  #IF (@loopcount ~< @containercount) {
    checkcontainers
  } {
  #SHOW <color cyan>I have no food at all, better get some!</color>
  }
}]]></value>
    </alias>
    <var name="foodtypes" type="StringList">bread|apple</var>
    <var name="containertypes" type="StringList">backpack</var>
    <var name="stillhungry" type="String">1</var>
    <var name="containercount" type="String">1</var>
    <var name="AlarmTime" type="String">2</var>
    <var name="havefood" type="String"/>
    <var name="havecontainer" type="String">backpack</var>
    <alias name="condel">
      <value>#DELITEM containertypes %1
#CR
#ECHO You have deleted %1 from your container list.</value>
    </alias>
    <alias name="eathelp">
      <value><![CDATA[#CR
#CR
#SHOW <color cornsilk><b>AutoEat Help</b></color>

#ECHO <color yellow>-----------------------------------------</color~>

#ECHO <color lightgreen>This script is to reduce the mundane eating crap!</color>

#ECHO <color lightgreen>Please set your AlarmTime Variable.</color>

#ECHO <color lightgreen>This variable is the delay time from the mud to</color>

#ECHO <color lightgreen>all of you things in your inventory and containter lists.</color>
#CR

#ECHO <color lightblue>salarm</color> <color yellow>-----</color><color red> Set the AlarmTime ~(variable). ex: salarm 3</color>

#SHOW <color lightblue>foodadd</color> <color yellow>-----</color> <color red>Add food to the food list ~(variable).</color>

#ECHO <color lightblue>fooddel</color> <color yellow>-----</color> <color red>Delete food from the food list ~(variable).</color>

#ECHO <color lightblue>conadd</color> <color yellow>-----</color> <color red>Add container to the container list ~(variable).</color>
#ECHO <color lightblue>condel</color> <color yellow>-----</color> <color red>Delete container from the container list ~(variable).</color>

#ECHO <color lightblue>eatshow</color> <color yellow>-----</color> <color red>Shows your list of food, containers and the AlarmTime ~(variables).</color>
#CR]]></value>
    </alias>
    <alias name="fooddel">
      <value><![CDATA[#DELITEM foodtypes %1
#CR
#IF ( @foodtypes ~= NULL ) {
#ECHO <color cyan>Invalid entry</color>
} {
#ECHO <color cyan>You have deleted %1 to your food list.</color>
}]]></value>
    </alias>
    <alias name="foodadd">
      <value>#ADDITEM foodtypes %1
#SORT foodtypes
#ECHO You have added %1 to your food list.</value>
    </alias>
    <alias name="salarm">
      <value>#var AlarmTime %1</value>
    </alias>
    <alias name="eatshow">
      <value><![CDATA[#CR
#CR
#ECHO <color yellow><b> *** YOUR LISTS ***</b></color>
#CR
#ECHO <color cornsilk><b>Food List</b></color>
#SHOW <color lightgreen><b>-----------------</b></color>
#LOOP 1,%numitems( @foodtypes) {
  #ECHO <color cyan> %i.</color> <color red>%item( @foodtypes, %i)</color>
}
#CR
#ECHO <color cornsilk><b>Container List</b></color>
#ECHO <color lightgreen><b>-----------------</b></color>
#LOOP 1,%numitems( @containertypes) {
  #ECHO <color cyan> %i.</color> <color red>%item( @containertypes, %i)</color>
}
#CR
#ECHO <color cornsilk><b>Alarm Time</b></color>
#ECHO <color lightgreen><b>-----------------</b></color>
#ECHO <color aqua>Your current alarm time is set to @bRed@AlarmTime@bCyan seconds.</color>
#CR]]></value>
    </alias>
    <alias name="conadd">
      <value>#ADDITEM containertypes %1
#SORT containertypes
#ECHO You have added %1 from your container list.</value>
    </alias>
    <trigger name="FoodTypeTrig" priority="230">
      <pattern>({@foodtypes})</pattern>
      <value>#NOOP Check to see if you have the food listed
#IF %ismember( %1, {@foodtypes}) {
#VAR havefood %additem( %1, @havefood)}
}  </value>
    </trigger>
    <trigger name="ConTypeTrig" priority="240">
      <pattern>({@containertypes})</pattern>
      <value>#NOOP Check to see if you have the container listed
#IF %ismember( %1, {@containertypes}) {
#VAR havecontainer %additem( %1, @havecontainer)
}

</value>
    </trigger>
    <trigger priority="250">
      <pattern>You are {hungry.|really hungry.|feeling slightly hungry.</pattern>
      <value>#NOOP Clear the variables
#VAR havefood 0
#VAR havecontainer 0
#VAR loopcount 0
#VAR containercount 0
#VAR stillhungry 0
#NOOP Run your command to show your inventory

inventory

#echo Triggered</value>
      <trigger>
        <pattern>(*)</pattern>
        <value>#T+ ConTypeTrig
#T+ FoodTypeTrig</value>
      </trigger>
      <trigger>
        <pattern>@AlarmTime</pattern>
        <value><![CDATA[#T- ConTypeTrig
#T- FoodTypeTrig
#IF (%numitems( @havefood)~>0) {
  eat %item( @havefood, 1)
  #AB 1
} {
  #CR
  #SHOW <color cyan>I have no food in my inventory list.</color>
}
#IF (%numitems( @havecontainer)~>0) {
  #VAR stillhungry 1
  #VAR containercount %numitems( @havecontainer)
  checkcontainers
} {
#CR
#SHOW <color cyan>I have no containers need go buy one, duh!</color>
}]]></value>
      </trigger>
    </trigger>
  </class>
  <class name="System">
    <alias name="atconnect"/>
    <trigger priority="10870">
      <pattern>You fall asleep.</pattern>
      <value>#NOOP Change the pattern to the output line of your mud for the sleep command.;#T- AutoEatTrig</value>
    </trigger>
    <trigger priority="10880">
      <pattern>You open your eyes</pattern>
      <value>#NOOP Change the pattern to the output line of your mud for the wake command.;#T+ AutoEatTrig</value>
    </trigger>
  </class>
</module>
</cmud>
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 03, 2007 5:00 am   
 
Anybody want to give this one a shot? I am at a total loss on this one.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sun Nov 04, 2007 4:42 am   
 
It looks like when tried this the first condition of the trigger isn't turning on the ConTypeTrig and FoodTypeTrig. I know I am using 2.10 Beta, but I think this has something to do with my scripting.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Nov 04, 2007 5:06 am   
 
Where you have "#VAR havefood 0" it should be "#VAR havefood {}", stillhungry should be initialized to 1.

CheckContainers and CheckMoreContainers rely on the third state no having become active, these need to be adjusted so that the other triggers are still on.

Your third state does not appear the be set for a type of Alarm and the order of logic needs to be adjusted. The logic should be changed so that if havefood it eats, else if havecontainers it checks, else it shuts off and tells the user to go buy something. Currently you the shut off before any logic. This is causing it to not actually detect anything inside the containers.

Also I am not quite sure why you are using #NEWVAR at all. There should be no need for it, #VAR should work.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sun Nov 04, 2007 1:26 pm   
 
I was playing around with it actually. I need to look at the original script.
After I posted the first time I forgot to put in my changes. I changed the Alarm trigger to be an actual alarm and remove the darn NEWVAR..
I will look at the rest of this .
Thanks Vijilante.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sun Nov 04, 2007 3:08 pm   
 
Have your trigger pattern "<pattern>You are {hungry.|really hungry.|feeling slightly hungry.</pattern>" get compiled? Add the closing brace to it anyway.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sun Nov 04, 2007 3:10 pm   
 
My pattern is getting compiled Arde. I think there is an issue with variable string lists.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sun Nov 04, 2007 3:16 pm   
 
And you do not get an error message in the Compiled Pattern tab for your trigger? Shocked
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sun Nov 04, 2007 3:21 pm   
 
That is really weird. I noticed that when I don't have the closing parenthesis is works and my pattern matches only the first variable in the string, but all others it doesn't match. I think we found a bug!
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Mon Nov 05, 2007 4:15 am   
 
Just an update I have worked on the script in another post. I thought there was a issue with the version.
Goto http://forums.zuggsoft.com/forums/viewtopic.php?t=28735 to see that post.

Code:

<?xml version="1.0" encoding="UTF-8" ?>
<cmud>
<module name="AutoEat" global="true">
  <uid>{41A6B894-7A16-4B04-BEDE-CAC5E777C471}</uid>
  <class name="AutoEatAliases">
    <alias name="checkcontainers">
      <value>#ADD loopcount 1
#T+ FoodTypeTrig
look in %item( @havecontainer, @loopcount)
#ALARM +@AlarmTime {checkmorecontainers}
</value>
    </alias>
    <alias name="checkmorecontainers">
      <value><![CDATA[#T- FoodTypeTrig
#IF ( %numitems( @havefood) ~> 0 ) {
  get %item( @havefood, 1) %item( @havecontainer, @loopcount)
  eat %item( @havefood, 1)
  #NEWVAR stillhungry 0
} {
  #CR
  #SHOW <color cyan>I have no food in my %item( @havecontainer, @loopcount)!</color>
  #IF (@loopcount ~< @containercount) {
    checkcontainers
  } {
  #SHOW <color cyan>I have no food at all, better get some!</color>
  }
}]]></value>
    </alias>
    <var name="foodtypes" type="StringList">bread|apple</var>
    <var name="containertypes" type="StringList">backpack|pouch|bag</var>
    <var name="stillhungry">1</var>
    <var name="containercount">0</var>
    <var name="AlarmTime" type="String">2</var>
    <var name="havefood" type="String"/>
    <var name="havecontainer" type="StringList"/>
    <alias name="condel">
      <value>#DELITEM containertypes %1
#CR
#ECHO You have deleted %1 from your container list.</value>
    </alias>
    <alias name="eathelp">
      <value><![CDATA[#CR
#CR
#SHOW <color cornsilk><b>AutoEat Help</b></color>

#ECHO <color yellow>-----------------------------------------</color~>

#ECHO <color lightgreen>This script is to reduce the mundane eating crap!</color>

#ECHO <color lightgreen>Please set your AlarmTime Variable.</color>

#ECHO <color lightgreen>This variable is the delay time from the mud to</color>

#ECHO <color lightgreen>all of you things in your inventory and containter lists.</color>
#CR

#ECHO <color lightblue>salarm</color> <color yellow>-----</color><color red> Set the AlarmTime ~(variable). ex: salarm 3</color>

#SHOW <color lightblue>foodadd</color> <color yellow>-----</color> <color red>Add food to the food list ~(variable).</color>

#ECHO <color lightblue>fooddel</color> <color yellow>-----</color> <color red>Delete food from the food list ~(variable).</color>

#ECHO <color lightblue>conadd</color> <color yellow>-----</color> <color red>Add container to the container list ~(variable).</color>
#ECHO <color lightblue>condel</color> <color yellow>-----</color> <color red>Delete container from the container list ~(variable).</color>

#ECHO <color lightblue>eatshow</color> <color yellow>-----</color> <color red>Shows your list of food, containers and the AlarmTime ~(variables).</color>
#CR]]></value>
    </alias>
    <alias name="fooddel">
      <value><![CDATA[#DELITEM foodtypes %1
#CR
#IF ( @foodtypes ~= NULL ) {
#ECHO <color cyan>Invalid entry</color>
} {
#ECHO <color cyan>You have deleted %1 to your food list.</color>
}]]></value>
    </alias>
    <alias name="foodadd">
      <value>#ADDITEM foodtypes %1
#SORT foodtypes
#ECHO <color cyan>You have added %1 to your food list.</color></value>
    </alias>
    <alias name="salarm">
      <value>#var AlarmTime %1</value>
    </alias>
    <alias name="eatshow">
      <value><![CDATA[#CR
#CR
#ECHO <color yellow><b> *** YOUR LISTS ***</b></color>
#CR
#ECHO <color cornsilk><b>Food List</b></color>
#SHOW <color lightgreen><b>-----------------</b></color>
#LOOP 1,%numitems( @foodtypes) {
  #ECHO <color cyan> %i.</color> <color red>%item( @foodtypes, %i)</color>
}
#CR
#ECHO <color cornsilk><b>Container List</b></color>
#ECHO <color lightgreen><b>-----------------</b></color>
#LOOP 1,%numitems( @containertypes) {
  #ECHO <color cyan> %i.</color> <color red>%item( @containertypes, %i)</color>
}
#CR
#ECHO <color cornsilk><b>Alarm Time</b></color>
#ECHO <color lightgreen><b>-----------------</b></color>
#ECHO <color aqua>Your current alarm time is set to @bRed@AlarmTime@bCyan seconds.</color>
#CR]]></value>
    </alias>
    <alias name="conadd">
      <value>#ADDITEM containertypes %1
#SORT containertypes
#ECHO You have added %1 from your container list.</value>
    </alias>
    <trigger priority="250">
      <pattern>You are {hungry|really hungry.|feeling slightly hungry.|starving}</pattern>
      <value>#NOOP Clear the variables
#VAR havefood {}
#VAR havecontainer {}
#VAR loopcount 0
#VAR containercount 0
#VAR stillhungry 1
#NOOP Run your command to show your inventory
#echo The have container: @havecontainer
inventory</value>
      <trigger>
        <pattern>*</pattern>
        <value>#echo Enter First state
;#CLASS CheckItems 1
#T+ ConTypeTrig
#T+ FoodTypeTrig
#echo Exit First state</value>
      </trigger>
      <trigger type="Alarm">
        <pattern>@AlarmTime</pattern>
        <value><![CDATA[#T- ConTypeTrig
#T- FoodTypeTrig
#CLASS CheckItems 0
#echo In the AlarmType
#IF (%numitems( @havefood)~>0) {
#echo Inside the if
  eat %item( @havefood, 1)
  #AB 1
} {
  #CR
  #SHOW <color cyan>I have no food in my inventory list.</color>
}
#IF (%numitems( @havecontainer)~>0) {
  #VAR stillhungry 1
  #VAR containercount %numitems( @havecontainer)
  checkcontainers
} {
#CR
#SHOW <color cyan>I have no containers need go buy one, duh!</color>
}]]></value>
      </trigger>
    </trigger>
    <var name="loopcount">0</var>
  </class>
  <class name="System">
    <trigger priority="10870">
      <pattern>You fall asleep.</pattern>
      <value>#NOOP Change the pattern to the output line of your mud for the sleep command.
#T- AutoEatTrig</value>
    </trigger>
    <trigger priority="10880">
      <pattern>You open your eyes</pattern>
      <value>#NOOP Change the pattern to the output line of your mud for the wake command.
#T+ AutoEatTrig</value>
    </trigger>
  </class>
  <trigger name="FoodTypeTrig" priority="50" enabled="false">
    <pattern>{(@foodtypes)}</pattern>
    <value>#echo Hit foodtypes
#NOOP Check to see if you have the food listed
#IF %ismember( %1, @foodtypes}) {#VAR havefood %additem( %1, @havefood)}</value>
  </trigger>
  <trigger name="ConTypeTrig" priority="430" enabled="false">
    <pattern>{(@containertypes)}</pattern>
    <value>#echo Hit containertypes1.
;#NOOP Check to see if you have the container listed
#IF (%ismember(%1,@containertypes)) {
#ADDITEM havecontainer %1
}
#echo @havecontainer
;#IF %ismember( %1, @containertypes){
;#echo See: %1
;#ADDITEM  havecontainer %1

;#VAR havecontainer %addItem( %1, @havecontainer)
;}
;#echo You have: @havecontainer</value>
  </trigger>
</module>
</cmud>
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Mon Nov 05, 2007 6:55 pm   
 
I have completed converting this script!!! It is now available in the Shared Package Library.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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