Xelitoth Posted August 21, 2015 Share Posted August 21, 2015 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 More sharing options...
NoQuitting Posted August 22, 2015 Share Posted August 22, 2015 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 characterlocal function common_init(inst)inst:AddTag("sleepyhead")--rest of your codeendthen 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 addBEDROLL_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 animationlocal 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 bedrolllocal 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 instendthen 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 More sharing options...
Xelitoth Posted August 22, 2015 Author Share Posted August 22, 2015 ok, so id just want to insert new code into the base file rather then make a new item then? if so how do i make my mod modify existing base files? (completely new at this, first mod) Link to comment Share on other sites More sharing options...
Xelitoth Posted August 25, 2015 Author Share Posted August 25, 2015 I think i need to use some combination of "AddPrefabPostInit" or "AddComponentPostInit" to make these changes, but im unsure exactly how to. If someone could help me out a bit id appreciate it very much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now