Page 1 of 1

Change saveSettings() to be more mod friendly

Posted: Wed Feb 20, 2013 4:22 am
by nate
I just managed to make a template for new graphical widgets in minimalist.lua, and check to notice that DarkGod's apparently just had a look in there, so I've got two comments:

1) saveSettings isn't mod (or maintenance) friendly, because it looks for specific fields ("player", "toolbar", "resources", etc) rather than writing all fields. That means that mods that want to introduce graphical widgets need to alter this function, right in the middle of the function, and so it's really tough to make them all play well together. I don't know how to fix it myself, but given the apparent power of Lua, I'd wager it's fixable.

2) Very very minor point, but desc_fct is a misleading choice of name, since anything you do on mouse-over (scaling or moving, for instance) has to occur in that function. mouseover_fct would be a better choice. Not a big deal, because mod authors can pick any name they want for that function when they use it, but for figuring out the code, better naming would be nice.

It's given me a real headache to trace this stuff out, but that's just because I'm new to it. I have to express my admiration to all of the coders (not just DarkGod?) for what is very readable, very clear code. Other than saveSettings, everything to make another widget can be easily superloaded.

Re: Change saveSettings() to be more mod friendly

Posted: Thu Feb 21, 2013 11:45 pm
by darkgod
I added a new hook UISet:Minimalist:saveSettings

Re: Change saveSettings() to be more mod friendly

Posted: Sun Feb 24, 2013 10:20 am
by nate
I see now that what I had in mind (writing all game.uiset.places[][] rather than specific places[][]) isn't good because it screws up the default game (errors on boundPlaces, maybe later too if boundPlaces got changed, because of unknown values). Writing something to settings/tome.uiset_minimalist other than .places (I tried .nateplaces = {}, .nateplaces.x = etc) didn't end up working-- not sure if there's something sitting in-between the .cfgs and game code that keeps it from getting through. The solution that ended up working for me was to use a different file extension for files that I wrote (don't get loaded by plain tome if they're not .cfg), but I'm not sure if that's the solution you'd like mod authors to settle on. Even with a hook, they'd have to do something like that.