Posted August 11, 2023 by sshelton
I've gotten two feature requests so I will add them and figured I would describe the process for anyone interested. Creating a thing from scratch and later coming back to it to modify it are two different things. In the latter scenario, we need to deal with whatever shortcuts or assumptions we made in the first one. Today I'm going to :
I'll tackle the more complicated scene first. Step one is add the new LineEdit node to take the user's input then add a variable to access the input with an @onready decorator at the top of the script. Now I need to get the value of that input and handle it like the others, but slightly differently.
This field is optional, so it may not have a value in it. If that is the case the rolls will assume a complication range of 20. I'll add the new value to the _check_inputs function. As a user you have some responsibility not to input nonsense and I can't protect you from everything. I only do minimal bounds checking to ensure the input values are 1 or above. But I will allow an empty complication range field and a null string in Godot cast to int evaluates to 0. So I just check that the value isn't less than 0 instead of 1.
Now I just need to factor in the user provided complication range or in it's absence substitute a default value of 20. And this is where I hit my first snag. I already have a variable in _process_roll called complication that I use to track the number of complications in the skill check. Oops! Now this isn't necessarily good practice and I just need to get this update done, so the complication variable represents complication range and the complications variable holds the number of complications rolled. Clear? Who cares, it works.
Make a little adjustment to the template string for the label to hold the new information and hopefully make it slightly more readable and this one is done! That wasn't too bad. Next we need a new image to represent a blank side of the Fallout 2d20 six sided damage dice. The other ones I shamelessly grabbed from image searches and edited them to suit the project. I think I'll make this one from scratch.
Glorious. It looks a little chunky as 200x200 and blown up 200% but I bet it will look amazing running in engine. Literally just two more lines of code and we're good to go.
Now the only thing left to do is run the updated project and see what I broke. Nothing? Well that might be a first. Ship it!