MillaBasset Posted April 13, 2017 Share Posted April 13, 2017 (edited) Hello! So... Lua is new to me and I am currently doing my own character for Dont Starve Together. Because my friends have more character focused of supporting and to surrive, i wanted to make a more "offensive" character. After a long time I thought about a robot who is a furnace and eat wood / twigs /grass and e.t.c. But currently my biggest problem is to add the food or to be more specific the code (which i think is working from other topics) crashes my game upon loading the character: Spoiler It is pretty obvious that a "(" is missing, so of course i added on: Spoiler Then that happend. I tried to copy the original script (cus I am still a newb in Lua). I would like to the what-ever-is-called clean way (adding stuffs in mainmod instead of adding more lua files) for future mods. Here is the code from Mainmod(with the barcket removed to original) : Spoiler PrefabFiles = { "esctemplate", "esctemplate_none", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/esctemplate.tex" ), Asset( "ATLAS", "images/saveslot_portraits/esctemplate.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/esctemplate.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/esctemplate.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/esctemplate_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/esctemplate_silho.xml" ), Asset( "IMAGE", "bigportraits/esctemplate.tex" ), Asset( "ATLAS", "bigportraits/esctemplate.xml" ), Asset( "IMAGE", "images/map_icons/esctemplate.tex" ), Asset( "ATLAS", "images/map_icons/esctemplate.xml" ), Asset( "IMAGE", "images/avatars/avatar_esctemplate.tex" ), Asset( "ATLAS", "images/avatars/avatar_esctemplate.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_esctemplate.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_esctemplate.xml" ), Asset( "IMAGE", "images/avatars/self_inspect_esctemplate.tex" ), Asset( "ATLAS", "images/avatars/self_inspect_esctemplate.xml" ), Asset( "IMAGE", "images/names_esctemplate.tex" ), Asset( "ATLAS", "images/names_esctemplate.xml" ), Asset( "IMAGE", "bigportraits/esctemplate_none.tex" ), Asset( "ATLAS", "bigportraits/esctemplate_none.xml" ), } local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS -- The character select screen lines STRINGS.CHARACTER_TITLES.esctemplate = "The Sample Character" STRINGS.CHARACTER_NAMES.esctemplate = "Esc" STRINGS.CHARACTER_DESCRIPTIONS.esctemplate = "*Perk 1\n*Perk 2\n*Perk 3" STRINGS.CHARACTER_QUOTES.esctemplate = "\"Quote\"" -- Custom speech strings STRINGS.CHARACTERS.ESCTEMPLATE = require "speech_esctemplate" -- The character's name as appears in-game STRINGS.NAMES.ESCTEMPLATE = "Esc" AddMinimapAtlas("images/map_icons/esctemplate.xml") -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL. AddModCharacter("esctemplate", "ROBOT") AddPrefabPostInit("Log", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BUURN inst.components.edible.healthvalue = 5 inst.components.edible.sanityvalue = 5 inst.components.edible.hungervalue = 15 end AddPrefabPostInit("Grass", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.NATURE inst.components.edible.healthvalue = 0 inst.components.edible.sanityvalue = 0 inst.components.edible.hungervalue = 2 end AddPrefabPostInit("Twigs", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.NATURE inst.components.edible.healthvalue = 0 inst.components.edible.sanityvalue = 0 inst.components.edible.hungervalue = 2 end AddPrefabPostInit("Armor_grass", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BUURN inst.components.edible.healthvalue = 5 inst.components.edible.sanityvalue = 10 inst.components.edible.hungervalue = 20 end AddPrefabPostInit("Armor_Wood", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BUURN inst.components.edible.healthvalue = 5 inst.components.edible.sanityvalue = 15 inst.components.edible.hungervalue = 50 end AddPrefabPostInit("Boards", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BUURN inst.components.edible.healthvalue = 10 inst.components.edible.sanityvalue = 10 inst.components.edible.hungervalue = 30 end AddPrefabPostInit("Brush", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BUURN inst.components.edible.healthvalue = 20 inst.components.edible.sanityvalue = 2 inst.components.edible.hungervalue = 20 end AddPrefabPostInit("Papyrus", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.NATURE inst.components.edible.healthvalue = 0 inst.components.edible.sanityvalue = 10 inst.components.edible.hungervalue = 10 end The Mainmod.lua is currently the most important think for me to fix first. I am totally aware of the error in the player.lua. (If you want to help me with the player.lua i would be grateful) Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting items local start_inv = { } -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when reviving from ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "esctemplate_speed_mod", 0.9) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "esctemplate_speed_mod") end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "esctemplate.tex" ) end local function getmultfn(inst, food, original_value) local mult = 1 if food.components.edible then if food:HasTag("preparedfood") then mult = 0.5 elseif food.prefab:find("cooked") then mult = 0.5 elseif food.prefab:find("dried") then mult = 0.5 elseif not food.prefab:find("dried") and not food.prefab:find("cooked") then mult = 0.5 end end end local function applyupgrades(inst) local max_upgrades = 15 inst.level = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil (125 + inst.level *7) --230 inst.components.health.maxhealth = math.ceil (150 + inst.level * 7) --255 inst.components.sanity.max = math.ceil (170 + inst.level * 2) --200 if inst.level < 2 then inst.components.combat.damagemultiplier = 1.1 inst.components.talker:Say("SYSTEM REPAIRED") end if inst.level > 3 then inst.components.talker:Say("POWER UP") end if inst.level > 5 then inst.components.health.absorb = (0.10) end if inst.level > 14 then inst.components.talker:Say("SYSTEM OPTIMIZED") end inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent) end local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") -- MarkL Can't do this here, need to do it inside the components -- todo pax Move upgrade logic elsewhere. --inst.HUD.controls.status.heart:PulseGreen() --inst.HUD.controls.status.stomach:PulseGreen() --inst.HUD.controls.status.brain:PulseGreen() --inst.HUD.controls.status.brain:ScaleTo(1.3,1,.7) --inst.HUD.controls.status.heart:ScaleTo(1.3,1,.7) --inst.HUD.controls.status.stomach:ScaleTo(1.3,1,.7) end inst.Soundemitter:PlaySound("dontstarve/common/fireAddFuel") if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.BUURN then inst.Light:SetIntensity(.8) inst.Light:SetRadius(.5) inst.Light:SetFalloff(.65) inst.Light:SetColour(255 / 255, 255 / 255, 236 / 255) inst.Light:Enable(false) inst.temperature:added= temperature+2 else end end local function IsOverheating(inst) if temperature > 50 then inst.components.damagemultiplier:SetMax(1.2) elseif temperature > 65 then inst.components.damagemultiplier:SetMax(1.3) end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "esctemplate.tex" ) end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "wx78" inst.components.IsOverheating() -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" inst.level = 0 -- Stats inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(125) inst.components.sanity:SetMax(150) inst.components.eater.foodprefs = { FOODTYPE.BUURN, FOODTYPE.NATURE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.MEAT, FOODTYPE.GENERIC,} inst.components.eater.ignoresspoilage = true inst.components.eater:SetCanEatGears() inst.components.eater:SetOnEatFn(oneat) applyupgrades(inst) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE end return MakePlayerCharacter("esctemplate", prefabs, assets, common_postinit, master_postinit, start_inv) To finish my little novel, I really appreciate any help and future tips for modding and to erase the mistake from the Mainmod. Cheers, Millabasset Edited April 13, 2017 by MillaBasset Fixed Link to comment Share on other sites More sharing options...
Aquaterion Posted April 13, 2017 Share Posted April 13, 2017 all your AddPrefabPostInit are missing the ) at the end of the whole line. example: red is what's missing, green is the bracket that is related to the missing red bracket AddPrefabPostInit("Log", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BUURN inst.components.edible.healthvalue = 5 inst.components.edible.sanityvalue = 5 inst.components.edible.hungervalue = 15 end) Link to comment Share on other sites More sharing options...
MillaBasset Posted April 13, 2017 Author Share Posted April 13, 2017 Huh... You have my thanks. I also found out what i was doing wrong. I closed the bracket but removed the end (even placed it outside one time) but damn, after all this despairment such little thing changed everything. But real talk now, Thank you very much. I have no idea why i never tried letting the end in. i tried so many locations to close the bracket, but sometimes the simple thinks are the correct one Also Thanks for this quick answer 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