Zmud Script Help Request :

... A place to ask for help on any topic whether it be starting out to player killing to IT issues.
Theid
Posts: 58
Joined: Tue Jun 16, 2015 9:05 pm

Zmud Script Help Request :

Postby Theid » Wed Dec 14, 2016 2:11 pm

I have heavily modified Taziar's existing WeaponType script http://www.wotmudarchives.org/forum/vie ... 2622#p2622 in an attempt to make a modified Equipment script for fun. However, I can't for the life of me get it to work...

Most of it (as far as I can tell) works. What is failing to work is "#VAR equipmentCurrentKeywordHead {}" never seems to register the right keyword.

Is it my "#VAR equipmentListHead" that isn't correct?

Basically, I just want #VAR equipmentCurrentNameHead to be the helmet name that I am wearing and #VAR equipmentCurrentKeywordhead be the corresponding keyword for that item.

IE: The helmet name, "A strange, insectoid helm" has the keyword "insectoid".

Any assistance or input is of course, much appreciated.

#CLASS {Equipment}
#CLASS {Equipment|HeadType}
#ALIAS equipmentCurrentFunctionHead {
#IF (%ismember( %1, @equipmentCurrentNameHead)) {} {
#VAR equipmentCurrentNameHead {%1}
equipmentSetKeywordHead current
}
}
#ALIAS equipmentSetKeywordHead {
#IF (%1=current) {#VAR equipmentKeywordVariableHead equipmentCurrentKeywordHead} {}
#FORALL @equipmentListHead {
#VAR equipmentSaveStringHead {%i}
#IF (%ismember( @equipmentNameHead, @equipmentSaveStringHead.1.1)) {
#VAR %eval( "@equipmentKeywordVariableHead") {@equipmentSaveStringHead.2.1}
#VAR equipmentTypeH {Head}
#ABORT 1
} {}
}
}
#VAR equipmentListHead {(a polished, slitted great helm|helm)|(a full metal helmet and visor|helmet)|(a strange, insectoid helm|insectoid)|(a rimmed round helmet |rimmed)}
#VAR equipmentCurrentKeywordhead {helm}
#VAR equipmentCurrentNameHead {a polished, slitted great helm}
#VAR equipmentKeywordVariableHead {equipmentCurrentKeywordHead}
#VAR equipmentNameHead {a polished, slitted great helm}
#VAR equipmentSaveNameHead {}
#VAR equipmentSaveStringHead {}
#VAR equipmentTypeH {Head}
#TRIGGER "WornOnHead" {*~<worn on head~>%s&equipmentNameHead%s$} {equipmentCurrentFunctionHead @equipmentNameHead}
#TRIGGER "YouWearHead" {*You wear &equipmentNameHead on your head.} {equipmentCurrentFunctionHead @equipmentNameHead}
#CLASS 0
#CLASS 0

Maegon
Posts: 242
Joined: Wed Mar 25, 2015 3:15 am

Re: Zmud Script Help Request :

Postby Maegon » Wed Dec 14, 2016 5:46 pm

So the first issue I found is that the #IF statement in the equipmentsetkeywordhead needs quotes for it to fire.

#IF (%1="current")

However, it seems like the use of a database would be FAR simpler, instead of the variable manipulation.

Code: Select all

#CLASS {Equipment}
#CLASS {Equipment|HeadType}


#VAR EquipmentNameHead ""
#VAR HeadPiece ""

#VAR headlist ""
#CALL %vartype(headlist,5)
#ADDKEY headlist {a polished, slitted great helm} {helm}
#ADDKEY headlist {a full metal helmet and visor} {helmet}
#ADDKEY headlist {a strange, insectoid helm} {insectoid}
#ADDKEY headlist {a rimmed round helmet} {rimmed}
#ADDKEY headlist {a thick helmet of supple leather} {thick}

#ALIAS headtest {#echo @HeadPiece}


#TRIGGER "WornOnHead" {*~<worn on head~>%s&equipmentNameHead%s$} {#VAR headpiece %item(@headlist,@equipmentnamehead)}
#TRIGGER "YouWearHead" {*You wear &equipmentNameHead on your head.} {#VAR headpiece %item(@headlist,@equipmentnamehead)}

#CLASS 0
#CLASS 0


I checked this in cmud, so it may or may not work in Zmud.

Theid
Posts: 58
Joined: Tue Jun 16, 2015 9:05 pm

Re: Zmud Script Help Request :

Postby Theid » Wed Dec 14, 2016 5:51 pm

Thank you Maegon! I will try the #IF (%1 "current")

I use Zmud, and am unsure how to use a database.. I'll confirm whether the #IF modification fixed it later tonight.

Maegon
Posts: 242
Joined: Wed Mar 25, 2015 3:15 am

Re: Zmud Script Help Request :

Postby Maegon » Wed Dec 14, 2016 6:06 pm

The #IF modification doesn't fix the problem. It just allows the alias to fire in the first place, and I stopped trying at that point after realizing a database would be better. I would highly recommend playing with the database variable type that I posted. There's a decent chance this will work just fine in Zmud though.

Also, I just realized that your "wornonhead" trigger will change if you look at anyone wearing something on their head. So to be concise, you would need to initialize those triggers to be disabled by default, then set an alias that turns on the trigger and checks your equipment, as well as cause the trigger to turn off on completion. I also changed the triggers to match at the start of the line, so someone couldn't screw up your stuff. Posted the changes below.

Code: Select all

#CLASS {Equipment}
#CLASS {Equipment|HeadType}


#VAR EquipmentNameHead ""
#VAR HeadPiece ""

#VAR headlist ""
#CALL %vartype(headlist,5)
#ADDKEY headlist {a polished, slitted great helm} {helm}
#ADDKEY headlist {a full metal helmet and visor} {helmet}
#ADDKEY headlist {a strange, insectoid helm} {insectoid}
#ADDKEY headlist {a rimmed round helmet} {rimmed}
#ADDKEY headlist {a thick helmet of supple leather} {thick}

#ALIAS headtest {#echo @HeadPiece}
#ALIAS eq {#T+ "WornOnHead";equipment}


#TRIGGER "WornOnHead" {^*~<worn on head~>%s&equipmentNameHead%s$} {#VAR headpiece %item(@headlist,@equipmentnamehead);#T- "WornOnHead"}
#TRIGGER "YouWearHead" {^*You wear &equipmentNameHead on your head.} {#VAR headpiece %item(@headlist,@equipmentnamehead)}
#T- "WornOnHead"

#CLASS 0
#CLASS 0

Theid
Posts: 58
Joined: Tue Jun 16, 2015 9:05 pm

Re: Zmud Script Help Request :

Postby Theid » Wed Dec 14, 2016 10:12 pm

Sorry it took forever to test this out. Unfortunately it still doesn't work.

The headpiece variable stays empty.

I copy and pasted the information to Zmud command line and then went to the folder and clicked on Edit, to get the "zmudified" code.
Doesn't look quite right..
However when I look at the headlist variable inside the class, it looks great with two columns, 1 with the equipment names and one with their respective keywords. How can I make it so @headpiece = the second column word?

Code: Select all

#CLASS {Equipment}
#CLASS 0
#CLASS {Equipment|HeadType}
#ALIAS headtest {#echo @HeadPiece}
#ALIAS eq {
  #T+ "WornOnHead"
  equipment
  }
#VAR EquipmentNameHead {}
#VAR HeadPiece {}
#VAR headlist {a polished, slitted great helmhelma full metal helmet and visorhelmeta strange, insectoid helminsectoida rimmed round helmetrimmeda thick helmet of supple leatherthick}
#TRIGGER "WornOnHead" {^*~<worn on head~>%s&equipmentNameHead%s$} {
  #VAR headpiece %item( @headlist, @equipmentnamehead)
  #T- "WornOnHead"
  } "" {disable}
#TRIGGER "YouWearHead" {^*You wear &equipmentNameHead on your head.} {#VAR headpiece %item( @headlist, @equipmentnamehead)}
#CLASS 0

Theid
Posts: 58
Joined: Tue Jun 16, 2015 9:05 pm

Re: Zmud Script Help Request :

Postby Theid » Wed Dec 14, 2016 10:26 pm

I got IT!

I played around with your script and some of my older attempts and mashed together something that works!

Thank you o so much!! Time to make 5 more classes for arms, body, hands, legs and feet! :!:

Code: Select all

#CLASS {Equipment}
#CLASS 0
#CLASS {Equipment|HeadType}
#ALIAS headtest {#echo @HeadPiece}
#ALIAS eq {
  #T+ "WornOnHead"
  equipment
  }
#ALIAS equipmentHeadSet {
  #IF (@equipmentHeadName="a polished, slitted great helm") {HeadPiece="helm"} {}
  #IF (@equipmentHeadName="a full metal helmet and visor") {HeadPiece="helmet"} {}
  #IF (@equipmentHeadName="a strange, insectoid helm") {HeadPiece="helm"} {}
  #IF (@equipmentHeadName="a rimmed round helmet") {HeadPiece="rimmed"} {}
  }
#VAR EquipmentHeadName {a rimmed round helmet}
#VAR HeadPiece {rimmed}
#TRIGGER "WornOnHead" {^*~<worn on head~>%s&equipmentNameHead%s$} {
  #VAR headpiece %item( @headlist, @equipmentnamehead)
  #T- "WornOnHead"
  } "" {disable}
#TRIGGER "YouWearHead" {^*You wear &equipmentNameHead on your head.} {equipmentHeadSet}
#CLASS 0

Theid
Posts: 58
Joined: Tue Jun 16, 2015 9:05 pm

Re: Zmud Script Help Request :

Postby Theid » Thu Dec 15, 2016 8:49 am

Hmm, just realized I didn't test the one of the two triggers... So I just removed it entirely.

This would be the ultra-simplified version and will only trigger when I wear something. (Which is fine by me)

P.S. I haven't tested it after removing the following, but I don't think there should be a problem:
- #ALIAS eq
- #TRIGGER "WornonHead"
- #ALIAS headtest

Code: Select all

#CLASS {Equipment}
#CLASS 0
#CLASS {Equipment|HeadType}
#ALIAS equipmentHeadSet {
  #IF (@equipmentHeadName="a polished, slitted great helm") {HeadPiece="helm"} {}
  #IF (@equipmentHeadName="a full metal helmet and visor") {HeadPiece="helmet"} {}
  #IF (@equipmentHeadName="a strange, insectoid helm") {HeadPiece="helm"} {}
  #IF (@equipmentHeadName="a rimmed round helmet") {HeadPiece="rimmed"} {}
  }
#VAR EquipmentHeadName {a rimmed round helmet}
#VAR HeadPiece {rimmed}
#TRIGGER "YouWearHead" {^*You wear &equipmentNameHead on your head.} {equipmentHeadSet}
#CLASS 0

Naerin
Posts: 202
Joined: Sat May 23, 2015 12:29 pm

Re: Zmud Script Help Request :

Postby Naerin » Thu Dec 15, 2016 12:48 pm

Suggestion: Instead of the eq alias, something like (not sure if I got the message right, can't check right now):

#TRIGGER {^You are using:} {#T+ "WornOnHead"}

This make me happier for a couple reasons: it's not aliasing over a mud command and if you ever do something like 'exa theid' it won't fail to trigger.

Could do a trigger for <worn on feet> to turn it off so you only need to care about it once, and maybe a failsafe alias to turn it off in case you go barefoot and that trigger doesn't fire.

Naerin
Posts: 202
Joined: Sat May 23, 2015 12:29 pm

Re: Zmud Script Help Request :

Postby Naerin » Thu Dec 15, 2016 12:52 pm

Also: for real a DB would make this like ten timer shorter. Could just check %iskey for every item you're wearing.

Theid
Posts: 58
Joined: Tue Jun 16, 2015 9:05 pm

Re: Zmud Script Help Request :

Postby Theid » Thu Dec 15, 2016 1:30 pm

Well, I don't know much about Databases or %iskeys... I'll take some time to read the Zmud helpfiles about that.

Oh and yes, in case you are wondering, the main purpose of this script was to be able to type 1 command (mendall) and it then mend all my gear, no matter the gear!

In a future installment, I'd like to have some sort of " #ALIAS Swap @Headpiece " that would check the condition of the item I am wearing vs the condition of an item in my inventory and swap them if the one I am wearing is in worse condition than the one in my inventory...

Backstory : I smob a lot, and after an hour of smobbing my gear has often gone from 85% to under 75%... So if, instead of tossing aside the abs gear the smobs load, I instead remove what I am wearing and replace it with the pristine condition piece they just loaded, I could theoretically smob indefinitely! Or atleast be wearing the best gear at all times... But this is a tad beyond me I think..

In the meantime here's the "complete" Equipment script (Will have to test once I get home and confirm functionality!) :

Code: Select all

#CLASS {Equipment}
#ALIAS mendall {
remove @HeadPiece
remove @ArmsPiece
remove @BodyPiece
remove @HandsPiece
remove @LegsPiece
remove @FeetPiece
mend @HeadPiece
mend @ArmsPiece
mend @BodyPiece
mend @HandsPiece
mend @LegsPiece
mend @FeetPiece
}
#ALIAS examineall {
examine @HeadPiece
examine @ArmsPiece
examine @BodyPiece
examine @HandsPiece
examine @LegsPiece
examine @FeetPiece
}
#CLASS 0
#CLASS {Equipment|HeadType}
#ALIAS equipmentHeadSet {
  #IF (@equipmentHeadName="a polished, slitted great helm") {HeadPiece="helm"} {}
  #IF (@equipmentHeadName="a full metal helmet and visor") {HeadPiece="helmet"} {}
  #IF (@equipmentHeadName="a strange, insectoid helm") {HeadPiece="helm"} {}
  #IF (@equipmentHeadName="a rimmed round helmet") {HeadPiece="rimmed"} {}
  }
#VAR EquipmentHeadName {a rimmed round helmet}
#VAR HeadPiece {rimmed}
#TRIGGER "YouWearHead" {^*You wear &equipmentNameHead on your head.} {equipmentHeadSet}
#CLASS 0
#CLASS {Equipment|ArmsType}
#ALIAS equipmentArmsSet {
  #IF (@equipmentArmsName="a pair of steel-plated vambraces") {ArmsPiece="vambraces"} {}
  #IF (@equipmentArmsName="a pair of ebony-steel plate vambraces") {ArmsPiece="vambraces"} {}
  #IF (@equipmentArmsName="a pair of polished, gold-plated vambraces") {ArmsPiece="vambraces"} {}
  #IF (@equipmentArmsName="a pair of riveted chainmail") {ArmsPiece="sleeves"} {}
  }
#VAR EquipmentArmsName {}
#VAR ArmsPiece {}
#TRIGGER "YouWearArms" {^*You wear &equipmentNameArms on your arms.} {equipmentArmsSet}
#CLASS 0
#CLASS {Equipment|BodyType}
#ALIAS equipmentBodySet {
  #IF (@equipmentBodyName="a thick, steel-plated breastplate") {BodyPiece="breastplate"} {}
  #IF (@equipmentBodyName="a shining steel breastplate") {BodyPiece=" breastplate"} {}
  #IF (@equipmentBodyName="a silver plated breastplate") {BodyPiece="breastplate"} {}
  #IF (@equipmentBodyName="an engraved gold-plated breastplate") {BodyPiece="breastplate"} {}
  #IF (@equipmentBodyName="a tunic of finely-crafted chain") {BodyPiece="tunic"} {}
  }
#VAR EquipmentBodyName {}
#VAR BodyPiece {}
#TRIGGER "YouWearBody" {^*You wear &equipmentNameBody on your body.} {equipmentBodySet}
#CLASS 0
#CLASS {Equipment|HandsType}
#ALIAS equipmentHandsSet {
  #IF (@equipmentHandsName="a pair of heavy metal gauntlets") {HandsPiece="gauntlets"} {}
  #IF (@equipmentHandsName="a sturdy pair of full leather gauntlets") {HandsPiece="gauntlets"} {}
  }
#VAR EquipmentHandsName {}
#VAR HandsPiece {}
#TRIGGER "YouWearHands" {^*You wear &equipmentNameHands on your hands.} {equipmentHandsSet}
#CLASS 0
#CLASS {Equipment|LegsType}
#ALIAS equipmentLegsSet {
  #IF (@equipmentLegsName="a pair of thick, gold-plated greaves") LegsPiece="greaves"} {}
  #IF (@equipmentLegsName="a pair of steel-plated greaves") LegsPiece="greaves"} {}
  #IF (@equipmentLegsName="a pair of ebony-steel plate greaves") LegsPiece="greaves"} {}
  #IF (@equipmentLegsName="a set of riveted chainmail leggings") LegsPiece="leggings"} {}
  }
#VAR EquipmentLegsName {}
#VAR LegsPiece {}
#TRIGGER "YouWearLegs" {^*You wear &equipmentNameLegs on your legs.} {equipmentLegsSet}
#CLASS 0
#CLASS {Equipment|FeetType}
#ALIAS equipmentFeetSet {
  #IF (@equipmentFeetName="a dark pair of steel boots") {FeetPiece="boots"} {}
  #IF (@equipmentFeetName="a pair of thick metal boots") {FeetPiece="boots"} {}   
  #IF (@equipmentFeetName="a pair of gleaming metal boots") {FeetPiece="boots"} {}
  #IF (@equipmentFeetName="a pair of lissome leather boots with metal capped toes") {FeetPiece="boots"} {}
  #IF (@equipmentFeetName="a pair of animal-fur boots") {FeetPiece="boots"} {}
  }
#VAR EquipmentFeetName {}
#VAR FeetPiece {}
#TRIGGER "YouWearFeet" {^*You wear &equipmentNameFeet on your feet.} {equipmentFeetSet}
#CLASS 0


Return to “Help and Newbie Area”

Who is online

Users browsing this forum: No registered users and 2 guests