Page 1 of 1

Editing Existing Objects in Lua

Posted: Sat Jul 06, 2019 6:38 am
by Taycott
I'm a bit lost on how I might be able to edit existing weapons and abilities in Lua. The test mod demonstrates how to define a new weapon or ability, but the only way I've found to edit an existing weapon, ability, or hero is to re-define them with def_weapon, ability, or object using the same name as the vanilla definition but with different variable values.

This works fine for modifying heroes because their vanilla definitions have been provided in the Asset Pack, but I can't seem to find weapon or ability definitions in any of the provided documentation. Is this something that might be available in a future Asset Pack?
Or perhaps there's a function that I'm unaware of that would allow me to edit a specific variable for an already defined object.

For example, to modify the Warden's starting abilities I can use def_object to define a new object with name="hero" and copy all the other variables from the Warden's definition in the Asset Pack, but change the "abilities" variable. This cannot be done however for weapons or abilities because their definitions are not available (as far as I can tell).

Sorry if I'm missing something really simple here, but I should be able to begin implementing the kinds of mods that I was hoping to make once I figure this out. Thanks in advance for any advice :)

Re: Editing Existing Objects in Lua

Posted: Sat Jul 06, 2019 3:33 pm
by petri
Hi and welcome! I've just added the missing card definitions to the asset pack. Beware! The card definitions use slightly different versions of def_xxx() functions because the code was written well before modding support was added to the game. See the remarks at the beginning of cards.lua.

Also regarding modifying Warden's ability list: it's probably better to use clone_object() (I think this is demoed in testmod), because it allows overriding just the properties that you actually want to change without duplicating all the fields from objdefs.lua.

Hope these help to get you started!

Re: Editing Existing Objects in Lua

Posted: Sat Jul 06, 2019 8:56 pm
by Taycott
Perfect, thanks for the quick reply! This is exactly what I've been missing.

Re: Editing Existing Objects in Lua

Posted: Sun Jul 07, 2019 7:33 am
by Taycott
I've been able to make some progress using def_aux_card() to modify variables from cards.lua, but it seems that in order to make more advanced changes or additions I would need to script the basic functionality of an ability from scratch in order to change it.

For example, if I wished to add a gem upgrade to "Mind Control" which forces the target to perform "Advance" instead of just performing their primary attack, I would need to write my own function for "Mind Control" with a slight alteration to allow for my new upgrade.

If I had access to the source code for these functions this process would be significantly easier because I expect there already exists a function for "Mind Control" that I could alter slightly to achieve my intended effect. This type of function is demonstrated in testmod in the creation of a new centipede with a freeze attack, but I can't find anything similar elsewhere. Is there perhaps an additional file containing these detailed ability functions that us modders could have access to?

No worries if you're not able to respond to this request anytime soon, I still need to acquaint myself with the level editor :)
Anyway, thank you for hearing me out!