View Single Post
Lawful_g
Senior Member
Volunteer Data File Contributor
 
Join Date: Mar 2007
Posts: 1,245

Old August 25th, 2009, 09:51 AM
The script used is not custom, at least I don't think. It is XML, which I had never used or heard of before I picked up HL. Here i'll give a detailed explaination of the previous code I provided, and hopefully that will provide some insight for you, Invictus.

var result as number
~ The above tells hero lab that we are going to create a variable named "result" and it is going to be a number. The general formula for this sort of thing is "var XXXX as number" and we can put any non-reserved word in the place of XXXX. If it is reserved, you will get an error later.

if (hero.tagis[Encumbered.Medium] + hero.tagis[Encumbered.Heavy] <> 0) then
result = assign[Helper.SpcDisable]
done
elseif (hero.tagis[Hero.MedArmor] + hero.tagis[Hero.HeavyArmor] <> 0) then
result = assign[Helper.SpcDisable]
done
endif

~ The general form HL uses for if/then statements is

"if (some Mathmatical relationship) then
the result
endif"

the result is only performed when some Mathmatical relationship is true. You can nest if/thens within each other to make very specific requirements to execute the result, but each of them needs to have it's own "endif" statment. Also not that if you are not nesting them, but performing them in sucession, the 2nd and all others should be "elseif".

The "hero.tagis[Encumbered.Medium]" is important as well. "hero" tells the program where to look (on your hero, obviously), "tagis" specifies that it is checking to see if a certain tag ("Encumbered.Medium" tags referred to in scripts are in []) exists and if so it will return a 1.

result = assign[Helper.SpcDisable] is a command to assign the tag "Helper.SpcDisable" to the grace ability (rendering it non-functional and greyed out), since this is the second part of an if/then it will only be carried out when the first part is true.

"done" tells the eval script to stop whatever it is doing and get out here. It is only safe to use as the second part of an if/then. If you use it outside of there, all code after it will not be read or carried out.

~ Get the bonus based on our level
var bonus as number
var level as number
level = field[xTotalLev].value
if (level >= 20) then
bonus = 3
elseif (level >= 11) then
bonus = 2
else
bonus = 1
endif


~ Here we set 2 new variables, and defined level based on the value of the field "xTotalLev". Then, depending on what the value of level was, we set the value of bonus. This is a common script you will be using a lot, for just about anything that varies with level.

~ Note that the bonus is a Competence bonus, so I have changed what was previously .field[Bonus] to .field[BonComp]
container.child[vRef].field[BonComp].value = container.child[vRef].field[BonComp].value + bonus

~ Here is where my knowledge gets a little fuzzy and I tend to fiddle around a bit. I am not sure what "container" means but it is the starting point. I think of a "." as sort of an arrow to the next level, so .child[vRef] means "from container go down to vRef" and .field[BonComp].value means "go to the field BonComp and get it's value".

The first part (container.child[vRef].field[BonComp].value) is specifying what we are looking at, and then we set it = to the current value + the bonus we defined before.

There, that completes my little demo. Any questions?
Lawful_g is offline   #25 Reply With Quote