Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Anyone have any clue why this doesn't work? I've got this in "mods/modname/scripts/characters/races.gd", but it doesn't seem to be doing anything.

https://pastebin.com/1swUp609

(+2)

What do you mean by "doesn't seem to be doing anything."  Have you looked at races.gd after applying?

If that's all the mod does, i don't see it actually having any impact on the game whatsoever.  Nothing iterates over all races. Even if you added those 2 races here, currently you'd need to also modify a bunch of other code for them to actually be used anywhere.
 Particularly all the races arrays in globals.gd, like say adding them to:

var starting_pc_races = ['Human', 'Elf', 'Dark Elf', 'Orc', 'Demon', 'Beastkin Cat', 'Beastkin Wolf', 'Beastkin Fox', 'Halfkin Cat', 'Halfkin Wolf', 'Halfkin Fox', 'Taurus']

Ah yes, I should have clarified. By "not do anything", I mean it doesn't modify the "races" variable once applied.

(3 edits) (+1)

Noticed the problem, I had same issue on new files i made. Tabs vs. spaces,  the game uses tabs for indentation and the mod code all expects tabs. You need to convert all those spaces to tabs, then it should work.

Edit: It's more than that, testing out more.  The mod code expects all following lines to begin with a tab too, so the "Race One" and "Race two" need to be indented.  However, even with that, using a regex tester it doesn't match the regex the game is using for variables.

Edit2: The game's regex for variables does not support this far as I can tell,

(var.*=)\s([{]([^\{\}]*[\r\n]*)*[}])?([^\{\}\s]*)

That won't match anything with nested {}'s which are required for adding a race.  You could work around this by defining your own races, and then appending them to the official ones during startup of the game? Otherwise, we'll need a new version that supports this. Basically that chunk of code needs to be amended to also accept a form where it's "var blah = {" followed by a series of lines starting with tab, and then ending with a }, similar to what it does for functions.

To work around this, instead of modifying races.gd, add your own file that defines those 2 races, then do something like this for scripts/globals.gd

https://pastebin.com/g1bwycdJ

It's possible to mod the mod system, to change that regular expression to something that would work better.

I wasn't very familiar with Godot syntax when I wrote that regular expression.  I had to look up multi-line variables, and was not aware at the time that a dictionary with multiple values could be declared on a single line, and I couldn't even find an example of a static multi-dimensional array/dictionary and its declaration.


Regular expressions are... difficult to get right.

Having said that,

what is a regex tester and where can I find one?

Haha yeah... I tried to tweak the regex to get it working right, but bit burned out on coding from work to finish.  I typically use a site like www.regex101.com so I can visually see how it's matching to a set of text.  Can then stick in a variety of test cases and see how it responds.  I was able to tweak it to accept:

var blah = {
<tab indented text>
}

But the solution wouldn't have worked for single lines.  Likely could have made it work with some more groupings and or operators.  I used that site earlier to figure out why some of my code wasn't working, as in my own mod,it also fails on:

var randomportraits = load(globals.modfolder + "/randomportraits/randomportraits.gd").new()

Because it only matches on
var randomportraits = load(globals.modfolder
and inserts that into the file, breaking the game.  Thus, i did var blah = null, and then conditionally load it first time i need it.

(1 edit) (+1)

The mod can't add a "races" variable, because that variable already exists in the script, so either they conflict (and the mod is not applied) or the one from the mod is overwritten.
Btw, can you define a variable before the "extends Node" statement?
I suggest to remove line 2 and 19 from the mod and insert the code after line 359 of races.gd, so that the new two races are pushed at the end of the existing list (the mod should start with <AddTo 358> or something like that, the number may be slightly wrong)

Also what Kyler2 said.

http://strive4power.wikia.com/wiki/Modding_Guide

I know about the conflict, but my understanding is that the <AddTo -1> tag should resolve it by modifying the object alone. I already sent this off to Maverik, and he didn't seem to find a problem with my reasoning but recommended that I post here to see if anyone could find something he missed.

<AddTo ...> is based off insertion point, not total line number.

<AddTo 2>

func testfunc: ....

....


Will add to line 2 of testfunc, not line 2 of the file.

For base files, you cannot define anything before the "extends Node" statement.  Godot requires all files to begin with that.  (Or begin with extending a subclass of Node)