Modding Help Is there no way to overwrite lua?

Discussion in 'Starbound Modding' started by tio200, Jun 23, 2017.

  1. tio200

    tio200 Void-Bound Voyager

    I was planning to make a mod that uses mech horn slot as weapons and such but it seems that I need to change the lua about the mech.

    Is there any way to overwrite or patch the lua? Either that, or any modding advice would be nice.
  2. Errors4l

    Errors4l Spaceman Spiff

    You can overwrite scripts simply by putting the same scripts in your mod. Note that this may lead to mod conflicts as Lua scripts can't be patched, and only the 'last' loaded version of the script will be used (which may or may not be yours).
  3. Inf_Wolf14

    Inf_Wolf14 Parsec Taste Tester

    You can create a patch to the mech itself to point to an alternate script you would then provide.
    Of course, should another mod change and/or also patch a new script, you can expect some obvious difficulties.
  4. Mobius58

    Mobius58 Void-Bound Voyager

    You can the best way is to write a separate lua file for the changes you want to make and then make a patch that would include the script where the lua script you want to mod is being used. You should do it like this so you can limit the number of changes you make to the lua script and thus increase compatibility with other mods and helps with keeping the mod working across updates.

    If you are not removing methods or function calls then you can do something like this:

    oldfunction = originalfunction

    function originalfunction(variables)
    your code here
    maybe more of your code here

    This can further increase compatibility with other mods because now you are limiting your changes to specific variables in the script at worst or you could be adding your own variables and function calls which should not conflict with other mods if you name them properly

    If another mod is also patching the same script if they use this method it most likely will be fine if they are not editing the same variable but if they are just completely replacing the script or function you should still be fine as long as you mod is loaded after theirs.
  5. tio200

    tio200 Void-Bound Voyager

    Thanks for all the help, guys. I did started working on the mod I was trying to make and was able to get the new lua running for the mech, but it kept getting crashes when using the custom weaponized horn. Hmm... I think I should try Mobius58's way one more time.
  6. tio200

    tio200 Void-Bound Voyager

    OK I was just trying to do what you said, but how do I add one more script on this? This is the sample of the original 'modularmech.vehicle'

    "name" : "modularmech",
    "boundBox" : [-32.0, -32.0, 32.0, 32.0],
    "slaveControlTimeout" : 2.0,
    "slaveControlHeartbeat" : 1.0,
    "canBeHit" : true,

    "keepAlive" : true,
    "persistent" : false,
    "clientEntityMode" : "ClientMasterAllowed",

    "script" : "/vehicles/modularmech/modularmech.lua",
    "scriptDelta" : 1,

    "animation" : "/vehicles/modularmech/modularmech.animation",
    and so on.....

    Um... Do I just add? Or do I have to fix the scriptDelta too? (What is it by the way?!)
  7. Errors4l

    Errors4l Spaceman Spiff

    Some assets use a "scripts" parameter, rather than a "script" parameter, which is an array of strings rather than a single string.
    You can try replacing the script line with a scripts array, but chances are high it won't work.
    "scripts": [
  8. tio200

    tio200 Void-Bound Voyager

    Tried it but didn't work. In fact, it seems that the only choice I have is to overwrite modularmech.lua itself and even that does not prove to work :(

    I think I shall let this go and work on more simpler mod I had in mind. Anyway, thanks for all the help!

Share This Page