• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Hero Lab Editor: Increase Rate of Fire

javadragon

Well-known member
I am attempting to create a custom data file for a home brewed fantasy campaign setting for Savage Worlds. I am attempting to create a new edge called Fast Shot that will increase the ROF of the character's bow by 1. Unfortunately it appears that ROF is a text field and therefore my Eval Script:

Code:
foreach pick in hero from WeapRange
    ~ TODO: need to look at weapon name for the word bow
    eachpick.field[wpFireRate].value += 1
nexteach
does not work as I get the error:

Attempt to access text-based field 'wpFireRate' as a value.

I thought that all ROF's were integers until I looked at the core book and saw some ranges of "1-2". Is there a way that I can write some code to check the ROF field value and if it is a number then increment it by one? Or do I just need to make a note in my edge that the player needs to note this increase for themselves.
 
That or is my only option appending text to this field to say "+1"? If this is the case, will:

Code:
eachpick.field[wpFireRate].text = eachpick.field[wpFireRate].text & " (+1)"
 
After some searching on type conversion, I came up with this which seems to work:

Code:
var rof as number
foreach pick in hero from WeapRange
    ~ TODO: need to look at weapon name for the word bow
    rof = eachpick.field[wpFireRate].text  +1
    eachpick.field[wpFireRate].text = rof
nexteach

By reading type conversion on the WIKI, it seems that "1-2" will be converted to 1 and then have the arithmetic applied.
 
For other user's reference, here is what my completed code looks like:
Code:
var rof as number
foreach pick in hero from WeapRange
    ~ if this is a bow weapon
    if (eachpick.tagis[Weapon.Bow] <> 0) then
        rof = eachpick.field[wpFireRate].text + 1
        eachpick.field[wpFireRate].text = rof
    endif
nexteach
 
Would you rather have that convert to "2-3"? I can show you how to pull the numbers out of the string, manipulate them, and put them back...
 
Forgive me for taking so long...

Try this:

Code:
var rof as number
var rof2 as number
foreach pick in hero from WeapRange
    ~ if this is a bow weapon
    if (eachpick.tagis[Weapon.Bow] <> 0) then
        if (pos(eachpick.field[wpFireRate].text,"-") <> -1) then
            rof  = left(eachpick.field[wpFireRate].text,1) + 1
            rof2 = right(eachpick.field[wpFireRate].text,1) + 1
            eachpick.field[wpFireRate].text = rof & "-" & rof2
        else
            rof = eachpick.field[wpFireRate].text + 1
            eachpick.field[wpFireRate].text = rof
        endif
    endif
nexteach


The other function that's useful for this type of thing is mid. It allows you to vary the start position

example: rof2 = mid(eachpick.field[wpFireRate].text,3,1) + 1

and
are substring functions that take the designated number of characters from that end of the string. [mid] allows you to start anywhere (the first number) and take a given number of characters (the second number). The [pos] function finds a designated set of characters in a string. It reports back starting with position 0, with a -1 if it doesn't find the given characters.​
 
Last edited:
Back
Top