Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(6 edits)

Hmm... weird.  I thought I updated the regex handling vars for 0.5.19a.  Let's see... The non-Godot (for online regex testing) should be:
(var.*=\s)(([\{\[]([^\{\}]*[\r\n]*)*[\}\]])|([^\{\}\[\]\s]*))

Does that above expression do what you want?  The double-escaped version should be what is in the modpanel.gd file as that's what I have in my working copy?
What you have doesn't look right as it still has the '?', which allows for cases like var test = {...}[random other stuff] to work.

Edit01 : Oh, maybe your v19a was before I submitted changes, but the updated version is still v19a.

Edit02: Oh pastebin.  Ya that works too. =D

(1 edit)

In v19a doesn't work for anything, mainly because it has some typos like this:

[\\{\\[]]

The double ]'s at the end there mean it tries to match a literal ]. As-is, v19a won't match practically any var. Beyond that, what you've shown here also does not work on numerous lines because of what i mentioned before, it wants every line to not contain { or }  and so it breaks on nested dictionaries.  The second half of the major | also is needlessly limiting what it can match on. It should just match everything up to the newline, otherwise it breaks on numerous valid lines.

The regex I've proposed works much better on a wide variety of use cases, the regex101 link loads it up in the unescaped form and includes several test case matches, which your proposed one, and past ones, fail on. For example, this has never worked as a new variable to insert:

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

Prior regex's would always chop off part of that, then insert an invalid statement into the scripts.

Plus the later code when using AddTo was stripping {}'s which also prevented any insertion in nested dictionaries.  With the proposed modpanel.gd changes I made from v19a though, I was able to successfully test a mod to races dictionary. Should also work for multiline arrays too.

I'd recommend for future releases you make a test mod that tries to insert new and modify existing entries in several methods and make sure that #1, you can apply it, and #2 after applying the game starts without errors.

Edit: Just saw your edit3, that still does not work.  Did you try plugging that into the regex101 link I gave? That includes a bunch of test cases, and it fails on the multi-line.  Is there something wrong with the one I've proposed? I've tested it against a wide variety of test cases and successfully used it in-game.