Kzisor Posted February 10, 2015 Share Posted February 10, 2015 (edited) @Crestonia, change these lines:AddPlayerPostInit( function()local player_pos = GLOBAL.ThePlayer():GetPosition() to:AddPlayerPostInit( function(inst)local player_pos = inst.Transform:GetPosition()It should work after that. A reason your code doesn't work is because ThePlayer is a variable not a function. You shouldn't use () with it. Use a . with it. Edited February 10, 2015 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-611564 Share on other sites More sharing options...
Crestonia Posted February 10, 2015 Author Share Posted February 10, 2015 Kzisor I'm really sorry it crashes so much e.e http://steamcommunity.com/sharedfiles/filedetails/?id=390106132 Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-611565 Share on other sites More sharing options...
Kzisor Posted February 10, 2015 Share Posted February 10, 2015 @Crestonia, change GetPosition to GetWorldPosition. Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-611567 Share on other sites More sharing options...
Crestonia Posted February 10, 2015 Author Share Posted February 10, 2015 @Kzisor I changed it but it still crashes.http://steamcommunity.com/sharedfiles/filedetails/?id=390288147 Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-611664 Share on other sites More sharing options...
Kzisor Posted February 10, 2015 Share Posted February 10, 2015 @Crestonia, by giving you the answer you will not learn. Your variable hat is a nil value, it means that wherever you are initializing the variable something is going wrong making it a nil or nonexistent variable. You will need to look at your code and determine why it's a nil value. Some questions to ask yourself:Is my prefab/item really being loaded properly?Should I add additional prints to the log file to see exactly where the code malfunctions?Should I comment out the mod main code and use the console to spawn it to see if it works?Debugging is part of coding in general and is something you should get familiar with if you plan on creating more mods. Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-611690 Share on other sites More sharing options...
Foxrai Posted February 11, 2015 Share Posted February 11, 2015 @KzisorAddPlayerPostInit( function()local player_pos = GLOBAL.ThePlayer():GetPosition()local hat = GLOBAL.SpawnPrefab('hat_bee_bw')hat.Transform:SetPosition(player_pos.x, player_pos.y, player_pos.z)end)In the modinfo You know I'm terrible at coding many things but... @Kzisor did you notice Crestonia said it's in the modinfo? Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612016 Share on other sites More sharing options...
Kzisor Posted February 11, 2015 Share Posted February 11, 2015 You know I'm terrible at coding many things but... @Kzisor did you notice Crestonia said it's in the modinfo? It's not in the modinfo.lua, they misremembered as in the files I downloaded it was in the modmain.lua file. Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612024 Share on other sites More sharing options...
Crestonia Posted February 11, 2015 Author Share Posted February 11, 2015 oops, sorry. lol e.e I think the hat is a lost cause though ... Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612025 Share on other sites More sharing options...
Jjmarco Posted February 11, 2015 Share Posted February 11, 2015 @Crestonia, Well, of course it's a lost cause if you give up so easily.Try what Kzisor suggested. Try spawning the hat using console commands, like c_give("hat_bee_bw").The console is opened using the ~ key on a QWERTY keyboard. We can't help you if you don't try things for yourself and always expect us to magically solve all your problems! Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612028 Share on other sites More sharing options...
Kzisor Posted February 11, 2015 Share Posted February 11, 2015 @Jjmarco, the problem lies in the tutorial in which they used originally to create their mod. @Crestonia, here is an updated tutorial. The original was created for Don't Starve, however, the modified tutorial is created for Don't Starve Together. How do you obtain the hat? Use the command c_give("hat_bee_bw") in the console. Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612035 Share on other sites More sharing options...
Crestonia Posted February 11, 2015 Author Share Posted February 11, 2015 (edited) () Edited February 11, 2015 by Crestonia Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612097 Share on other sites More sharing options...
Crestonia Posted February 11, 2015 Author Share Posted February 11, 2015 @Kzisor Thanks for all the help! The modified version doesn't crash my game. Link to comment https://forums.kleientertainment.com/forums/topic/50003-custom-item/page/2/#findComment-612101 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