|
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
I think the toughest part of learning to write eval scripts has been learning how to put 'sentences' together that make sense to the editor. I think I have a basic understanding of the vocabulary needed (I get what tags, fields, macros, things, etc. are), but I think I am still lacking the knowledge of how to put that vocabulary together to make a 'language' that is understandable.
For example, I might know the words in Spanish for 'I', 'eat', 'cookie', and 'want', but if I don't know what order to put them in, the resulting sentence will probably be meaningless. My experience with writing scripts has been very much like this; I know 'words' like 'field' and 'cBbnRage', but writing a 'sentence' like "apply a bonus to damage equal to the character's Intelligence bonus with all firearms" still eludes me. Is there a tutorial or thread on the forums that teaches the 'grammar' of scripts? |
#1 |
Senior Member
Join Date: May 2015
Posts: 830
|
http://forums.wolflair.com/showthread.php?t=21688
Keep in mind that you are programming, not using what humans call language. The primary difference is that you are giving commands to the system, not communicating with it. Also keep in mind while apply a bonus to damage equal to the character's Intelligence bonus with all firearms might be one sentence for humans its a matter of 4-5+ commands for HL |
#2 |
Senior Member
Join Date: May 2015
Posts: 830
|
the sudo code for apply a bonus to damage equal to the character's Intelligence bonus with all firearms is something like:
find intelligence modifier and store in variable. find all fire arms, and iterate over those (a for each loop) apply damage modifier to said weapon. end the for each loop and you would need to set the timing of that command correctly, Somewhere after post attributes probably. |
#3 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Quote:
field.[abValue]=hero.child[aINT].field[aBonus].value Then, I would do a foreach command that locates all picks with the BaseWep component and the tag wCategory.Firearm: foreach pick in hero from Component.BaseWep where wCategory.Firearm Then, I apply the bonus to the results that the foreach command found: eachpick.field[dmrBonus].value += hero.child[aINT].field[abValue].value Lastly, I end the foreach command: nexteach I haven't tried it yet, just wanted to get my thoughts written down so that it sticks in my mind. Let me know if my script was right, and thank you so much for your help. Last edited by Bob G; December 6th, 2017 at 01:58 PM. |
|
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
|
#5 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Quote:
Thanks for that. I feel like a two year old learning how to talk... |
|
#6 |
Senior Member
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226
|
Quote:
Example: Do I use foreach pick in hero where wCategory.Firearm or just foreach pick in hero where Firearm |
|
#7 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
Take a look at THIS post I did about doing that. Hopefully it helps. Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. |
|
#8 |
Senior Member
Join Date: May 2015
Posts: 830
|
It looks right, but I haven't tested it. I also wouldn't use abValue for basic variable usage.
I would do something like: Code:
var int_bonus as number int_bonus = hero.child[aINT].field[aBonus].value foreach pick in hero where wCategory.Firearm eachpick.field[dmrBonus].value += int_bonus nexteach Last edited by Minous; December 6th, 2017 at 12:34 PM. |
#9 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
Quote:
|
|
#10 |
|
|