Jump to content

Recommended Posts

So I want to create a bundle and give it inst.name "hostage".
I created a file in script/prefab and include comments like

local bundle = SpawnPrefab"bundle"
    bundle.components.unwrappable:WrapItems({inst}, doer)
    bundle:SetTitle("Hostage")
    bundle:AddComponent"tradable"
        inst:Remove()

Then I go to the modmain and wrote

APPI("bundle", function(inst)
    local OnLoad, OnSave = inst.OnLoad, inst.OnSave
    inst.OnLoad = function(inst, data)
        if data and data.title 
                then inst:SetTitle(data.title) end 
        if OnLoad 
                then return OnLoad(inst, data) end 
    end
    inst.OnSave = function(inst, data)
        if inst.title 
                then data.title = inst.title end 
        if OnSave 
                then return OnSave(inst, data) end 
    end
        inst.SetTitle = function(inst, name)
        inst.name = name
    end

it worked perfectly, but now I want to give the bundle a tradable component.
Put it in script, when log on/off it doesn't work anymore; if put in modmain it makes all bundle tradable (only want bundle with name "hostage").
Can someone help me into how to put the component correctly in my OnLoad/OnSave part?
(Its singleyplayer so it may look a little bit weird and don't say post it there its dead lol)

Edited by Last_epilogue
24 minutes ago, Rickzzs said:

Why don't you create a new prefab using

local function fn()
  local bundle=Prefabs.bundle.fn()
  return bundle
end
return Prefab("hostage"

Are u suggesting me create a new file naming bundle.lua, or I use it to replace what I typed above? Here's my file for u if this can help! I was modding an action called "snare".

snarable.lua snaring.lua

9 hours ago, Last_epilogue said:

Are u suggesting me create a new file naming bundle.lua, or I use it to replace what I typed above? Here's my file for u if this can help! I was modding an action called "snare".

snarable.lua 1.17 kB · 0 downloads snaring.lua 337 B · 0 downloads

I suggest you created a new prefab hostage if you want to rename a bundle that does not have a new component. And if you want to save data, the most convenient way is creating a prefab.

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