Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game

Notices

Reply
 
Thread Tools Display Modes
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 104

Old December 5th, 2017, 07:38 PM
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?
Bob G is offline   #1 Reply With Quote
Minous
Senior Member
 
Join Date: May 2015
Posts: 567

Old December 6th, 2017, 07:13 AM
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
Minous is offline   #2 Reply With Quote
Minous
Senior Member
 
Join Date: May 2015
Posts: 567

Old December 6th, 2017, 07:16 AM
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.
Minous is offline   #3 Reply With Quote
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 104

Old December 6th, 2017, 01:03 PM
Quote:
Originally Posted by Minous View Post
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.
So, if I'm thinking this through correctly, and following your steps, I would first get the INT attribute bonus:
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 02:58 PM.
Bob G is offline   #4 Reply With Quote
Minous
Senior Member
 
Join Date: May 2015
Posts: 567

Old December 6th, 2017, 01:32 PM
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
I will also note that the fields you are using may or may not be correct, I dont have HL handy to confirm.

Last edited by Minous; December 6th, 2017 at 01:34 PM.
Minous is offline   #5 Reply With Quote
Aaron
Senior Member
Lone Wolf Staff
 
Join Date: Oct 2011
Posts: 6,662

Old December 6th, 2017, 01:49 PM
Quote:
Originally Posted by Minous View Post
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
I will also note that the fields you are using may or may not be correct, I dont have HL handy to confirm.
In my opinion, its always much better to store a value used in a field than in a variable. Fields can be manipulated from the outside, while variables can't. For the same reason it's also best practices to split your eval scripts so that the first sets values, and the second uses those values, with some time in between in case something needs to intervene.
Aaron is offline   #6 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 12,367

Old December 6th, 2017, 02:04 PM
Quote:
Originally Posted by Bob G View Post
field.[abValue]
In the link Minous gave you, follow the second link - the Location, Location, Location article, and then take another look at the syntax for the field transition. What you've got here is not correct.
Mathias is online now   #7 Reply With Quote
Minous
Senior Member
 
Join Date: May 2015
Posts: 567

Old December 6th, 2017, 02:37 PM
Aaron the only reason I suggested a variable was for readability purposes. I find int_bonus far easier to remember then what hero.child[aINT].field[aBonus].value is referring to. Had this been a more complex request or a scaling value I would agree. But for what is just a simple reference value that is not going to be used outside of the script I felt that limiting the scope using a variable was appropriate.
Minous is offline   #8 Reply With Quote
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 104

Old December 6th, 2017, 02:54 PM
Quote:
Originally Posted by Mathias View Post
In the link Minous gave you, follow the second link - the Location, Location, Location article, and then take another look at the syntax for the field transition. What you've got here is not correct.
Yessir, you are right. Should be field[abValue].value

Thanks for that. I feel like a two year old learning how to talk...
Bob G is offline   #9 Reply With Quote
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 104

Old December 6th, 2017, 02:56 PM
Quote:
Originally Posted by Minous View Post
Aaron the only reason I suggested a variable was for readability purposes. I find int_bonus far easier to remember then what hero.child[aINT].field[aBonus].value is referring to. Had this been a more complex request or a scaling value I would agree. But for what is just a simple reference value that is not going to be used outside of the script I felt that limiting the scope using a variable was appropriate.
It's all good, either way. I've learned that there are two ways to accomplish the task, and that's a good thing.

Thanks everyone.
Bob G is offline   #10 Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:12 PM.


Powered by vBulletin® - Copyright ©2000 - 2018, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.