About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
golgepapaz
Beginner


Joined: 09 Sep 2010
Posts: 13

PostPosted: Thu Sep 09, 2010 4:37 pm   

resetting a trigger (newbie question)
 
hello all,

I am trying to write an identify trigger that will add an item to database,thing is
identify text format maybe different with respect to type of the item identified
so i wound up for writing different triggers for different types of equipment (armor vs weapon)

For example for a weapon;
Code:

     A warm wave of magic flows through your hands as you perceive that.. (common for both types)
.. this object, a long golden dagger, is a dagger, (common)
   and can be referred to as 'long dagger gold'. (common)
It deals 5d6 damage (averaging at 17). (shows if it's a weapon,otherwise not)
Its attacks take the form of a pierce.
When worn, it (common for both types although optional , last part of the identify string)
   modifies mana by 10
   modifies health by 15
   modifies hit roll by 3

in the above example, when i identify an equipment and it's not a weapon
my wepon trigger's state is stuck at the weapon damage line indefinitely, because that line isnt received from the mud.
how do i reset my trigger to it's initial state automatically(when that damage line is not received), so i can use it next time
when i identify a weapon?

Also that modifier lines may happen 0 or more times, and how can i store them in a dictionary or something like that
then reset my trigger to initial state (They are the last lines from an identify, you may assume there is at least one of them).

Any pointers would be greatly appreciated..
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Sep 09, 2010 7:05 pm   
 
A better solution for this situation than a multistate trigger would be to break this up into separate triggers. Create one trigger that detects when you start identifying, which enables a class (call it Identify). Within that Identify class, you then create individual triggers for each possible line you want to grab from the identification, which stores the important values in variables. If you have a line that can occur multiple times, have that trigger use #additem, so that you create a stringlist rather than a simple variable. In addition, create another trigger within the Identify class which detects when the identification is ended (by detecting some specific closing text, or detecting a new prompt). This final trigger should collect all the the data from the variables, insert the data into the database, reset the variables to nulls, and disable the Identify class.

Be sure to set the Identify class to disabled initially. Also, you can set the variables to have defaults of nulls, so that you never restart a session with old data in them.
Reply with quote
golgepapaz
Beginner


Joined: 09 Sep 2010
Posts: 13

PostPosted: Thu Sep 09, 2010 7:18 pm   
 
ok ,this looks like that can solve the substate deadlock problem, I'll get to it, the database part,I'll handle it trial and error approach
since i am new to cmud scripting , thanks anyway
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