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


Joined: 09 Apr 2008
Posts: 167

PostPosted: Mon May 18, 2020 12:16 am   

Converting to using Variable Database and keep getting duplicate Key:Value(s)
 
As topic states... Not everything gets duped but this is the offending trigger (I assume, as it is the only one that captures the HP/CP/NRG/etc values) Mostly the curHP/curCP maxHP/maxCP NRG that I see getting duplicated, rarely companion or curEnemy
Code:

TRIG {
^HP:\s\[(\d+)/(\d+)]\sCP:\s\[(\d+)/(\d+)]\sENERGY:\s\[(\d+)]\sCOMP:\s\[(\d+)\%]\sENEMY:\s(\d+)\%$
}

PATTERN {
// setting variables
charData.curHP = %1
charData.maxHP = %2
charData.curCP = %3
charData.maxCP = %4
guildData.NRG = %5
guildData.companion = %6
charData.curEnemy = %7

// gagging line feed
#SUB %null

// ability costs
guildPowers.costFirstaid = %int(50*.@guildPowers.costRedux)
guildPowers.costTrance = %int(75*.@guildPowers.costRedux)
guildPowers.costRake = %int(40*.@guildPowers.costRedux)
guildPowers.costStrike = %int(70*.@guildPowers.costRedux)
guildPowers.costRebuff = %int(60*.@guildPowers.costRedux)
guildPowers.costSuture = %int(40*.@guildPowers.costRedux)
guildPowers.costCauterize = %int(50*.@guildPowers.costRedux)
guildPowers.strikePerRound=%int(100/@guildPowers.costStrike)

// per round functions
inCombat = 1
#IF (@guildData.NRG <= 50) {guildData.corpseUsage="cremate corpse"} {#IF (@charData.curHP >= %int(@charData.maxHP*.50)) {guildData.corpseUsage="assess corpse"} {guildData.corpseUsage="sendoff corpse"}}
#IF (@guildData.companion <= 50 && @guildPowers.Firstaid == Available) {fa companion}
#IF (@charData.curHP <= (@charData.maxHP/3*2) && @guildPowers.Suture == Available) {su}
#IF (@charData.curHP <= (@charData.maxHP/2) && @guildPowers.Poultice == Available) {phot}
#IF (@charData.curEnemy >= 10 && @guildPowers.Trance == Available)
  {
  #SENDRAW {!trance}
  #IF (@guildPowers.Rebuff == Available && @charData.NRG >= @guildPowers.costRebuff) {re}
  } {
  #IF (@guildPowers.Rake == Available && @guildData.NRG >= @guildPowers.costRake)
  {
    #IF (@guildPowers.Rebuff == Available && @guildData.NRG >= @guildPowers.costRebuff) {re}
    ra
  } {
    #IF (@guildPowers.Rebuff == Available && @guildData.NRG >= @guildPowers.costRebuff) {re}
    #IF (@guildPowers.Strike == Available && @guildData.NRG >= @guildPowers.costStrike) {#REP @guildPowers.strikePerRound {St}}
        }
  }

// Per Round Gexp Tracking
#SENDRAW {!gexp}
}


**tried to use %db and other functions but kept erroring out... so I'm not using the correctly obviously**
Reply with quote
shalimar
GURU


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

PostPosted: Mon May 18, 2020 2:31 am   
 
So you are winding up with two instances of a given key? That is rather odd.
I would almost suspect a corrupted .pkg file.

As far as cleaner code goes, the long-forms would be:

#ADDKEY charData curHP %1

#ADDKEY guildPowers costFirstaid %int(50*%concat("0.", %db(@guildPowers, costRedux)))

#IF ((%db(@guildPowers. Rebuff) == Available) && (%db(@charData, NRG) >= %db(@guildPowers, costRebuff))) {re}
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Mon May 18, 2020 2:50 am   
 
Ok, I think that makes sense. I noted you had said you didn't preffer the . method of calling on Var DB.

I'm trying to clean up extrenous code and make things more efficient, use $local when I don't need to store the data.


Question, if your variable db already has the field then you don't need to use #ADDKEY right? just the way I was doing in my sample above?
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Mon May 18, 2020 4:58 am   
 
Another problem... Why is the #FORALL not working?!?

Code:
//Set base gSkill list
FishSpeakerData.gSkillList = proficiency|determination|precognition|speed|honor|discipline|cunning

//add sub-guild gSkill
#SW (@FishSpeakerData.subGuild = Scout) {#additem @FishSpeakerData.gSkillList lethality}
 (@FishSpeakerData.subGuild = Warrior) {#additem @FishSpeakerData.gSkillList carnage}
 (@FishSpeakerData.subGuild = Medic) {#additem @FishSpeakerData.gSkillList vitality}

//add companion gSkill if unlocked
#IF (@FishSpeakerData.gLevel >= 150) {#additem @FishSpeakerData.gSkillList camaraderie}

//perform Training or Costs calc
#IF (!%ismember(%1, "train|costs")) {#echo Syntax: gskillme train/costs}

#IF (%ismember(%1, "train")) {
 #ECHO gskillme training
 #FORALL @FishSpeakerData.gSkillsList {train %i}
}

#IF (%ismember(%1, "costs")) {
 #ECHO gskillme costs
 totalExpCost = 0
 totalSolCost = 0
 #WA 1000
 #SENDRAW {!gskills}
 #WA 1000
 #SHOW {[ Total Exp Cost : @totalExpCost | Total Sol Cost : @totalSolCost ]}
 #SHOW { ** gSkill softcap : %int(@FishSpeakerData.gLevel / 4) ** }
 totalExpCost = 0
 totalSolCost = 0
Reply with quote
shalimar
GURU


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

PostPosted: Mon May 18, 2020 11:22 am   
 
#ADDKEY will overwrite the data, its essentially the difference between using the var command or just doing this=that.

I think the dot syntax doesn't always evaluate appropriately at runtime.
Using local variables instead or the %db function is just one means of ensuring the right data is being tested against.

Try putting your #FORALL expression in parenthesis.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Mon May 18, 2020 2:30 pm   
 
using ( ) didn't do anything. using "" in testing does when it's encapsulating the stringlist from the top. getting it to include the "'s is the issue.

it wanted to """proficiency"|determination|precognition|speed|honor|discipline|cunning|vitality|camaraderie"
if I put in " leading the first list, and " after camaraderie to close it off.

would this be a case use of %concat ?
** tried messing with concat and couldn't get that to work either... seems that pulling the list from variable database is the issue, making the gSkillList it's own variable works fine.

Code:
//Set base gSkill list
gSkillList = "proficiency|determination|precognition|speed|honor|discipline|cunning"

//add sub-guild gSkill
#SW (@FishSpeakerData.subGuild = Scout) {#ADDITEM gSkillList lethality}
 (@FishSpeakerData.subGuild = Warrior) {#ADDITEM gSkillList carnage}
 (@FishSpeakerData.subGuild = Medic) {#ADDITEM gSkillList vitality}

//add companion gSkill if unlocked
#IF (@FishSpeakerData.gLevel >= 150) {#ADDITEM gSkillList camaraderie}

//perform Training or Costs calc
#IF (!%ismember(%1, "train|costs")) {#echo Syntax: gskillme train/costs}

#IF (%ismember(%1, "train")) {
 #ECHO gskillme training
 #FORALL @gSkillList {train %i}
}

#IF (%ismember(%1, "costs")) {
 #ECHO gskillme costs
 totalExpCost = 0
 totalSolCost = 0
 #WA 1000
 #SENDRAW {!gskills}
 #WA 1000
 #SHOW {[ Total Exp Cost : @totalExpCost | Total Sol Cost : @totalSolCost ]}
 #SHOW { ** gSkill softcap : %int(@FishSpeakerData.gLevel / 4) ** }
 totalExpCost = 0
 totalSolCost = 0
}
Reply with quote
shalimar
GURU


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

PostPosted: Mon May 18, 2020 7:26 pm   
 
Try assigning the value to a local variable and run the #FORALL off that?
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Mon May 18, 2020 10:39 pm   
 
tried using $gSkillList and it kept saying invalid local variable or some error with invalid character =
Reply with quote
shalimar
GURU


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

PostPosted: Mon May 18, 2020 11:11 pm   
 
Likely a scoping issue.
If it is being defined inside an if/loop what have you, yet not used within that smaller script, you need to declare it in the main script first with #LOCAL.
It only exists within the script {} that initializes it otherwise.
_________________
Discord: Shalimarwildcat
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