Jump to content

Need some help with custom characters


dkkkop

Recommended Posts

I made a simple mod, that adds a backpack to starting inventory
But it seems, that  this mod works only with default characters, and don't work with custom characters
How can i fix that

This is "modmain.lua"
 

local default_inv = {"backpack"} 
local function setStarterInventory(inst, custom_inv)
local st_inv = inst.components.inventory.starting_inventory
if (st_inv) then 
for k,v in pairs(default_inv) do
table.insert(st_inv, v)
end
else 
inst.components.inventory.starting_inventory = default_inv
end
if (custom_inv) then 
for k,v in pairs(custom_inv)  do
table.insert(inst.components.inventory.starting_inventory, v)
end
end
end
 
local function makePostInit(custom_inv)
return function (inst)
setStarterInventory(inst, custom_inv)
end
end
Link to comment
Share on other sites

If you can't just add it to the starter inventory, try using "AddSimPostInit". It's explained it a mod called "APIexamples" and runs when the player spawns in a newly created world. Then calculate random offset (as in other game files, "waxwelljournal" for example) and spawn a backpack.

You may need to add a "InCave" check. I could write it should you still struggle when I'm back in... ten hours...

Link to comment
Share on other sites

thx for your advise, will try to fix myself, if i'm not able to do that- will wait 10 hours though 


thx for your advise, will try to fix myself, if i'm not able to do that- will wait 10 hours though 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...