Jump to content

Recommended Posts

If >= 2 players use my custom character in the same server then the skill won't work unless all of them activate it.

I think the game use the same variable (local ZenRest, local MidStr, etc.) instead of individual variable for each of them? How can I fix this?

modmain.lua

oisaokuto.lua

Edited by Anstarveo
local MyComp = Class(function(self, inst)
    self.inst = inst
    self.myvariable = nil
    -- you can add as many vairables you like to
end)


function MyComp:OnSave()
    local data = {}
    data.myvariable = self.myvariable -- save variable
    return data
end

function MyComp:OnLoad(data)
    if data.myvariable ~= nil then
        self.myvariable = data.myvariable -- load my variable
    end
end


return MyComp

put this into a script in your mod folder scripts/components. Of course you can rename "MyComp" and "myvariable" to whatever you prefer, but the name of the file should be the same name like you chose for "MyComp"but in lower letters.
And in your characterfile you make "inst:AddComponent("MyComp")" where you also added other components (I guess it is in master_postinit.

Now whenever you change the value for your character change it with:
inst.components.mycomp.myvariable = x
 

Edited by Serpens

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