Tutorial: How to change the stat modifier calculation


So, I chose to calculate stat modifiers according to the "most popular" RPG instead of a common GLOG method. Many users might wish to change it to use (stat/3)-3 instead of (stat-10)/2.

You can do this by selecting File>Properties>Script.

Here's the function where the formula is defined. Everything in the deck uses this function when it wants to calculate a stat modifier.


The lines with # at the beginning are comments. As you can see, I've already included several examples. To switch to one of them, add a # before the first line, then remove it from the line you want to use.

For character sheets from before 1.1:

I used the (stat-10)/2 calculation in a couple places, we'll need to change it in each one.

First, change your tool from "Interact" to "Widgets".


Then, double-click any of the stat bars, and then click "Prototype".


Then, from the top menu, select "Prototype" then "Script..."

Here, I've used the following bit of code in three places:

-10)/2

Edit it to the following:

/3)-3

Press ctrl+s to save, then return home with File>Close Script and Prototype>Close.

The second place I calculate modifiers is in the d20 roller. Double-click it and go to its prototype, then to the prototype's script. You should see the formula twice near the top. Replace it just like you did earlier.

Next... I'm really sorry about this. All six stat roll buttons in this prototype use the code, twice, in the middle of a larger formula.


Double-click the button, then look at the button's script.



Replace `-10)/2` with `/3)-3` in both places. Be careful not to mess with surrounding parentheses.

You'll have to do this individually for each button.

I didn't want to update this tool a lot since existing character saves won't get new features, but this really feels like it warrants an update. In the next version, I'll definitely edit these to all point at one function that you can easily edit it in one place and have the change apply everywhere.

Also, I already have plans for the d20 roller to log all previous rolls instead of just being a big white space with a single number. So I can bring both these changes to you at once.

Extra secret hack that might do all this in an instant but I haven't tested it thoroughly and it might break things:

File>Save As. Make sure the filename ends in .html.

Open the html file in notepad or your text editor of choice.

Find and replace `-10)/2` with `/3)-3`.

Save, then open the html file again in decker.

Get Interactive GLOG Character

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

(+1)

Another idea for making this configurable might be to use eval[]. For example, if you have an expression as a string (which could be a contraption attribute):

expr:"(n-10)/2"

You could then evaluate it under a dictionary of variable bindings:

(x+floor eval[expr ("n" dict grid1.cellvalue)].value) ...
(1 edit)

I'll keep it in mind. Since I'm using it in two different contraptions, I'm thinking a module is better than anything that belongs to one contraption since both contraptions can access it equally?

(Edit: there's even a deck-level script which is probably a simpler solution than a module)