AkaiNight Posted March 16, 2018 Share Posted March 16, 2018 Well i am making a custom character and i want to make my character can't eat anything except fish,fishtacos, fishsticks, ice, fish_cooked. Is is possible? And how can i do this? Thanks for helping. Link to comment Share on other sites More sharing options...
BraveChicken Posted March 18, 2018 Share Posted March 18, 2018 I believe the fastest way to do that would be adding new "food type" to your character (instead of running through all of the existing foods in the game to set them as "uneatable") It's pretty simple. Go to your character's prefab file and add this along with your character's other stats: inst.components.eater.ablefoods = { "NOMS" } inst.components.eater.foodprefs = { "NOMS" } (You can of course change the "NOMS" to whatever other name you want to give them XD it doesn't really matter.) Then head to your modmain.lua and add this: GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("fish", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "NOMS" end end) AddPrefabPostInit("fishsticks", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "NOMS" end end) and so on... I hope this helps. And good luck! ^-^ Link to comment Share on other sites More sharing options...
AkaiNight Posted March 18, 2018 Author Share Posted March 18, 2018 2 hours ago, BraveChicken said: I believe the fastest way to do that would be adding new "food type" to your character (instead of running through all of the existing foods in the game to set them as "uneatable") It's pretty simple. Go to your character's prefab file and add this along with your character's other stats: inst.components.eater.ablefoods = { "NOMS" } inst.components.eater.foodprefs = { "NOMS" } (You can of course change the "NOMS" to whatever other name you want to give them XD it doesn't really matter.) Then head to your modmain.lua and add this: GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("fish", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "NOMS" end end) AddPrefabPostInit("fishsticks", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "NOMS" end end) and so on... I hope this helps. And good luck! ^-^ Thank you very much Link to comment Share on other sites More sharing options...
AkaiNight Posted March 22, 2018 Author Share Posted March 22, 2018 On 18.03.2018 at 2:19 PM, BraveChicken said: I believe the fastest way to do that would be adding new "food type" to your character (instead of running through all of the existing foods in the game to set them as "uneatable") It's pretty simple. Go to your character's prefab file and add this along with your character's other stats: inst.components.eater.ablefoods = { "NOMS" } inst.components.eater.foodprefs = { "NOMS" } (You can of course change the "NOMS" to whatever other name you want to give them XD it doesn't really matter.) Then head to your modmain.lua and add this: GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("fish", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "NOMS" end end) AddPrefabPostInit("fishsticks", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "NOMS" end end) and so on... I hope this helps. And good luck! ^-^ Well i did but i had a few errors i handled some of them but i can't figure this out. I hope that you can help me here is error. If you need more information let me know. [string "scripts/mainfunctions.lua"]:147: Error loading file prefabs/alishia no file '../mods/alishia/scripts/prefabs/alishia.lua' (checked with custom loader) no file 'scripts/prefabs/alishia.lua' (checked with custom loader) no file 'scriptlibs/prefabs/alishia.lua' (checked with custom loader) no file 'scripts/prefabs/alishia.lua' (checked with custom loader) LUA ERROR stack traceback: =[C] in function 'assert' scripts/mainfunctions.lua(147,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(598,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(267,1) in function 'LoadAssets' scripts/gamelogic.lua(865,1) =[C] in function 'SetPersistentString' scripts/saveindex.lua(176,1) in function 'Save' scripts/saveindex.lua(366,1) =[C] in function 'SerializeWorldSession' scripts/networking.lua(280,1) in function 'SerializeWorldSession' scripts/saveindex.lua(369,1) in function 'OnGenerateNewWorld' scripts/gamelogic.lua(876,1) in function 'cb' scripts/screens/worldgenscreen.lua(152,1) in function 'OnUpdate' scripts/frontend.lua(654,1) in function 'Update' scripts/update.lua(92,1) [00:00:35]: Disabling alishia (Alisia FrostFox) because it had an error. Link to comment Share on other sites More sharing options...
BraveChicken Posted March 23, 2018 Share Posted March 23, 2018 13 hours ago, AkaiNight said: Well i did but i had a few errors i handled some of them but i can't figure this out. I hope that you can help me here is error. If you need more information let me know It looks like your game can't find the prefab file "alishia". It happens when the file is called in your modmain.lua in the PrefabFiles = { } section but the file either don't exist in your prefabs file folder or has it's name changed. Check in your modmain.lua if the right prefab files are called in the PrefabFiles section, and the name of your prefab file and folders. It's probably just a typo somewhere. If you'll keep on having that problem with your mod then you can send it over to me and I'll try to fix it. (If you want) Link to comment Share on other sites More sharing options...
AkaiNight Posted March 23, 2018 Author Share Posted March 23, 2018 Well i handle it but there was too many errors and i'm fixing them somehow. But this one i didin't understand anything. The error says "then" needed near "=" but there is a then near it. So here is the error and the code. local function critter_SanityAura(inst) local x, y, z = inst.Transform:GetWorldPosition() local delta = 0 local ents = TheSim:FindEntities(x, y, z, 20, {"critter_puppy", "player", "critter_kitten"}) local bonus_sanity = nil local distsq = nil local totalDelta= nil for k, v in pairs(ents) do if v = inst then (THIS ONE IS 190. LINE) if v.prefab =="critter_puppy" then bonus_sanity = -TUNING.SANITYAURA_MEDIUM distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta +bonus sanity / distsq elseif v.prefab == "critter_kitten" then bonus_sanity = TUNING:SANITYAURA_SMALL distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq elseif v:HasTag ("player") then bonus_sanity = -TUNING.SANITY_SMALL distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq else end end totalDelta =totalDelta + delta end if #ents > 0 then totalDelta = totalDelta / #ents else totalDelta = 0 end return totalDelta end [00:00:24]: [string "scripts/mainfunctions.lua"]:147: Error loading file prefabs/alishia [string "../mods/alishia/scripts/prefabs/alishia.lua"]:190: 'then' expected near '=' LUA ERROR stack traceback: =[C] in function 'assert' scripts/mainfunctions.lua(147,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) scripts/mods.lua(598,1) in function 'RegisterPrefabs' scripts/gamelogic.lua(267,1) in function 'LoadAssets' scripts/gamelogic.lua(851,1) in function 'cb' scripts/saveindex.lua(285,1) =[C] in function 'GetPersistentString' scripts/saveindex.lua(267,1) in function 'GetSaveDataFile' ... =[C] in function 'GetPersistentString' scripts/saveindex.lua(250,1) in function 'Load' scripts/gamelogic.lua(1053,1) in function 'callback' scripts/playerprofile.lua(977,1) in function 'Set' scripts/playerprofile.lua(838,1) =[C] in function 'GetPersistentString' scripts/playerprofile.lua(836,1) in function 'Load' scripts/gamelogic.lua(1052,1) in main chunk =[C] in function 'require' scripts/mainfunctions.lua(874,1) also i find something like this. [00:00:32]: Warning: GetPlayer() is deprecated. Please use ThePlayer instead. (@../mods/alishia/modmain.lua:224 in ?) [00:00:32]: error calling PrefabPostInit: chester_eyebone in mod alishia (Alisia FrostFox): [string "../mods/alishia/modmain.lua"]:224: attempt to index a nil value LUA ERROR stack traceback: ../mods/alishia/modmain.lua(224,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) in function 'mod' scripts/mainfunctions.lua(216,1) =[C] in function 'SpawnPrefab' scripts/mainfunctions.lua(255,1) in function 'SpawnPrefab' scripts/mainfunctions.lua(261,1) in function 'SpawnSaveRecord' scripts/gamelogic.lua(482,1) in function 'PopulateWorld' scripts/gamelogic.lua(732,1) in function 'DoInitGame' scripts/gamelogic.lua(852,1) in function 'cb' ... =[C] in function 'GetPersistentString' scripts/saveindex.lua(250,1) in function 'Load' scripts/gamelogic.lua(1053,1) in function 'callback' scripts/playerprofile.lua(977,1) in function 'Set' scripts/playerprofile.lua(838,1) =[C] in function 'GetPersistentString' scripts/playerprofile.lua(836,1) in function 'Load' scripts/gamelogic.lua(1052,1) in main chunk =[C] in function 'require' scripts/mainfunctions.lua(874,1) is that some kind of error? Code for this error. AddPrefabPostInit("chester_eyebone", function(inst) if GetPlayer().prefab == "alishia" then (THIS ONE IS 224. LINE) inst:RemoveComponent("inventoryitem") inst.components.talkerSay("I can't touch the 'Cursed bone'") end end) Link to comment Share on other sites More sharing options...
BraveChicken Posted March 24, 2018 Share Posted March 24, 2018 20 hours ago, AkaiNight said: Well i handle it but there was too many errors and i'm fixing them somehow. But this one i didin't understand anything. The error says "then" needed near "=" but there is a then near it. So here is the error and the code. Hmm, I haven't really used the "for k, v in pairs" type of coding that much so I also will need to look around to try and solve the problem. And if I'll figure something out I'll let you know. But from what I managed to understand from the script, it looks like you're trying to add a sanity aura on some prefabs/entities? If yes, then is there a reason why you are adding it this way instead of adding it directly on the prefabs files? (I mean simply adding the lines inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL into the critter_kitten and critter_puppy prefab files) And as for the chester_eyebone, try removing (or turning off) the line inst.components.talkerSay("I can't touch the 'Cursed bone'") Also, just to be sure I need to ask. You are testing it in Don't starve or Don't starve: Reign of Giants. Right? Because Don't starve together of what I managed to understand uses few different codings so it could cause you errors. I just want to be sure. (I don't really have Don't starve together to be fully aware of all of the differences there) Link to comment Share on other sites More sharing options...
AkaiNight Posted March 25, 2018 Author Share Posted March 25, 2018 22 hours ago, BraveChicken said: Hmm, I haven't really used the "for k, v in pairs" type of coding that much so I also will need to look around to try and solve the problem. And if I'll figure something out I'll let you know. But from what I managed to understand from the script, it looks like you're trying to add a sanity aura on some prefabs/entities? If yes, then is there a reason why you are adding it this way instead of adding it directly on the prefabs files? (I mean simply adding the lines inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL into the critter_kitten and critter_puppy prefab files) And as for the chester_eyebone, try removing (or turning off) the line inst.components.talkerSay("I can't touch the 'Cursed bone'") Also, just to be sure I need to ask. You are testing it in Don't starve or Don't starve: Reign of Giants. Right? Because Don't starve together of what I managed to understand uses few different codings so it could cause you errors. I just want to be sure. (I don't really have Don't starve together to be fully aware of all of the differences there) Well I'm using don't starve together. About the chester bone how can i add custom speech for it? Sorry again. There's a lots of errors and i'm trying to fix them but english is not my first language and there are many things that i can't understand and thanks again for everything. It's a shame for me to ask someone that much questions but there is one more thing that i can't understand. [string "../mods/alishia/modmain.lua"]:224: attempt to index a nil value LUA ERROR stack traceback: ../mods/alishia/modmain.lua(224,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) in function 'mod' scripts/mainfunctions.lua(216,1) =[C] in function 'SpawnPrefab' scripts/mainfunctions.lua(255,1) in function 'SpawnPrefab' scripts/mainfunctions.lua(261,1) in function 'SpawnSaveRecord' scripts/gamelogic.lua(482,1) in function 'PopulateWorld' scripts/gamelogic.lua(732,1) in function 'DoInitGame' scripts/gamelogic.lua(852,1) in function 'cb' ... =[C] in function 'GetPersistentString' scripts/saveindex.lua(250,1) in function 'Load' scripts/gamelogic.lua(1053,1) in function 'callback' scripts/playerprofile.lua(977,1) in function 'Set' scripts/playerprofile.lua(838,1) =[C] in function 'GetPersistentString' scripts/playerprofile.lua(836,1) in function 'Load' scripts/gamelogic.lua(1052,1) in main chunk =[C] in function 'require' scripts/mainfunctions.lua(874,1) here is code AddPrefabPostInit("chester_eyebone", function(inst) if GetPlayer().prefab == "alishia" then (THIS ONE 224.) inst:RemoveComponent("inventoryitem") end end) Link to comment Share on other sites More sharing options...
BraveChicken Posted March 25, 2018 Share Posted March 25, 2018 3 minutes ago, AkaiNight said: Well I'm using don't starve together. About the chester bone how can i add custom speech for it? If you want your mod to be compatible with Don't starve together then I sadly won't be able to help you as much (Because as I mentioned I don't have Don't starve together to know about all of the differences in the script that it would need to be made. But there's a lot of helpful people on the [Don't starve together] Mods and Tools, so I'm sure you'll find help anyways) and as for the bone, the easiest way would be changing the text in your character's speech.lua so upon examining the eyebone your character would say "I can't touch the 'Cursed bone'". Just look for CHESTER_EYEBONE in the speech.lua of your character and put the same text in the GENERIC and WAITING state. It should work. Link to comment Share on other sites More sharing options...
AkaiNight Posted March 25, 2018 Author Share Posted March 25, 2018 3 minutes ago, BraveChicken said: If you want your mod to be compatible with Don't starve together then I sadly won't be able to help you as much (Because as I mentioned I don't have Don't starve together to know about all of the differences in the script that it would need to be made. But there's a lot of helpful people on the [Don't starve together] Mods and Tools, so I'm sure you'll find help anyways) Oh forgive me it's my mistake i thought i was writing the together form. Link to comment Share on other sites More sharing options...
BraveChicken Posted March 25, 2018 Share Posted March 25, 2018 31 minutes ago, AkaiNight said: Sorry again. There's a lots of errors and i'm trying to fix them but english is not my first language and there are many things that i can't understand and thanks again for everything. It's a shame for me to ask someone that much questions but there is one more thing that i can't understand. [string "../mods/alishia/modmain.lua"]:224: attempt to index a nil value I believe the problem might be because of the if GetPlayer() call. I think that the Don't starve together might use a different one and that's why it's giving you errors. 34 minutes ago, AkaiNight said: thanks again for everything. It's a shame for me to ask someone that much questions And no worries! I'm always glad if I can help someone ^-^ Link to comment Share on other sites More sharing options...
Recommended Posts
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.