Jump to content
  • 0

API to install upgrades, invokeFunction by script index


Rinart73

Suggestion

As you can see in this thread and few others, it appears, that:

If you have several scripts with the same script path, attached to the entity, you can call  'invokeFunction' only on first one.

 

Based on that, first suggestion is: please add a way to replace scriptName with scriptIndex when calling invokeFunction like we can do with 'removeScript' function.


Second suggestion is about installing upgrades. Currently modders can only remove them - they remove script and on C side upgrade disappears (from upgrades UI etc). But we can't install upgrade. We can add system upgrade to the entity, but it will not appear in the Upgrades Tab.

 

Update: Edited post, because you can specify script index in 'removeScript' function to remove specific script. But there is still no way to invoke function on a certain script.

 

Update: As of version 0.18.2 we can now install/uninstall upgrades. Thanks

Link to comment
Share on other sites

3 answers to this suggestion

Recommended Posts

  • 0

Yes please. Script indeces would be incredibly handy for not a small amount of use cases.

Apparently there is a way to remove entity scripts by indeces. I recently looked at the entitydbg.lua code to try to add more functionality and fix some stuff. And I found this:

function removeEntityScript(script)

    if onClient() then

        local entry = tonumber(scripts[scriptList.selected])
        if entry ~= nil then
            invokeServerFunction("removeEntityScript", entry)
            invokeServerFunction("sendEntityScripts", Player().index)
        end

        return
    end

    print("remove script " .. script)

    Entity():removeScript(tonumber(script))

    print("remove script done ")
end

Remember, entitydbg panel allows you to remove any script from sector or entity. It's just not specified in Documentation that we can use a number here.


But we still don't have a way to install upgrades.

Link to comment
Share on other sites

  • 0

Bump, because this is important.

 

Having a way to specify script index in "invokeFunction" will give players a way to work with multiple instances of the same script.

And having an API to install upgrades will allow modders to create functional solutions, that will be compatible with default Upgrade Tab.

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...