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 Goto page 1, 2  Next
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Thu Jul 23, 2020 10:56 am   

Variables in triggers
 
So...
I have a string list

statmod_types=Strength|Wisdom|Hit points|Mana etc

I have a trigger:-

Stat Mods:%s(*)%s: (%n)%s(*)%s: (%n)

Works fine.

I tried using:-

Stat Mods:%s(@statmod_types)%s: (%n)%s(@statmod_types)%s: (%n)

The documentation suggest that @vars can be used in triggers. I tried a #FORALL (%1) but the trigger failed. The documentation is, once again, not helpful.
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Thu Jul 23, 2020 11:03 am   
 
Also...

On another trigger I tried this:-

%s{(%w)|(%w) (%w)}%s

Am testing for things like

corpse
bloody corpse

where I don't know if there may be one word or two. This didn't work.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Thu Jul 23, 2020 1:24 pm   
 
You need to wrap your variable in curly brackets to use it in a pattern.
You can also use anonymous variables.

%s{@statmod_types}%s: (%n)%s{@statmod_types}%s: (%n)

{corpse|bloody corpse}
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Thu Jul 23, 2020 4:23 pm   
 
Ah. I was doing ({@var}) as I also want to capture the variable.

EG.

#ADDKEY dbvar_location/@statmod_types dbvar

Am trying to populate dbvars for eq items according to type (armor, weapon, etc) and have one var for each type. With a switch it is easy as I just use the literal word...but then my switch is about 16 items long. Using the contents of the trigger variable just means a couple of lines of code.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Thu Jul 23, 2020 6:07 pm   
 
You can use both, but you have to use the curly for sure.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Thu Jul 23, 2020 7:38 pm   
 
So does the trigger automatically loop through all items in the string list if it is used in the trigger pattern?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Thu Jul 23, 2020 8:38 pm   
 
It's more like it becomes x triggers in one.
%1 (or whichever) becomes the literal string that matched in this instance.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Fri Jul 24, 2020 7:15 am   
 
After taking your advice to name temp triggers, several of them stopped misbehaving. However, one temp trigger that does not want to play nice...NOTE! This is NOT CODE, am just wording it simply.

MY 'popitemlist' gets item data from looted mobs:

name, room, zone, mob

basic items that appear from the 'death line' on a kill (You get someitem from the blahblah corpse of the mob of doom.) So I get someitem, mob, room, zone and drop them, into a dbvar. At a later stage (I intend to stick automation into a tick event), I manually run a pre_mid alias (mid = mob id). This alias is the crucial one, it takes the name and IDs an item to get the unique key. As I said, I want to quit the word search after a get a successful result.

pre_mid reads in a 'record' from the popitemlist. Initially I was 'popping' an item off the list, but this (obviously) depletes the list. Thus I have to keep copying a list back in. The reason I started to use a loop is that the documentation states that #BREAK can only be used in a loop and it gives an example. HOWEVER, #FORALL, #WHILE, #UNTIL are not mentioned. So I am not certain that #BREAK actually works outside of LOOP.

Then there is a second loop (currently FORALL) which takes each word and runs ID against it to see if I get a valid result. In every case, the loop runs through EVERY word. NO matter I now use a loop and have a BREAK statement in there.

Secondly, re. TEMP triggers. It seems a TEMP trigger cannot be run from within a function. For example, the above scenario to get an ID match could be better served by using a function:

Eg.,, valid_key=@get_idkey(@local string)

But I cannot get a TEMP trigger to work within a function. I switched get_idkey from a function to an alias and pass a parameter to it. I have to use a perm variable to store the result as it would be not be prudent to recall the parent script with a returning variable.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Fri Jul 24, 2020 11:36 am   
 
#BREAK works in all the loops

Make use of $local vars
$this=@popItemList
Since they die outside of the script it doesn't matter if they get depleted, and you retain the master list.

There is nothing stopping you from defining a #TEMP from within a #FUNC, it works fine locally.
It is unlikely to have any new text printing to screen while the #FUNC is processing for it to be relevant to define it there though.

Everything in CMUD is code to some degree, likely this issue is as well.
Show me the code and I might be able to spot the issue.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Fri Jul 24, 2020 7:16 pm   
 
Items (popitemlist):
rec1={name="pair|of|WTC|padded|leather|boots"|mob=whip master|room=19983|zone=Warrior's Training Camp}
rec2={name="WTC|regulation|belt"|mob=whip master|room=19983|zone=Warrior's Training Camp}
rec3=name="WTC|fatigue|uniform"|mob=whip master|room=19983|zone=Warrior's Training Camp}
rec4=name="WTC|regulation|flowing|cape"|mob=whip master|room=19983|zone=Warrior's Training Camp}
rec5={name="WTC|knout"|mob=whip master|room=19983|zone=Warrior's Training Camp}

pre_mid(alias)
Code:
#LOCAL $local_key
#LOCAL $last_item  // Store last name for testing
#LOCAL $read_item
#LOCAL $local_name
#LOCAL $write_item
#LOCAL $local_id
$local_popitemlist=@popitemlist
$local_popitemlist=@trim_strings($local_popitemlist)


$item_count=%numitems($local_popitemlist)

#LOOP 1,$item_count {
  $local_key=%concat("rec",%i)
  $read_item=%db($local_popitemlist,$local_key)
  $local_name=%db($read_item,name)
 
  get_id $local_name
  $local_id=@EQID/current_item_id
 
  #ADDKEY itemlist $local_id
 
  #ADDKEY $write_item name $read_item.name
  #ADDKEY $write_item room $read_item.room
  #ADDKEY $write_item zone $read_item.zone
  #ADDKEY $write_item mob $read_item.mob
 
  #ADDKEY itemlist.$local_id $write_item
   
}


which calls

get_id
Code:
// Takes a string list and tries to match a 'keyword' that can be used to ID an item.
// Sets a permanent variable with the ID
// $local_string is a dbvar copy of 'popitemlist' passed from 'pre_mid'

#T+ MOBID_Trigs
$local_id=""
$last_id_found=""
$last_word_found=""

$word_count=%numitems($local_string)

#WHILE %numitems($local_string) {
  $temp_word=%pop($local_string) // Take a word from the string list
 
  // Test if the current word has been used before
  #IF (%match($temp_word,$last_word_found)) {#CONTINUE}
 
  identify $temp_word
 
  // Match the last ID found with the current one - words might be different for same ID
  #IF (%match($last_id_found,@EQID/current_item_id)) {#CONTINUE}
 
  // If the item is not a container, put it in a bag. Should prevent re_ID of same item
  #IF (%match(@EQID/current_item_type,"Container")) {#NOOP;#CONTINUE} {p3 @EQID/current_item_id}
 
  #WAIT 2000
 
  // Store the last word used to test against new word
  $last_word_found=$temp_word
 
  // If no word was valid for use
  #IF (@Mob_EQID/test_failed=0) {#CONTINUE}

  // If a match was found, store the last ID used, write a message and exit.
  #IF (@EQID/name_match=1) {$last_id_found=@EQID/current_item_id;#T- MOBID_Trigs;#WIND ID_Equip "Found :"@EQID/current_item_id;#EXIT}
 
  $last_id_found=@EQID/current_item_id
}
#T- MOBID_Trigs


and function trim_strings is supposed to strip duplicate words from the collection of names. Am getting illegal character in expression and I cannot see why. It looks fine to me.

trim_strings - takes $localdb as a parameter
Code:
$local_String=""
$record_count=%numitems($localdb)
$word_count=0
$last_string=$localdb.rec1.name
$local_key=""

#LOOP 2, $record_count {
  $local_key=%concat("rec",%i)
  $local_String=$localdb.$local_key.name

  #FORALL $last_string {
    #IF (%ismember(%i, $local_String)) {#DELITEM $local_String %i}
  }
}

#SH $localdb
#RETURN $localdb


MOBID_Trigs is a small group of triggers.

Code:
<class name="MOBID_Trigs" enabled="false" id="19013">
  <onenable>#TIMER 0
EQID/current_item_type=""
Mob_EQID/test_failed=0
EQID/current_item_id=0
EQID/name_match=0</onenable>
  <ondisable>#TIMER 1</ondisable>
  <trigger priority="196750" id="19675">
    <pattern>^~| Id%s: (%d)</pattern>
    <value>EQID/current_item_id=%1
EQID/name_match=1</value>
  </trigger>
  <trigger priority="230090" id="23009">
    <pattern>You do not have that item</pattern>
    <value>Mob_EQID/test_failed=1</value>
  </trigger>
  <trigger priority="230110" id="23011">
    <pattern>What do you want to identify</pattern>
    <value>Mob_EQID/test_failed=1</value>
  </trigger>
  <trigger name="is_bag" priority="230210" id="23021">
    <pattern>~| Type%s: Container</pattern>
    <value>EQID/current_item_type="Container"</value>
  </trigger>
</class>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Fri Jul 24, 2020 7:52 pm   
 
In the first code block:

#ADDKEY itemlist $local_id

Has no value, just the key.

#ADDKEY itemlist.$local_id $write_item
Should be?
#ADDKEY itemlist $local_id $write_item

Code:
#ADDKEY $write_item name $read_item.name
#ADDKEY $write_item room $read_item.room
#ADDKEY $write_item zone $read_item.zone
#ADDKEY $write_item mob $read_item.mob

seems like
$write_item=$read_item
would save time

Code block 2 (and elsewhere):
You should not need to set your $localVars to a null value like that, this is a separate setting and should not be able to see the $localvars in other settings.

Code block 3 (trim_strings):
$local_String=$localdb.$local_key.name
Is causing your illegal token, dot notation is weird when using $localVars, %db is almost always preferred
That said, you can force it to work like so:
$local_String=$localdb.${local_key}.name
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sat Jul 25, 2020 9:09 pm   
 
I am beginning to think I have been staring at this too long. I decided to go back to the beginning and make it all more modular.

This is the very first part...and I am buggered if I can see the problem. It fires but not compile.

Code:
<trigger priority="178660" id="17866">
  <pattern>You {get a |get an |get the |get some |get }(*) from {the *|the} corpse {of a|of an|of the|of} (*).</pattern>
  <value>#LOCAL $object
#LOCAL $local_name


#IF (%match(%1,"gold coin")) {} {
  #T+ MOBID_Trigs
  $local_name=@trim_string(%1)


  #FORALL $local_name {
    ID %i
//    #TEMP get_id_key {~| Id%s: (%d)} {Mob_EQID/current_item_id=%1;#EXIT}
    #ADDKEY $object name $local_name
  }
  #ADDKEY $object mob %2
  #ADDKEY $object room %roomkey()
  #ADDKEY $object zone %zonename()
 
  #ADDKEY Mob_EQID/looted_keys @Mob_EQID/current_item_id $object</value>
</trigger>


I have been having frikkin problems with ANYTHING that tries to do the simplest of things with a string list.
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Sun Jul 26, 2020 1:28 am   
 
At first glance It looks like you have an extra space between sections. I would remove the space after the first list and put it before the wildcard (like how you have it at the end).
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sun Jul 26, 2020 8:19 am   
 
If you are referring to the trigger pattern, that is not where the problem is. Almost EVERYWHERE I have tried, the problem lies with the use of %i. It seems to work for some things but not others. WHich makes almost all uses of FORALL pointless.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Mon Jul 27, 2020 5:45 pm   
 
If you are looking at the trigger in the settings editor, there is a syntax checker under the Editor menu, also ctrl+k
That will tell you precisely where CMUD thinks the first error in your code is.

Also, if you have a loop inside of another loop, the nested loop uses %j instead of %i, and then it goes on to %k if there is a third nested loop, and so on.

#ADDKEY Mob_EQID/looted_keys @Mob_EQID/current_item_id $object

This seems unnecessarily precise
Do you have so many variables with the same name that you have to specify the folder/class it is in?

If not, this should do the same thing:

#ADDKEY looted_keys @current_item_id $object

Regarding %i, have you checked to be sure that the current value thereof is not what is messing your code up?
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Mon Jul 27, 2020 6:42 pm   
 
Re. classes, I am trying to prevent errant occurrences of the same variable being created at a different level by whatever script may be running. By specifying the class, the variable should not get created outside that class.

I was not aware of the %i, %j, etc thing. Most helpful to know.

Here's a question:

If I have a trigger pattern

<somepattern>(%w)<rest of pattern>

and I am working on %1, if I have a temp trigger defined within the script, would it have access to the calling %1, or even, would a temp trigger have access to any local vars created at the script root level?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Mon Jul 27, 2020 9:09 pm   
 
No, #TEMP triggers only have access to @savedVariables, or those from their own pattern.
#LOCAL variables live and die in the setting they are created in.

Save things to a permanent variable if you want to use them in other settings.

You could use a #WAITFOR instead of a #TEMP if you want to still have access to local things.


Back to the class/variable issue:
So long as the trigger can see a variable with the name provided, CMUD will use that variable.

Duplicates only get made when you force it, by including the class name, or if the class containing said variable, or any of the parent classes, get disabled.
Issues usually only crop up AFTER you have duplicated variables and arent supplying the class as well.
It's classic scoping.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Tue Jul 28, 2020 6:43 am   
 
I appreciate your assistance. I have been having issues with triggers for some time and, logically, I suppose the problem is mine but I just cannot see where I am going wrong. The documentation is weak and appears to be of no help.

The class/var issue is a chore.

I have a class tree such as:

Equipment
- get_eq_data (all data capture triggers)
MOB - collecting basic items info from mobs for later identifying
SHOP - id all regular store items
INV - identify any other inventory items.

From the documentation:

********************************************************

What if you wanted to end the previous trigger before the 5 lines were up? For example, what if you wanted to collect the inventory until a blank line was received? Well, you can use the #STATE command to set the current state of any trigger. Setting a trigger state back to zero resets the trigger. So, you could do the following:

#TRIGGER "InvTrig" {Inventory} {#VAR Inv "";#TEMP {^$} {#STATE InvTrig 0}}
#COND {} {#ADDITEM Inv %line} {LoopLines|Param=99}

********************************************************
So, of course I expect this to be exactly what I am after...only it isn't.

My prime example is this:

Code:
+-----------------------------------------------------------------+
| Keywords   : armor aardwolf breastplate aardwolfarmor (409575)  |
| Name       : Aardwolf Breastplate of Magic Resistance           |
| Id         : 2219213937                                         |
| Type       : Armor                     Level  :   191           |
| Worth      : 2,000                     Weight :    10           |
| Wearable   : torso                                              |
| Score      : 514                                                |
| Flags      : unique, glow, hum, magic, held, burn-proof, V3,    |
|            : precious                                           |
| Owned By   : Dhalsim                                            |
| Found at   : Immortal Homes                                     |
+-----------------------------------------------------------------+
| Stat Mods  : Luck         : +2       Constitution : +2          |
|              Wisdom       : +2       Dexterity    : +2          |
|              Strength     : +2       Intelligence : +2          |
|              Hit points   : +125     Mana         : +125        |
|              Moves        : +125     Damage roll  : +38         |
|              Hit roll     : +38                                 |
+-----------------------------------------------------------------+
| Resist Mods: Acid         : +100     Air          : +100        |
|              Cold         : +100     Earth        : +100        |
|              Energy       : +100     Fire         : +100        |
|              Holy         : +100     Light        : +100        |
|              Electric     : +100     Mental       : +100        |
|              Negative     : +100     Sonic        : +100        |
|              Shadow       : +100     Water        : +100        |
|              Magic        : +100     All physical : +48         |
+-----------------------------------------------------------------+


It has the elements I am trying to capture for all items: several 'sections' split up by a definite pattern, multiple lines within each keyword part of the section, and multiple data types.

Originally I had a trigger for every word within the 'stat' and 'resists' portions. The data is important as it will be used for scripting to evaluate items against other items so I would prefer to not just grab each line as text and join them all together, either as a string list or some other way.

I have a trigger that runs:

Code:
<trigger name="statmods_trig" priority="232840" id="23284">
  <pattern>~| Stat Mods%s:%s(*): (%n)%s(*): (%n)%s~|</pattern>
  <value>#WIND Equip_ID %trim(%1) %2 %trim(%3) %4

#TEMP endHR {~| %s(%w): (%n)%s~|} {#WIND Equip_ID %1 %2;#STATE statmods_trig 0}
#TEMP endstatmods {+----} {#WIND Equip_ID "----" ;#STATE statmods_trig 0}</value>
  <trigger type="Loop Pattern" param="5">
    <pattern>~|%s(*)%s: (%n)%s(*)%s: (%n)%s~|</pattern>
    <value>#WIND Equip_ID %trim(%1) %2 %trim(%3) %4

#STATE 0</value>
  </trigger>
</trigger>


I decided, for testing purposes, to send the output to a window instead of variables. If I can see the data I need in the window, it will be right for changing the code to variables. I should have thought of it before.

Anyway, the trigger for resists is, in effect, the same one. I ID an item and I get data to the window.

Code:
Keywords : armor aardwolf breastplate aardwolfarmor (409575) 
Name : Aardwolf Breastplate of Magic Resistance           
ID : 2219213937
Type : Armor         Level : 191
Worth : 2000         Wgt : 10
Wearable : torso
Score : 514
Found : Immortal Homes                                     
Flags :  unique|glow|hum|magic|held|burn-proof|V3|precious
Luck +2 Constitution +2
Wisdom +2 Dexterity +2
----
Acid +100 Air +100
Cold +100 Earth +100
----


This is not the original. In the beginning I had it similarly to the documentation: main trigger and conditional. If you look at the 'stat mods' part of the item you can see that the last key and value is only one item on the line whereas the rest are two items per line. As each item will have different stats it is likely that other items I encounter may have a line with only one data item on it. I was scouring the documentation and forums for some way to have a COND trigger that would mimic:

~|%s(*)%s: (%n)%s(*)%s: (%n)%s~|

OR

~|%s(*)%s: (%n)%s~|

to cope with both scenarios. I tried

~|%s(*)%s: (%n)%s{~||(*)%s: (%n)%s~|}

but that didn't seem to work.

The first temporary trigger is firing but the second is not and the statmods and resists output is only two lines:one for the main trigger and one for the first temp trigger.

Now, from reading the documentation, I understand that, in my case, the initial

~| Stat Mods%s:%s(*): (%n)%s(*): (%n)%s~|

portion (the main trigger) will be state 0, the condition will be state 1. So my understanding is that, in order to get all the data, I need another temporary trigger to read the single item line. Not working and neither is the COND trigger not looping. I assumed from reading that if I just reset the trigger state to 1 it will attempt to match the same pattern (thus giving me the data I need) but it seems not to be so.

I tried changing the the WITHIN clause to a LOOP clause and making this number 8 - should account for all resistances - but no. Imaginemy surprise when I see only 4 lines, and then I change it to 10 and I see 5 lines. BY this logic, if I set the loop to 16 I should get all lines.

Before this, I had each item (stat mods and resist mods) in its own class and when the 'Stat/Resist Mods :' text appeared it would #T+ the class, and within each class would be a permanent trigger for '+-----' to end that section. For the most part it was working fine, and for a single item on its own, a trigger pattern for a single item. All well and good, except that there were issues with delay in that I would have to trigger TWICE for 'stat mods' or 'resist mods'.

I tried reparsing the line by having the initial trigger as just

~|%sStat Mods

and the trigger pattern would have the vital capturing pattern but there were other issues that cropped up. Probably down to lag or some other timing issue...and a lot of cases, an infinite loop with re-parsing.


It is making my head spin!
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Tue Jul 28, 2020 8:24 am   
 
Aha! I saw your other post re. trigger states and that made far more sense than the documentation.

So I altered my script, swapped the loop for a within and set the state. Almost all is working.

The single data item pattern is still not firing.
Code:
<trigger name="statmods_trig" priority="232840" id="23284">
  <pattern>~| Stat Mods%s:%s(*): (%n)%s(*): (%n)%s~|</pattern>
  <value>#WIND Equip_ID "----"
#WIND Equip_ID %trim(%1) %2 %trim(%3) %4

#TEMP endHR {~| %s(%w): (%n)%s~|} {#WIND Equip_ID %1 %2;#STATE statmods_trig 0}
#TEMP endstatmods {+----} {#STATE statmods_trig 0}</value>
  <trigger type="Within Lines" param="1">
    <pattern>~|%s(*)%s: (%n)%s(*)%s: (%n)%s~|</pattern>
    <value>#WIND Equip_ID %trim(%1) %2 %trim(%3) %4

#STATE statmods_trig 1</value>
  </trigger>
</trigger>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Tue Jul 28, 2020 12:01 pm   
 
Try viewing the trigger in the settings editor, only switch over to the Pattern tab, along the bottom.
Put the literal line from the mud you are trying to match on the Test line, and see if your pattern does in fact match.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Wed Jul 29, 2020 6:46 am   
 
It has nothing to do with the pattern and everything to do with trying to figure out which line may only have one stat on it and thus where to put the pattern.

Resistmods may have 1-22 items, and statmods may have 1-11 items. Therefore I need an either/or pattern which gathers data from either two items on a line or one item, OR I need a way to have another COND trigger which will fire within reach of the main trigger but not to the point it steps into another trigger pattern. The problem with 'within' in this case is that, if the number is too low it may not be within reach of the main trigger, and if it is too hih it is probably going to encroach on another pattern

Initially, I had these two in their own class and within was a solo trigger to match a one-item line. If there is no other solution I may go back to that...but even that was iffy as the class needs to be open only at a certain point. The logical openings were when 'Resist mods' or 'Stat mods' text appears but then there is always a two-item pattern on that line and it means attempting a re-parse...which was where I was getting infinite loops.

Code:
<trigger name="statmods_trig" priority="232840" id="23284">
  <pattern>~| Stat Mods%s:%s(*): (%n)%s(*): (%n)%s~|</pattern>
  <value>#WIND Equip_ID " "
#WIND Equip_ID "---- Stat Mods"
#WIND Equip_ID %trim(%1) %2 %trim(%3) %4
temp_statmods=""

#TEMP endstatmods {+----} {#ADDKEY EQ/item_record statmods @temp_statmods;#STATE statmods_trig 0}

#SWITCH (%trim(%1))
  ("Constitution") {#ADDKEY temp_statmods "CON" %2}
  ("Damage roll") {#ADDKEY temp_statmods "DR" %2}
  ("Dexterity") {#ADDKEY temp_statmods "DEX" %2}
  ("Hit points") {#ADDKEY temp_statmods "HP" %2}
  ("Hit roll") {#ADDKEY temp_statmods "HR" %2}
  ("Intelligence") {#ADDKEY temp_statmods "INT" %2}
  ("Luck") {#ADDKEY temp_statmods "LUCK" %2}
  ("Mana") {#ADDKEY temp_statmods "MN" %2}
  ("Moves") {#ADDKEY temp_statmods "MV" %2}
  ("Strength") {#ADDKEY temp_statmods "STR" %2}
  ("Wisdom") {#ADDKEY temp_statmods "WIS" %2}
 
#SWITCH (%trim(%3))
  ("Constitution") {#ADDKEY temp_statmods "CON" %4}
  ("Damage roll") {#ADDKEY temp_statmods "DR" %4}
  ("Dexterity") {#ADDKEY temp_statmods "DEX" %4}
  ("Hit points") {#ADDKEY temp_statmods "HP" %4}
  ("Hit roll") {#ADDKEY temp_statmods "HR" %4}
  ("Intelligence") {#ADDKEY temp_statmods "INT" %4}
  ("Luck") {#ADDKEY temp_statmods "LUCK" %4}
  ("Mana") {#ADDKEY temp_statmods "MN" %4}
  ("Moves") {#ADDKEY temp_statmods "MV" %4}
  ("Strength") {#ADDKEY temp_statmods "STR" %4}
  ("Wisdom") {#ADDKEY temp_statmods "WIS" %4}

</value>
  <trigger type="Within Lines" param="1">
    <pattern>~|%s(*)%s: (%n)%s(*)%s: (%n)%s~|</pattern>
    <value>#WIND Equip_ID %trim(%1) %2 %trim(%3) %4

#SWITCH (%trim(%1))
  ("Constitution") {#ADDKEY temp_statmods "CON" %2}
  ("Damage roll") {#ADDKEY temp_statmods "DR" %2}
  ("Dexterity") {#ADDKEY temp_statmods "DEX" %2}
  ("Hit points") {#ADDKEY temp_statmods "HP" %2}
  ("Hit roll") {#ADDKEY temp_statmods "HR" %2}
  ("Intelligence") {#ADDKEY temp_statmods "INT" %2}
  ("Luck") {#ADDKEY temp_statmods "LUCK" %2}
  ("Mana") {#ADDKEY temp_statmods "MN" %2}
  ("Moves") {#ADDKEY temp_statmods "MV" %2}
  ("Strength") {#ADDKEY temp_statmods "STR" %2}
  ("Wisdom") {#ADDKEY temp_statmods "WIS" %2}
 
#SWITCH (%trim(%3))
  ("Constitution") {#ADDKEY temp_statmods "CON" %4}
  ("Damage roll") {#ADDKEY temp_statmods "DR" %4}
  ("Dexterity") {#ADDKEY temp_statmods "DEX" %4}
  ("Hit points") {#ADDKEY temp_statmods "HP" %4}
  ("Hit roll") {#ADDKEY temp_statmods "HR" %4}
  ("Intelligence") {#ADDKEY temp_statmods "INT" %4}
  ("Luck") {#ADDKEY temp_statmods "LUCK" %4}
  ("Mana") {#ADDKEY temp_statmods "MN" %4}
  ("Moves") {#ADDKEY temp_statmods "MV" %4}
  ("Strength") {#ADDKEY temp_statmods "STR" %4}
  ("Wisdom") {#ADDKEY temp_statmods "WIS" %4}

#STATE statmods_trig 1</value>
  </trigger>
  <trigger type="Within Lines" param="6">
    <pattern>~|%s(*): (%n)%s~|</pattern>
    <value>#WIND Equip_ID %trim(%1) %2

#SWITCH (%trim(%1))
  ("Constitution") {#ADDKEY temp_statmods "CON" %2}
  ("Damage roll") {#ADDKEY temp_statmods "DR" %2}
  ("Dexterity") {#ADDKEY temp_statmods "DEX" %2}
  ("Hit points") {#ADDKEY temp_statmods "HP" %2}
  ("Hit roll") {#ADDKEY temp_statmods "HR" %2}
  ("Intelligence") {#ADDKEY temp_statmods "INT" %2}
  ("Luck") {#ADDKEY temp_statmods "LUCK" %2}
  ("Mana") {#ADDKEY temp_statmods "MN" %2}
  ("Moves") {#ADDKEY temp_statmods "MV" %2}
  ("Strength") {#ADDKEY temp_statmods "STR" %2}
  ("Wisdom") {#ADDKEY temp_statmods "WIS" %2}
  </value>
  </trigger>
</trigger>


This does not work. I get the two-part lines but not the single item.

So...if my initial text pattern is (eg):

| Stat mods : Dexterity : +2 Hit points : +40 |

If I have the meaty triggers in a class that gets enabled when '~|%sStat mods' appears, I will have to re-parse the same line but there is now no guarantee that any lag will cause the trigger to skip...and that was what I was getting before at some stages: the two items AFTER the initial 'Stat mods' pattern were getting missed. It would be handy to be able to to slow the mud output down to give triggers more time to fire.
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Wed Jul 29, 2020 8:06 am   
 
In fact, reparse seems to loop infinitely at every opportunity.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Wed Jul 29, 2020 2:40 pm   
 
If you have multiple patterns and you cannot be sure of the order they will occur, then you do NOT want a state-based trigger.
You want a group of individual triggers that are all in the same class, so you can enable/disable the class as needed.

Your "endStatMods" trigger seems like a good choice for turning it back off.


Rather than reparse, there is a checkbox in the trigger for 'repeat within line' that should do what you expect.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sat Aug 01, 2020 8:49 am   
 
I managed (with some thought) to get it sorted by reverting to classes and having triggers for both 1-item and 2-item lines. Seeing as it is almost all contained within one root class, I figured "what an ideal opportunity to make it a package". So I moved it all into a package. Imagine my surprise (yet again) when aliases I have for getting things out of containers and putting things into containers (g1,p1, g2 ,p3, etc) are no longer functional. The aliases still exist and if one types #ALIAS the entire list is revealed and lo! they are still there...but no longer working...from anywhere!


So packages are not as useful as the documentation states. Add to that, when I moved things into the package, some aliases actually disappeared! Now I have to try and recreate them.

UPDATE: It is some bug in the software. Like other issues, a restart cures the invisible alias thing...in fact it seems to be most things, not just aliases. Room scripts fail to fire and speed(safe) walks are failing, with movement of only 2 or 3 rooms before giving up.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Sat Aug 01, 2020 3:29 pm   
 
Packages are funny, you need to add them to your session.

Click on the sessions button.
Edit your session.
Move to the Packages tab.
If your package is not on the list already, click the green plus button to add it.
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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