Jump to content

Custom Item - Bedroll


Recommended Posts

Im trying to make a character with a custom sleeping bag, but i dont know how to make one from scratch and after some effort and several general searches, it seems that i cant simply modify the base item and make it work.

 

I have already made the character, and gotten the art done, and the character code works, but i can get the sleeping bag coding to no cause a crash after character select due to the base coding appearently calling for information i havent included.

 

If anyone can help me out and give me a lead on how to start the coding so i make a new type of bedroll/sleeping bag, or what i need to modify from the base coding to make it happy, id appreciate it.

Link to comment
Share on other sites

 

 

I am new to lua / modding this game so someone else could probably help you with how to properly accomplish this but just looking at the game code here are some things you will probably want to have and need.

 

You will want to add the following code to your custom character

local function common_init(inst)inst:AddTag("sleepyhead")--rest of your codeend

then for your recipes.lua you will want to add...

Recipe("bedroll_junk", {Ingredient("gears", 1), Ingredient("rope", 1)}, RECIPETABS.SURVIVAL, TECH.SCIENCE_ONE, nil, nil, nil, nil, "sleepyhead")

now you need to go to strings.pot and add

#. STRINGS.RECIPE_DESC.BEDROLL_JUNKmsgctxt "STRINGS.RECIPE_DESC.BEDROLL_JUNK"msgid "Sleep through the night steam punk style."msgstr ""

and in strings.lua ...

        BEDROLL_STRAW = "Sleep through the night.",        BEDROLL_FURRY = "Sleep through the night in comfort!",        BEDROLL_JUNK = "Sleep through the night steam punk style."

then in each character speech file but especially your custom character you will want to search for BEDROLL_STRAW and below that add

BEDROLL_JUNK = "For some reason these gears really help my back.",

In bedroll.lua you will need to add to the very bottom like so...

return Prefab("common/inventory/bedroll_straw", bedroll_straw, straw_assets),    Prefab("common/inventory/bedroll_furry", bedroll_furry, furry_assets),  Prefab("common/inventory/bedroll_junk", bedroll_junk, junk_assets)

then on the top of bedroll.lua you will want to add your animation

local junk_assets ={    Asset("ANIM", "anim/swap_bedroll_junk.zip"),}

then in the same bedroll.lua you will see local function bedroll_furry() as an example but here is an idea for your custom bedroll

local function bedroll_junk()    local inst = common_fn("swap_bedroll_junk", "swap_bedroll_junk")    if not TheWorld.ismastersim then        return inst    end    --5 uses is 1 less than a tent and more than any portable sleeping item    inst:AddComponent("finiteuses")    inst.components.finiteuses:SetConsumption(ACTIONS.SLEEPIN, 1)    inst.components.finiteuses:SetMaxUses(5)    inst.components.finiteuses:SetUses(5)    -- normal straw bed is *.67 so this is a lot more sanity boost    inst.sanity_tick = TUNING.SLEEP_SANITY_PER_TICK    -- do not gain health when sleeping in junk bed    inst.components.sleepingbag.healthsleep = false    inst.onuse = onuse_junk    return instend

then you will need an onuse function like so...

local function onuse_junk(inst)    inst.AnimState:OverrideSymbol("swap_bedroll", "swap_bedroll_junk", "bedroll_junk")end
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
 Share

×
  • Create New...