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
Llohr
Apprentice


Joined: 17 May 2005
Posts: 108

PostPosted: Sat Mar 03, 2012 7:23 am   

Variables being created/modified in separate packages + disappearing scripts
 
So I have a couple of problems I was hoping someone could help me sort out.
The first, as is likely unclear by the subject line, involves running very similar scripts on two characters (packages) simultaneously, and running into problems with the alias/trigger in one packages modifying the variables of the other package.

I set up a simple script to recast failed spells, with an alias, "ca," which initially had the value of "cast %-1;#var lastspell {%-1} {} {recast}." This worked well for quite some time, as I generally run one spellcaster and one melee class at any given time. Then I decided to run two casters at once, and found that one character's "lastspell" value would always override the other's. So, while one character cast, say, "fireball," and the other cast "lightning bolt," both of them would have "lightning bolt" as the value of "lastspell."

I tried what I figured would be the simplest solution--that of modifying the script to append the individual characters' names to the variable and all instances where the variable was called, and, as further assurance, I placed those variables in a new folder also named with the character's name. Thus, the value of alias "CA" became: "cast %-1; #var lastspellbob} {%-1} {} {recastbob}."

That sorted, I made sure it worked individually, and then tested with two casters grouped together. I had exactly the same problem. Now, @lastspellbob and @lastspellbill both contained Bob's last spell, despite Bob's alias only setting @lastspellbob and only in class recastbob. Bill's variable, lastspellbill, in class recastbill, would somehow have picked up Bob's spell.

I considered using local variables, but from the help file it seems those are a one-shot deal, and there are occasions in which I might need to call the same value multiple times.

Additionally, I wondered if anyone could tell me why my triggers, aliases, and even single lines within script blocks occasionally disappear. This seems to be a new trend, which especially affects newly created triggers/etc., but has occasionally occurred with long-standing bits of code.

If you made it this far, thanks for reading!

-Llohr
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Mar 03, 2012 3:27 pm   
 
Its funny... I logged into the forum to post the exact same issue.

I run an automatic practice script on a MUD that allows 3 characters online at once. If I have more than one session opened I get the issue described by the OP in which the sessions use the variables from each others' packages. This really messes things up since I may have each character practicing different things. I've made sure the package includes for each of the 3 character session packages is not including the other 2 character packages. Yet this still happens. CMUD 3.34. This only seems to happen for me when using #THREAD however, not all the time... so it may be a different issue despite sounding exactly the same.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun Mar 04, 2012 12:40 am   
 
Lines disappearing mysteriously in your scripts sounds like corruption of your package. This can also lead to many other mysterious problems. Try the export/import trick.

It is possible that problems with variables could be caused by the same thing, so fix that first. It does not sound like Ralgith has that problem, however. Can you explain how your session is set up? Does each session have a separate session package? Are the variables for each session in that session's package? Are the the triggers using those variables duplicated in each session, or are they in a separate shared package? Have you double checked that there aren't accidentally duplicated variables somewhere that all the sessions can see?

I suppose it is concievable that a thread might lose track of which session it is supposed to work with, but we will need more detail to track this down.
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Mar 04, 2012 2:16 am   
 
Each character has its own unique session. The script is an exact duplicate between sessions except the contents of the variables controlling which spells & skills they're practicing & the ones that track their mana.

Here is the script XML for one character.
Code:

<class name="Automatic Practice" id="436">
  <alias name="pracon" id="437">
    <value>#t+ pscan
#CLASS {Automatic Practice}
#VAR PracStatus "On"
#CLASS 0</value>
  </alias>
  <alias name="pracoff" id="438">
    <value>#t- pscan
#CLASS {Automatic Practice}
#VAR PracStatus "Off"
#CLASS 0</value>
  </alias>
  <alias name="addprac" id="439">
    <value>#IF (%1 = "" | %2 = "") {
  #EXEC prachelp
  #ABORT 1
  }
#CLASS {Automatic Practice}
#IF (%ismember( %1, @PracListSpell)) {
  #ECHO This spell is already part of the practice list. Updating the matching spell percentage with percentage listed now and also updating the target.
  #VAR PracListMax  %replaceitem( %2, %ismember( %1, @PracListSpell), @PracListMax)
  #IF (%3) {#VAR PracListTarget  %replaceitem( %3, %ismember( %1, @PracListSpell), @PracListTarget)}
  } {
  #VAR PracListSpell  %additem( %1, @PracListSpell)
  #VAR PracListMax  %additem( %2, @PracListMax)
  #IF (%3) {#VAR PracListTarget  %additem( %3, @PracListTarget)} {#VAR PracListTarget  %additem( "Blank", @PracListTarget)}
  }
#CLASS 0</value>
  </alias>
  <alias name="nextprac" id="440">
    <value>spell =  %pop( PracListSpell)
max =  %pop( PracListMax)
#IF (%item( @PracListTarget, 1) = "Blank") {
  targ = ""
  #DELNITEM PracListTarget 1
  } {targ =  %pop( PracListTarget)}</value>
  </alias>
  <alias name="prachelp" id="441">
    <value>#ECHO %cr
#ECHO {Erian's Automatic Practice Script}
#ECHO {Version: @APvers}
#ECHO {----------------------------------------------------------------------------------------------------}
#ECHO {Please Use This Format: addprac ~ ~ ~[SpellTarget~]}
#ECHO {SpellTarget is only required for combat spells and locate object, identify, or remove curse (use item in inventory).}
#ECHO {Please remember to add prereqs in proper order, BEFORE the higher spells in the chain.}
#ECHO {NOTE: You must encapsulate multi-word spell names in quotes. Example: addprac ~"word of recall~" 90}
#ECHO {Requirements: MudReader Plugin}
#ECHO {Designed for Eternal Darkness MUD ( ed.wolfpaw.net )}
#ECHO {Requirement Exception: You may skip using MudReader Plugin if you manually edit all of the ~#SPEAK into ~#ECHO}
%cr</value>
  </alias>
  <var name="maxma" id="442">4049</var>
  <var name="spell" id="443">wind wall</var>
  <var name="targ" type="Literal" id="444"/>
  <var name="max" id="445">90</var>
  <var name="APvers" type="String" id="446">3.0.1 Beta</var>
  <var name="PracName" type="String" id="448">%char</var>
  <var name="PracMana" id="452">4160</var>
  <var name="PracPrompt" type="Literal" id="453">Yes</var>
  <var name="FleeAct" type="String" id="454">flee</var>
  <trigger priority="4990" newline="false" prompt="true" id="455">
    <pattern>%dhp (%d)m %dmv></pattern>
    <value>#CLASS {Automatic Practice}
#VAR PracMana %1
#VAR PracPrompt "Yes"
#CLASS 0</value>
  </trigger>
  <class name="Run Prac" id="456">
    <alias name="PerformPrac" id="457">
      <value>#THREAD "autoprac_jenia" {
  #T- pscan
  #IF (%ismember( @spell, @NonDummyList)) {north} {west}
  #WHILE (%int( %eval( @PracMana * 100 /  @maxma)) > 15 &amp;&amp; @PracStatus = "On") {
    #CLASS {Automatic Practice}
    #VAR PracPrompt "No"
    #CLASS 0
    c '@spell'  @targ
    #WHILE (@PracPrompt = "No") {
      #IF (@PracNoFight) {
        #5  @FleeAct east
        #CLASS {Automatic Practice}
        #VAR PracNoFight {}
        #CLASS 0
        #BREAK
        }
      #IF (@PracNoMana) {
        #IF (%ismember( @spell, @NonDummyList)) {south} {#IF (@targ = "dummy") {#5  @FleeAct east} {east}}
        #CLASS {Automatic Practice}
        #VAR PracNoMana {}
        #CLASS 0
        #BREAK
        }
      #WAIT 2000
      }
    }
  #IF (%ismember( @spell, @NonDummyList)) {south} {#IF (@targ = "dummy") {#5  @FleeAct east} {east}}
  prac  @spell
  #T+ pscan
  }</value>
    </alias>
    <trigger name="blah" priority="5020" id="458">
      <pattern>^@spell%s(%d)$</pattern>
      <value>#IF (%1 =  @max) {
  #ECHO {@PracName has completed practice on @spell}
  #IF (@PracListSpell) {
    #ECHO {@PracName moving on to next spell, %item( @PracListSpell, 1)}
    nextprac
    } {
    #ECHO {@PracName has completed all current practice requirements.}
    pracoff
    }
  } {#ECHO {@PracName @spell at %1 percent.}}</value>
    </trigger>
    <trigger priority="5030" id="459">
      <pattern>Impossible!  You can't concentrate enough!</pattern>
      <value>#CLASS {Automatic Practice}
#VAR PracNoFight 1
#CLASS 0</value>
    </trigger>
    <trigger priority="5040" id="460">
      <pattern>You haven't the energy to cast that spell!</pattern>
      <value>#CLASS {Automatic Practice}
#VAR PracNoMana 1
#CLASS 0</value>
    </trigger>
    <class name="pscan" initdisable="true" enabled="false" id="461">
      <trigger priority="5060" newline="false" prompt="true" id="462">
        <pattern>(%d)hp (%d)m (%d)mv></pattern>
        <value>#IF (%2 ==  @maxma) {PerformPrac}</value>
      </trigger>
    </class>
  </class>
  <var name="PracStatus" type="Literal" id="463">On</var>
  <var name="PracNoMana" type="String" id="464"/>
  <var name="PracNoFight" type="String" id="753"/>
  <var name="PracListMax" type="StringList" id="754">
    <value>90</value>
    <json>[90]</json>
  </var>
  <var name="PracListSpell" type="StringList" id="755">
    <value>summon demon</value>
    <json>["summon demon"]</json>
  </var>
  <var name="PracListTarget" type="StringList" id="756">
    <value>Blank</value>
    <json>["Blank"]</json>
  </var>
  <var name="NonDummyList" type="StringList" id="757">
    <value>darkness|plant growth|animate dead|create golem|summon water elemental|summon fire elemental|summon air elemental|summon earth elemental|summon demon</value>
    <json>["darkness","plant growth","animate dead","create golem","summon water elemental","summon fire elemental","summon air elemental","summon earth elemental","summon demon"]</json>
  </var>
</class>


It is of course possible that I have some unforeseen bug in here... but I think it unlikely since if I only have a single character session open, it works flawlessly.

EDIT: The help alias stated MudReader is a requirement... because I never updated the help when I updated the script for CMUD.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Mar 04, 2012 2:30 am   
 
I would like to state that I did work around this bug by editing the RunPrac alias to use the full variable paths just now as a test, however that should not be needed and really annoys me.

By full variable paths I mean:
@//Jenia/Automatic_Practice/VarName

Very annoying! >_<
But at least it lets me run the script while another character does something else.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Mar 04, 2012 5:43 pm   
 
Then again... maybe not. I just had another time it went haywire. So, I guess that wasn't a valid work-around after all. Just didn't do it when I had another character on that didn't have the script is all.

So... any other ideas? >_<
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
shalimar
GURU


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

PostPosted: Sun Mar 04, 2012 7:10 pm   
 
You have seperate sessions with duplicate variables..
Make a seperate package that both will use just for setting the various variables
_________________
Discord: Shalimarwildcat
Reply with quote
Llohr
Apprentice


Joined: 17 May 2005
Posts: 108

PostPosted: Mon Mar 05, 2012 3:45 am   
 
Okay, as far as I can tell, the only bit directed at me was a suggestion that I use the export/import trick. Beyond the obvious, what steps are involved in this trick? Should I reinstall CMud? Create a new session? Just delete all of my settings after exporting and prior to importing?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Mar 05, 2012 5:04 am   
 
Easiest way is to export, remove the tab you just exported, find and delete the .pkg file that tab was associated with, then create a new package and import what you just exported. Since you cannot be sure exactly which package is broken, it's best to do them all.

For particularly large or complex packages, I've found it useful to only import small, manageable sections that I can then look at and make sure stuff was imported correctly before moving on to the next bit (since this will no doubt break some of your scripts while you're in the middle of reviewing them, you may wish to disable them).
_________________
EDIT: I didn't like my old signature
Reply with quote
Llohr
Apprentice


Joined: 17 May 2005
Posts: 108

PostPosted: Tue Mar 13, 2012 8:02 am   
 
So, I exported the package, then, due to some concern about breaking things, chose to simply create a new session rather than deleting the existing one, and imported the xml file into the new session.

I got what appears to be all of my triggers back. No variables, no aliases, no classes, just all of my triggers sitting in the root folder. Did I miss something?
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