How to make functions in tables and have them sync

I've seen Battle and RSNEO have functions stored in tables, so I tried putting my own functions in tables for something I've been working on, but when playing online, they won't archive. I tried looking in the wiki, then I tried using rawset to get to the actual weapon table like RSNEO, to looking at slingfunc itself, to eventually just using the RSNEO addweapon function to see if that would even work, but I haven't gotten it to work, is there a specific way I'm supposed to do it?
 
I'm not familiar with RSNEO nor Battle, but could you be a little more specific? Because...
I tried using rawset to get to the actual weapon table like RSNEO
This should be working. And from the little tests I ran before replying the concept worked fine?

Lua:
local localTestTable = {
    func1 = function(x) print(x) end,
    func2 = function(x) print(x .. " 2") end
}

if not globalTestTable then rawset(_G, "globalTestTable", localTestTable) end

addHook("JumpSpinSpecial", function(player)
    -- You can call the functions like globalTestTable['func1'](parameter) as well.
    globalTestTable.func1(player.mo.skin)
    globalTestTable.func2(player.mo.skin)
end)

ezgif-5-1e0117d0fe.gif
ezgif-5-2fad701c76.gif

If that's not what you meant could you try to fill me in a little more?
Post automatically merged:

I'm not familiar with RSNEO nor Battle, but could you be a little more specific? Because...
I tried using rawset to get to the actual weapon table like RSNEO
This should be working. And from the little tests I ran before replying the concept worked fine?

Lua:
local localTestTable = {
    func1 = function(x) print(x) end,
    func2 = function(x) print(x .. " 2") end
}

if not globalTestTable then rawset(_G, "globalTestTable", localTestTable) end

addHook("JumpSpinSpecial", function(player)
    -- You can call the functions like globalTestTable['func1'](parameter) as well.
    globalTestTable.func1(player.mo.skin)
    globalTestTable.func2(player.mo.skin)
end)

ezgif-5-1e0117d0fe.gif
ezgif-5-2fad701c76.gif

If that's not what you meant could you try to fill me in a little more?
 
I'm not familiar with RSNEO nor Battle, but could you be a little more specific? Because...

This should be working. And from the little tests I ran before replying the concept worked fine?

Lua:
local localTestTable = {
    func1 = function(x) print(x) end,
    func2 = function(x) print(x .. " 2") end
}

if not globalTestTable then rawset(_G, "globalTestTable", localTestTable) end

addHook("JumpSpinSpecial", function(player)
    -- You can call the functions like globalTestTable['func1'](parameter) as well.
    globalTestTable.func1(player.mo.skin)
    globalTestTable.func2(player.mo.skin)
end)

View attachment 86119View attachment 86120

If that's not what you meant could you try to fill me in a little more?
Post automatically merged:

I'm not familiar with RSNEO nor Battle, but could you be a little more specific? Because...

This should be working. And from the little tests I ran before replying the concept worked fine?

Lua:
local localTestTable = {
    func1 = function(x) print(x) end,
    func2 = function(x) print(x .. " 2") end
}

if not globalTestTable then rawset(_G, "globalTestTable", localTestTable) end

addHook("JumpSpinSpecial", function(player)
    -- You can call the functions like globalTestTable['func1'](parameter) as well.
    globalTestTable.func1(player.mo.skin)
    globalTestTable.func2(player.mo.skin)
end)

View attachment 86119View attachment 86120

If that's not what you meant could you try to fill me in a little more?
That was one of the ways I was trying to fix my problem, but it didn't work. I keep getting function archive errors because of the functions but when I load RSNEO, there's never been a single one.
Here's an example of what my table looked like before I was messing with it

Lua:
rawset(_G, "RingTest", {})

RingTest.Weapons = {
    
    // Red Rings //
    regular = {
        name = "Normal Ring",
        object = MT_REDRING,
        delay = TICRATE/2,
        flags2 = 0,
        hud = "RINGIND",
        damage = 19,
        rfunction = function(player, mo)
            print("hello")
        end,
    },
}
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top