kivviz Posted January 7, 2015 Share Posted January 7, 2015 PrefabFiles = { "marty", "backpackm",} Assets = { Asset( "IMAGE", "images/saveslot_portraits/marty.tex" ), Asset( "ATLAS", "images/saveslot_portraits/marty.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/marty.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/marty.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/marty_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/marty_silho.xml" ), Asset( "IMAGE", "bigportraits/marty.tex" ), Asset( "ATLAS", "bigportraits/marty.xml" ), Asset( "IMAGE", "images/map_icons/marty.tex" ), Asset( "ATLAS", "images/map_icons/marty.xml" ), Asset( "IMAGE", "images/avatars/avatar_marty.tex" ), Asset( "ATLAS", "images/avatars/avatar_marty.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_marty.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_marty.xml" ),} AddMinimapAtlas("images/marty.xml") -- strings! Any "marty" below would have to be replaced by the prefab name of your character. -- The character select screen lines-- note: these are lower-case character nameGLOBAL.STRINGS.CHARACTER_TITLES.marty = "Traveller"GLOBAL.STRINGS.CHARACTER_NAMES.marty = "Marty" -- Note! This line is especially important as some parts of the game require -- the character to have a valid name.GLOBAL.STRINGS.CHARACTER_DESCRIPTIONS.marty = "*Likes to run and travel\n*Maybe do a backpack on start\n*Loves berries"GLOBAL.STRINGS.CHARACTER_QUOTES.marty = "\"We will travel?\"" -- You can also add any kind of custom dialogue that you would like. Don't forget to make-- categores that don't exist yet using = {}-- note: these are UPPER-CASE charcacter name--GLOBAL.STRINGS.CHARACTERS.marty = {}--GLOBAL.STRINGS.CHARACTERS.marty.DESCRIBE = {}--GLOBAL.STRINGS.CHARACTERS.marty.DESCRIBE.EVERGREEN = "A template description of a tree."local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSGLOBAL.STRINGS.CHARACTERS.MARTY = require "speech_marty" -- DST STRINGS.NAMES.MARTY = "Marty"STRINGS.CHARACTERS.GENERIC.DESCRIBE.MARTY = { GENERIC = "Berries now!", ATTACKER = "Back off!", MURDERER = "You are murder!", REVIVER = "Friend of ghosts", GHOST = "Wow, ghost, yay",} -- Let the game know marty is a male, for proper pronouns during the end-game sequence.-- Possible genders here are MALE, FEMALE, or ROBOTtable.insert(GLOBAL.CHARACTER_GENDERS.MALE, "marty") AddMinimapAtlas("images/map_icons/marty.xml") { Recipe("backpackm", {Ingredient("trunk_summer", 1), Ingredient("silk", 10)}, RECIPETABS.WAR, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0}, nil, nil, nil, nil, true),} AddModCharacter("marty")BackPack:local assets ={ Asset("ANIM", "anim/backpackm.zip"), Asset("ANIM", "anim/swap_backpackm.zip"), Asset("ATLAS", "images/inventoryimages/backpackm.xml"),}local function onequip(inst, owner) --owner.AnimState:OverrideSymbol("swap_body", "swap_backpack", "backpack") owner.AnimState:OverrideSymbol("swap_body", "swap_backpackm", "swap_body") owner.components.inventory:SetOverflow(inst) inst.components.container:Open(owner)endlocal function onunequip(inst, owner) --owner.AnimState:ClearOverrideSymbol("backpack") owner.AnimState:ClearOverrideSymbol("swap_body") owner.components.inventory:SetOverflow(nil) inst.components.container:Close(owner)endlocal function onopen(inst) inst.SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")endlocal function onclose(inst) inst.SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")endlocal slotpos = {}for y = 0, 5 do table.insert(slotpos, Vector3(-162, -y*75 + 170 ,0)) table.insert(slotpos, Vector3(-162 +75, -y*75 + 170 ,0))endlocal function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) inst.AnimState:SetBank("backpackm") inst.AnimState:SetBuild("backpackm") inst.AnimState:PlayAnimation("anim") inst:AddTag("backpack") local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon("backpackm.tex") inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "backpackm" inst.components.inventoryitem.atlasname = "images/inventoryimages/backpackm.xml" inst.components.inventoryitem.cangoincontainer = false inst.components.inventoryitem.foleysound = "dontstarve/movement/foley/backpack" inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY if EQUIPSLOTS["PACK"] then inst.components.equippable.equipslot = EQUIPSLOTS.PACK else inst.components.equippable.equipslot = EQUIPSLOTS.BODY end inst.components.equippable:SetOnEquip( onequip ) inst.components.equippable:SetOnUnequip( onunequip ) inst.components.locomotor.walkspeed = 2 inst.components.locomotor.runspeed = 2 -- inst:AddComponent("waterproofer") -- inst.components.waterproofer.effectiveness = 0 inst:AddComponent("container") inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetanimbank = "ui_piggyback_2x6" inst.components.container.widgetanimbuild = "ui_piggyback_2x6" inst.components.container.widgetpos = Vector3(-5,-90,0) inst.components.container.side_widget = true inst.components.container.type = "pack" inst.components.container.onopenfn = onopen inst.components.container.onclosefn = onclose return instendreturn Prefab( "common/inventory/backpackm", fn, assets) >What I not so do? >Why mistake? Link to comment https://forums.kleientertainment.com/forums/topic/48591-problem-with-a-backpack/ Share on other sites More sharing options...
Sarcen Posted January 7, 2015 Share Posted January 7, 2015 RECIPETABS is nil, i assume its a global variable so it should be GLOBAL.RECIPETABS, this should be done for all global variables inside the modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/48591-problem-with-a-backpack/#findComment-598143 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