Jump to content

Modding existing scripts


Tanksy

Recommended Posts

When modifying scripts, can you place a separate script that overwrites the existing script when the game loads or must you overwrite the original file? Is there a way to overwrite existing functions with your own?

 

I would like a clear explanation of the scripting process, where to put custom scripts, and if you can make say, a custom script that adds a type of asteroid that can be generated, without modifying the original asteroid generation scripts. So far we have barely any documentation apart from the API documents that aren't complete, and the posts by the developer talking about how custom functions are ran and how scripts can be attached to entities. Is modding the original scripts to add in extra functions at all possible without overwriting original files to keep things working alongside other mods?

Link to comment
Share on other sites

Depends on the script

 

If the new scripts runs after the one with the original code, yes. ( per execute )

 

 

Adding things beneath a function without deleting it:

function actual_func( ply )
    print( "hi" )
end
local old_func =  actual_func( ... )      -- basically you know the parameters, but we cant define them here. Let's call it placeholder.

function myfunc()
    print("hey, how are you?" )
end


function old_func( ply )
    myfunc()
end

 

Output:

Hi
hey, how are you?

 

Btw this is very experimental, and i dont recommend to use this.

Why would you even overwrite a function?

Mostly you use this to hook into function's, that are hardcoded like "addScript()" for a super noobish CheatProtection or logging.

 

You can still call things like "addMetheor..." if you required that file.

There are many things you just can't edit, without overhaul the default code.

 

Hooking in a default function isn't always that good, if the function returns something important and you return just before that in your function, the old one is broken. That causes errors and leads to disfunctionallity.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...