RedRock911 Posted April 26, 2015 Share Posted April 26, 2015 I have been working on a project for a follower, and I made some dumb error, and I'm not exactly sure what I need to do. I have been using THIS mod by TheDanaAddams, for referencing and format. Which if anyone needs to ever work on advanced project, I highly recommend (it is extremely well put together!) taking a look at her work. Also, I have been badgering Corrosive, who has been above and beyond helpful at taking someone, who knows nothing about scripting, or programming language, and at least aiding in the understanding on how things work in LUA. So, I didn't declare an ANIM state, and I'm not exactly sure how to do that. In fact, I probably have several errors that I am not seeing atm with my script, due to lack of inexperience. Below in the spoilers are the Prefab, and the crash log. If anyone thinks the error could be in the stategraph,brains, or anywhere else, please let me know, and i'll post those as well. scripts/worldgen_main.lua(80,1) SEED = 1430059404 scripts/worldgen_main.lua(458,1) WORLDGEN PRESET: SURVIVAL_DEFAULT scripts/worldgen_main.lua(466,1) WORLDGEN LEVEL ID: 1 scripts/worldgen_main.lua(473,1) ######### Generating Normal Mode Default Level######## F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(240,1) Creating story... F:/steam/steamapps/common/dont_starve/data/scripts/map/storygen.lua(444,1) LinkNodesByKeys F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(278,1) Baking map... 350 F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(303,1) Map Baked! F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(334,1) Encoding... F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(338,1) Encoding... DONE F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(407,1) Checking Tags F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(520,1) Populating voronoi... F:/steam/steamapps/common/dont_starve/data/scripts/map/object_layout.lua(418,1) Warning! Could not find a spot for Maxwell6 in node Speak to the king:1:DeepDeciduous:BG_40 F:/steam/steamapps/common/dont_starve/data/scripts/map/forest_map.lua(655,1) Done forest map gen! scripts/worldgen_main.lua(246,1) Checking map... scripts/worldgen_main.lua(600,1) Generation complete WorldSim::SimThread::Main() completescripts/gamelogic.lua(148,1) Unload FE scripts/gamelogic.lua(150,1) Unload FE done scripts/dlcsupport.lua(24,1) Load scripts/DLC001_prefab_files scripts/mods.lua(269,1) Mod: FlapJack Registering prefabs scripts/mods.lua(275,1) Mod: FlapJack Registering prefab file: prefabs/flapjack scripts/mods.lua(279,1) Mod: FlapJack flapjack scripts/mods.lua(292,1) Mod: FlapJack Registering default mod prefab Could not preload undefined prefab 0x6317756d (syrupbottle)scripts/mods.lua(269,1) Mod: knuckles Registering prefabs scripts/mods.lua(275,1) Mod: knuckles Registering prefab file: prefabs/knuckles scripts/mods.lua(279,1) Mod: knuckles knuckles scripts/mods.lua(292,1) Mod: knuckles Registering default mod prefab Could not preload undefined prefab 0x6317756d (syrupbottle)scripts/mods.lua(269,1) Mod: syrupbottle Registering prefabs scripts/mods.lua(275,1) Mod: syrupbottle Registering prefab file: prefabs/syrupbottle scripts/mods.lua(279,1) Mod: syrupbottle syrupbottle scripts/mods.lua(292,1) Mod: syrupbottle Registering default mod prefab scripts/gamelogic.lua(164,1) LOAD BE scripts/gamelogic.lua(172,1) LOAD BE : done MiniMapComponent::AddAtlas( minimap/minimap_data.xml )MiniMapComponent::AddAtlas( ../mods/FlapJack/images/map_icons/flapjack.xml )scripts/components/seasonmanager.lua(1586,1) AUTUMN TIME scripts/gamelogic.lua(494,1) Loading Nav Grid scripts/saveindex.lua(218,1) LoadSavedSeasonData CB scripts/widgets/bloodover.lua(30,1) update state scripts/widgets/bloodover.lua(50,1) turn off HttpClientWriteCallback (0x009A1DFF, 1, 16, 0x06D7F9B0)HttpClientWriteCallback READ 16 (16 total)QueryServerComplete no callback...e/data/../mods/knuckles/scripts/prefabs/knuckles.lua:38: variable 'anim' is not declaredLUA ERROR stack traceback: =[C] in function 'error' F:/steam/steamapps/common/dont_starve/data/scripts/strict.lua(23,1) F:/steam/steamapps/common/dont_starve/data/../mods/knuckles/scripts/prefabs/knuckles.lua(38,1) in function 'fn' F:/steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(127,1) =[C] in function 'SpawnPrefab' F:/steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(161,1) in function 'SpawnPrefab' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(300,1) in function 'SpawnChild' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(90,1) in function 'OnUpdate' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(113,1) in function 'fn' F:/steam/steamapps/common/dont_starve/data/scripts/scheduler.lua(170,1) in function 'OnTick' F:/steam/steamapps/common/dont_starve/data/scripts/scheduler.lua(381,1) in function 'RunScheduler' F:/steam/steamapps/common/dont_starve/data/scripts/update.lua(87,1)scripts/frontend.lua(723,1) SCRIPT ERROR! Showing error screen Force aborting... Prefab --[NEW] Here we list any assets required by our prefab.local assets ={--[NEW] this is the name of the Spriter file.Asset("ANIM", "anim/knuckles.zip"),}local function onnear(inst) inst.components.locomotor.walkspeed = inst.components.locomotor.walkspeed*.08 endlocal function onfar(inst) inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+1endlocal prefabs ={ "syrupbottle" }--[NEW] This function creates a new entity based on a prefab.local function create_knuckles() local inst = CreateEntity() inst.entity:AddTransform()inst.entity:AddAnimState()inst.Transform:SetFourFaced()inst:AddTag("K'nuckles") inst:AddTag("smallcreature")inst:AddTag("scarytoprey")inst:AddTag("largecreature")inst:AddTag("knuckles") anim:SetBank("knuckles") anim:SetBuild("knuckles") anim:PlayAnimation("idle_loop", true )inst:AddComponent("playerprox") inst.components.playerprox:SetDist(1, 2) inst.components.playerprox:SetOnPlayerNear(onnear) inst.components.playerprox:SetOnPlayerFar(onfar)inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier inst.components.locomotor.runspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+4-- inst.components.locomotor.isrunning = true inst:SetStateGraph("SGknuckles")inst:AddComponent("inspectable")inst:AddComponent("follower")inst:AddComponent("locomotor")inst.components.locomotor.runspeed = 5 inst.components.locomotor.walkspeed = 3 inst:AddTag("companion") inst:AddComponent("combat")inst.components.combat:SetKeepTargetFunction(ShouldKeepTarget)inst.components.combat.canbeattackedfn = function(self, attacker) if attacker == GetPlayer() then return false endreturn trueend ------------------ inst:AddComponent("health") inst.components.health:SetMaxHealth(300)local brain = require "brains/knucklesbrain"inst:SetBrain(brain) --[NEW] return our new entity so that it can be added to the world. return instendreturn Prefab( "common/knuckles", create_knuckles, assets, prefabs) The error initially leads here anim:SetBank("knuckles")So, I know I need to declare the Anime state, following the error report, I found this script in strict.lua line 23,1, if it helps.t.__index = function (t, n) if not mt.__declared[n] and debug.getinfo(2, "S").what ~= "C" then error("variable '"..n.."' is not declared", 2) end return rawget(t, n)endI hope this helps in looking at the files. Let me know what you guys think. Special Thanks to Corrosive, for all your hard work and dedication to problem solving., Seiai, and Mobbstar, for being proactive on the forums, And thanks to TheDanaAddams for her mod, which is a beautiful work on the inside and outside. Link to comment Share on other sites More sharing options...
Seiai Posted April 26, 2015 Share Posted April 26, 2015 @RedRock911replace anim:SetBank("knuckles") anim:SetBuild("knuckles") anim:PlayAnimation("idle_loop", true )with inst.anim:SetBank("knuckles") inst.anim:SetBuild("knuckles") inst.anim:PlayAnimation("idle_loop", true )because u didnt reference the animstate of the character the right way, it thinks u are trying to use a variable called "anim" to do stuff, but that variable isnt declared anywhere, hence "variable 'anim' is not declared". Link to comment Share on other sites More sharing options...
RedRock911 Posted April 26, 2015 Author Share Posted April 26, 2015 because u didnt reference the animstate of the character the right way, it thinks u are trying to use a variable called "anim" to do stuff, but that variable isnt declared anywhere, hence "variable 'anim' is not declared". Thank you so much! I was trying to compare it to some accounting script on the .lua website. One of those stare right at it for 3 hour issues. Link to comment Share on other sites More sharing options...
RedRock911 Posted April 27, 2015 Author Share Posted April 27, 2015 @RedRock911replace anim:SetBank("knuckles") anim:SetBuild("knuckles") anim:PlayAnimation("idle_loop", true )with inst.anim:SetBank("knuckles") inst.anim:SetBuild("knuckles") inst.anim:PlayAnimation("idle_loop", true )because u didnt reference the animstate of the character the right way, it thinks u are trying to use a variable called "anim" to do stuff, but that variable isnt declared anywhere, hence "variable 'anim' is not declared". I recieved a nil return:reference ...e/data/../mods/knuckles/scripts/prefabs/knuckles.lua:38: attempt to index field 'anim' (a nil value)LUA ERROR stack traceback: F:/steam/steamapps/common/dont_starve/data/../mods/knuckles/scripts/prefabs/knuckles.lua(38,1) in function 'fn' F:/steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(127,1) =[C] in function 'SpawnPrefab' F:/steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(161,1) in function 'SpawnPrefab' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(300,1) in function 'SpawnChild' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(90,1) in function 'OnUpdate' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(113,1) in function 'fn' F:/steam/steamapps/common/dont_starve/data/scripts/scheduler.lua(170,1) in function 'OnTick' F:/steam/steamapps/common/dont_starve/data/scripts/scheduler.lua(381,1) in function 'RunScheduler' F:/steam/steamapps/common/dont_starve/data/scripts/update.lua(87,1)scripts/frontend.lua(723,1) SCRIPT ERROR! Showing error screen Please correct me if I am wrong here. Since This particular guy uses pig animations, did I screw up by having my own bank build? I dont think the game knows it's there. AND did I not do something to tell it that it IS there? here is my updated script --[NEW] Here we list any assets required by our prefab.local assets ={--[NEW] this is the name of the Spriter file.Asset("ANIM", "anim/knuckles.zip"),}local function onnear(inst) inst.components.locomotor.walkspeed = inst.components.locomotor.walkspeed*.08 endlocal function onfar(inst) inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+1endlocal prefabs ={ "syrupbottle" }--[NEW] This function creates a new entity based on a prefab.local function create_knuckles() local inst = CreateEntity() inst.entity:AddTransform()inst.entity:AddAnimState()inst.Transform:SetFourFaced()inst:AddTag("K'nuckles") inst:AddTag("smallcreature")inst:AddTag("scarytoprey")inst:AddTag("largecreature")inst:AddTag("knuckles") inst.anim:SetBank("knuckles") inst.anim:SetBuild("knuckles") inst.anim:PlayAnimation("idle_loop", true )inst:AddComponent("playerprox") inst.components.playerprox:SetDist(1, 2) inst.components.playerprox:SetOnPlayerNear(onnear) inst.components.playerprox:SetOnPlayerFar(onfar)inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier inst.components.locomotor.runspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+4-- inst.components.locomotor.isrunning = true inst:SetStateGraph("SGknuckles")inst:AddComponent("inspectable")inst:AddComponent("follower")inst:AddComponent("locomotor")inst.components.locomotor.runspeed = 5 inst.components.locomotor.walkspeed = 3 inst:AddTag("companion") inst:AddComponent("combat")inst.components.combat:SetKeepTargetFunction(ShouldKeepTarget)inst.components.combat.canbeattackedfn = function(self, attacker) if attacker == GetPlayer() then return false endreturn trueend ------------------ inst:AddComponent("health") inst.components.health:SetMaxHealth(300)local brain = require "brains/knucklesbrain"inst:SetBrain(brain) --[NEW] return our new entity so that it can be added to the world. return instendreturn Prefab( "common/knuckles", create_knuckles, assets, prefabs) I dont have to add my anim file to the return Prefab line do I? Link to comment Share on other sites More sharing options...
Seiai Posted April 27, 2015 Share Posted April 27, 2015 @RedRock911ok, sry, i didnt read the file through close enough, it seems u copypasted stuff together from different creatures, that's why i overlooked this:u can either write: inst.entity:AddAnimState()andinst.AnimState:SetBank("knuckles")inst.AnimState:SetBuild("knuckles")inst.AnimState:PlayAnimation("idle_loop", true )or anim=inst.entity:AddAnimState()andanim:SetBank("knuckles")anim:SetBuild("knuckles")anim:PlayAnimation("idle_loop", true )this means u can either just create the AnimState and then access it via the system's reference inst.AnimState(glommer.lua for instance does it this way) or u can create the AnimState and put a reference to it straight into a variable (anim here) and then access it via that variable(spider.lua does hat one for instance).and yes, copypasting different creatures together into one can be a lot of trouble, cause they can be programmed in different ways(i did that with hounds and spiders in my mod, it took me a long time to sort everything out).also, if u wanna have him be your follower right after he spawns, just addGetPlayer().components.leader:AddFollower(inst)right afterinst:AddComponent("follower")will u also combine the stategraphs and brains of different creatures for knuckles?also, did u actually alter the anim.bin file, so u can use this?inst.AnimState:SetBank("knuckles")if not, u will have to leave the Bank(name of the animatiofolder inside the anim.bin) at "pigman":inst.AnimState:SetBank("pigman")inst.AnimState:SetBuild("knuckles")inst.AnimState:PlayAnimation("idle_loop", true )after the 20th edit of this post, ill just say: if u need further help, add me on steam, i helped some other pple over steam, its much more direct for such multilayered problems http://steamcommunity.com/profiles/76561197996184319 Link to comment Share on other sites More sharing options...
RedRock911 Posted April 27, 2015 Author Share Posted April 27, 2015 @RedRock911ok, sry, i didnt read the file through close enough, it seems u copypasted stuff together from different creatures, that's why i overlooked this:Well, originally, I had help, and was writing it from scratch, got the luau standalone to try and obtain some knowledge of how the language words on a suggestion from our buddy Corrosive. And for a month or so, been dealing with errors, mostly from me not understanding how to write a decent table.So I decided I would look at how other people wrote out their scripts. I looked at your Kerrigan (who is really fun to play btw), Link the Hero, and ahem......puppy mushu princess.I have been reading the forums, all in which we all have seemed to run into snags with custom followers at some point during the creation process. A lot of people borrow from the hound files it seems. So I did the same.Eventually I redistributed some script lines to look more like "link the hero" from thedanaaddams.Hers seemed to work, and it's crazy the amount of stuff is in that mod.So in my defense, every line I tried to look at why I would need it, before bringing it over. But as you said, I think all I did was borrow more trouble, lol.But yah, I'll find you on steam if you don't mind. Give Corrosive a break, lol. Link to comment Share on other sites More sharing options...
Corrosive Posted April 27, 2015 Share Posted April 27, 2015 @RedRock911, Tired of reading my manifesto-length private replies? hah Link to comment Share on other sites More sharing options...
Corrosive Posted April 27, 2015 Share Posted April 27, 2015 lso, did u actually alter the anim.bin file, so u can use this? Yes, he used ktools to decompile the pig animations and made his own sprites for knuckles, which I've helped a bit with cleaning up(still have a ways to go) cause the pig parts are pretty unique. Link to comment Share on other sites More sharing options...
Corrosive Posted April 27, 2015 Share Posted April 27, 2015 I dont have to add my anim file to the return Prefab line do I? You already are : _____ you are creating an assets variable, which, because of the {}s, is a / table with your asset as the only element(currently).local assets ={Asset("ANIM", "anim/knuckles.zip"),} ____ look familiar? /return Prefab( "common/knuckles", create_knuckles, assets, prefabs)In addition to the AnimState thing, your next problem is going to be these lines:inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier inst.components.locomotor.runspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+4-- inst.components.locomotor.isrunning = true...which you have before you've added the locomotor component Link to comment Share on other sites More sharing options...
RedRock911 Posted April 27, 2015 Author Share Posted April 27, 2015 @RedRock911,Tired of reading my manifesto-length private replies? hah Ha! You seemed busy, but that's because I assumed you wait galiantly by your Mac, waiting for my next misstep! So.....now that your here....... Link to comment Share on other sites More sharing options...
Corrosive Posted April 27, 2015 Share Posted April 27, 2015 You seemed busy I was a bit busy, sorry I'm back now. Also I updated my last post in the event you didn't catch it Link to comment Share on other sites More sharing options...
RedRock911 Posted April 28, 2015 Author Share Posted April 28, 2015 ignore this Link to comment Share on other sites More sharing options...
RedRock911 Posted April 28, 2015 Author Share Posted April 28, 2015 You already are : _____ you are creating an assets variable, which, because of the {}s, is a / table with your asset as the only element(currently).local assets ={Asset("ANIM", "anim/knuckles.zip"),}So i am still getting a nil value.. is this the reason? Link to comment Share on other sites More sharing options...
Seiai Posted April 28, 2015 Share Posted April 28, 2015 @RedRock911, add me already Link to comment Share on other sites More sharing options...
RedRock911 Posted April 28, 2015 Author Share Posted April 28, 2015 @RedRock911,add me already added Link to comment Share on other sites More sharing options...
RedRock911 Posted April 28, 2015 Author Share Posted April 28, 2015 I was a bit busy, sorry I'm back now. Also I updated my last post in the event you didn't catch itLooking at it now. with a very puzzled look on my face. Ok, so since I only added the one asset, could that be an issue? I keep refering to other posts while i'm looking for the solution. Telling myself, "dont think about just 'adding' something, tell the game what you want it to see, you want it to see the anim files." So i'm trying to figure out how to do that. THEN I need to reallocate the locomotor lines, after the locomotor component. well, in ways I'm glad this post is public, hopefully when I get knuckles up n running, people will be able to refer back to this post for troubleshooting. Link to comment Share on other sites More sharing options...
Corrosive Posted April 28, 2015 Share Posted April 28, 2015 So i am still getting a nil value.. is this the reason? No, all that does is make those assets ready for use by the prefab. You got a nil value error because of what Seiai said in post #5. If you fixed that but then didn't fix the second problem I mentioned on the bottom half of post #9, you would also get a nil value error. In Lua, everything is nil, by default. So when you try to access a variable that you haven't initialized yet, the Lua interpreter considers the value of it to be nil. This is only a problem when you try to use that variable in some manner that nil can't be used. For example, if you were to try to treat it like a table and retrieve an index via somevariable.index. In effect, the Lua interpreter considers this to be saying nil.index, which makes no sense, so Lua throws the nil value error. In the case of your script, your errors were: 1. On the line: inst.anim:SetBank("knuckles")You are trying to access the "anim" index of the table held by the inst variable, which doesn't exist. The index that you were looking for was AnimState. This results in Lua seeing this expression as inst.nil:SetBank("knuckles") 2. On the line: inst.components.locomotor.walkspeed = ...You are trying to access the "locomotor" index held by the table held by the "components" index of the table held by the inst variable, which also doesn't exist. It doesn't exist, because it has not yet been added by inst:AddComponent("locomotor"). This results in Lua seeing this expression as inst.components.nil.walkspeed = ... Edit: ya responded like 5 seconds before I posted this =o Link to comment Share on other sites More sharing options...
RedRock911 Posted April 28, 2015 Author Share Posted April 28, 2015 In the case of your script, your errors were: 1. On the line: inst.anim:SetBank("knuckles")You are trying to access the "anim" index of the table held by the inst variable, which doesn't exist. The index that you were looking for was AnimState. This results in Lua seeing this expression as inst.nil:SetBank("knuckles") Edit: ya responded like 5 seconds before I posted this =o So what, ( and I really feel a bit less intellegent for asking this, but then again......) What would be the correct way for me to write AnimeState? Link to comment Share on other sites More sharing options...
Seiai Posted April 28, 2015 Share Posted April 28, 2015 see post #5 Link to comment Share on other sites More sharing options...
Corrosive Posted April 28, 2015 Share Posted April 28, 2015 @RedRock911, inst inst.anim+===========+=============+ .--------- NOTHIN' HERE (nil)| key | value | / +===========+=============+ / | | | / inst.AnimState+-----------+-------------+ / .---------+===========+=============+| anim | nil |-/ / | key | value | +-----------+-------------+ / +===========+=============+ | AnimState | (AnimState)-|-----/ | (all of AnimState's |+-----------+-------------+ | methods are in here) | | |Does this make more sense? Edit: This is an oversimplification of AnimState, but it's meant to illustrate table indexes. Link to comment Share on other sites More sharing options...
RedRock911 Posted April 29, 2015 Author Share Posted April 29, 2015 @RedRock911, inst inst.anim+===========+=============+ .--------- NOTHIN' HERE (nil)| key | value | / +===========+=============+ / | | | / inst.AnimState+-----------+-------------+ / .---------+===========+=============+| anim | nil |-/ / | key | value | +-----------+-------------+ / +===========+=============+ | AnimState | (AnimState)-|-----/ | (all of AnimState's |+-----------+-------------+ | methods are in here) | | |Does this make more sense? Edit: This is an oversimplification of AnimState, but it's meant to illustrate table indexes. yes it makes sense! And I do get it. But no matter how I'm rewriting the script, I still get that error. It's making me think that the error is somewhere else. BUT, just to be sure, here is how I rewrote it last. I did try and rewrite it like in post 5, but i recieved the same error. This is the current rewrite,--[NEW] Here we list any assets required by our prefab.local assets ={--[NEW] this is the name of the Spriter file.Asset("ANIM", "anim/knuckles.zip"),}local prefabs ={ "syrupbottle" }--[NEW] This function creates a new entity based on a prefab.local function create_knuckles() local inst = CreateEntity() inst.entity:AddTransform()inst.entity:AddAnimState()inst.Transform:SetFourFaced()inst:AddTag("K'nuckles") inst:AddTag("smallcreature")inst:AddTag("scarytoprey")inst:AddTag("largecreature")inst:AddTag("knuckles") inst.AddAnimState() anim:SetBank("knuckles") anim:SetBuild("knuckles") anim:PlayAnimation("idle_loop", true )inst:AddComponent("playerprox") inst.components.playerprox:SetDist(1, 2) inst.components.playerprox:SetOnPlayerNear(onnear) inst.components.playerprox:SetOnPlayerFar(onfar) inst:SetStateGraph("SGknuckles")inst:AddComponent("inspectable")inst:AddComponent("follower")inst:AddComponent("locomotor")inst.components.locomotor.runspeed = 5 inst.components.locomotor.walkspeed = 3 inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier inst.components.locomotor.runspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+4-- inst.components.locomotor.isrunning = true inst:AddTag("companion") inst:AddComponent("combat")inst.components.combat:SetKeepTargetFunction(ShouldKeepTarget)inst.components.combat.canbeattackedfn = function(self, attacker) if attacker == GetPlayer() then return false endreturn trueend ------------------ inst:AddComponent("health") inst.components.health:SetMaxHealth(300)local brain = require "brains/knucklesbrain"inst:SetBrain(brain) --[NEW] return our new entity so that it can be added to the world. return instendlocal function onnear(inst) inst.components.locomotor.walkspeed = inst.components.locomotor.walkspeed*.08 endlocal function onfar(inst) inst.components.locomotor.walkspeed = GetPlayer().components.locomotor.groundspeedmultiplier*GetPlayer().components.locomotor.walkspeed*GetPlayer().components.locomotor.fastmultiplier+1endreturn Prefab( "common/knuckles", create_knuckles, assets, prefabs) and BTW thank you both for your patience! Link to comment Share on other sites More sharing options...
Corrosive Posted April 29, 2015 Share Posted April 29, 2015 @RedRock911, You should fix your indentation, it makes everything a lot easier to read when you're trying to figure out what's wrong In any case, never assume that an error you get is the same as the last one you got-- they could have very different causes but end at the same result. You didn't say what line the error was occuring on, but I can see one issue with the lines: inst.components.playerprox:SetOnPlayerNear(onnear) inst.components.playerprox:SetOnPlayerFar(onfar)Both onnear and onfar haven't been defined yet in your code-- your function definitions are way at the bottom, so those variables don't exist at that point. Link to comment Share on other sites More sharing options...
RedRock911 Posted April 29, 2015 Author Share Posted April 29, 2015 @RedRock911, You didn't say what line the error was occuring on, but I can see one issue with the lines: my bad, here it is QueryServerComplete no callback...e/data/../mods/knuckles/scripts/prefabs/knuckles.lua:31: attempt to call field 'AddAnimState' (a nil value)LUA ERROR stack traceback: F:/steam/steamapps/common/dont_starve/data/../mods/knuckles/scripts/prefabs/knuckles.lua(31,1) in function 'fn' F:/steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(127,1) =[C] in function 'SpawnPrefab' F:/steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(161,1) in function 'SpawnPrefab' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(300,1) in function 'SpawnChild' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(90,1) in function 'OnUpdate' F:/steam/steamapps/common/dont_starve/data/scripts/components/childspawner.lua(113,1) in function 'fn' F:/steam/steamapps/common/dont_starve/data/scripts/scheduler.lua(170,1) in function 'OnTick' F:/steam/steamapps/common/dont_starve/data/scripts/scheduler.lua(381,1) in function 'RunScheduler' F:/steam/steamapps/common/dont_starve/data/scripts/update.lua(87,1)scripts/frontend.lua(723,1) SCRIPT ERROR! Showing error screen Force aborting... This is line 31inst.AddAnimState()and this is the error in mainfunctions.lua if it helps anyif prefab then local inst = prefab.fn(TheSim) if inst ~= nil then inst:SetPrefabName(inst.prefab or name)for k,mod in pairs(prefab.modfns) domod(inst)end for k,prefabpostinitany in pairs(ModManager:GetPostInitFns("PrefabPostInitAny")) do prefabpostinitany(inst) end return inst.entity:GetGUID() else print( "Failed to spawn", name ) return -1 end endend DOES it help any? Link to comment Share on other sites More sharing options...
Corrosive Posted April 29, 2015 Share Posted April 29, 2015 @RedRock911, ohhhhhh-- inst.AddAnimState() -> inst.entity:AddAnimState() Link to comment Share on other sites More sharing options...
Seiai Posted April 29, 2015 Share Posted April 29, 2015 @Corrosive, we are already working through that on steam^^ btw, u wanna maybe add me too? we are both very active on the forums and i could maybe be nice to be able to chat more directly. 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.