mouse Posted September 12, 2013 Share Posted September 12, 2013 (edited) I'm trying to make placers for things that already exist. I really don't get what I'm doing wrong. They always work great when I put them directly into the prefab file but I think that shouldn't even be an option.This:local function gravestoneplacer(inst)return Prefab( "common/objects/gravestone", fn, assets, prefabs ),GLOBAL.MakePlacer( "common/gravestone_placer", "gravestone", "gravestones", "grave1")endAddPrefabPostInit("gravestone", gravestoneplacer)Results in the error: playercontroller.lua:126: attempt to index field 'placer'(a nil value)Putting this at the end of modmain.lua:return Prefab( "common/objects/gravestone", fn, assets, prefabs ) ,GLOBAL.MakePlacer( "common/gravestone_placer", "gravestone", "gravestones", "grave1")Results in the error: Variable 'MakePlacer' is not declaredLike I said they work great when they're in the prefab file but trying to pass them from modmain.lua to the prefab is giving me trouble. When I try to dissect other mods that use custom placers, they seem to overwrite the prefab lua file so they're no help. What am I doing wrong? Edited September 12, 2013 by mouse Link to comment https://forums.kleientertainment.com/forums/topic/27596-makeplacer-in-modmainlua/ Share on other sites More sharing options...
mouse Posted September 15, 2013 Author Share Posted September 15, 2013 Alternatively, would anyone know how to get "require" to work properly in modmain.lua? It always gives me an error. Link to comment https://forums.kleientertainment.com/forums/topic/27596-makeplacer-in-modmainlua/#findComment-322615 Share on other sites More sharing options...
RCatta Posted September 15, 2013 Share Posted September 15, 2013 (edited) I'm trying to make placers for things that already exist. I really don't get what I'm doing wrong. They always work great when I put them directly into the prefab file but I think that shouldn't even be an option.This:local function gravestoneplacer(inst)return Prefab( "common/objects/gravestone", fn, assets, prefabs ),GLOBAL.MakePlacer( "common/gravestone_placer", "gravestone", "gravestones", "grave1")endAddPrefabPostInit("gravestone", gravestoneplacer)Results in the error: playercontroller.lua:126: attempt to index field 'placer'(a nil value)Putting this at the end of modmain.lua:return Prefab( "common/objects/gravestone", fn, assets, prefabs ) ,GLOBAL.MakePlacer( "common/gravestone_placer", "gravestone", "gravestones", "grave1")Results in the error: Variable 'MakePlacer' is not declaredLike I said they work great when they're in the prefab file but trying to pass them from modmain.lua to the prefab is giving me trouble. When I try to dissect other mods that use custom placers, they seem to overwrite the prefab lua file so they're no help. What am I doing wrong? I very tired and half (or mre than hlaf ) drunk right now but I'm pretty sure you shou;dn't return anything from your postinit function , especially not in the first line of code. "return" will return what you set it to return and will not go through any subsequent lines of code in your function , so :GLOBAL.MakePlacer( "common/gravestone_placer", "gravestone", "gravestones", "grave1")will never even be executed.. Edited September 15, 2013 by RCatta Link to comment https://forums.kleientertainment.com/forums/topic/27596-makeplacer-in-modmainlua/#findComment-322630 Share on other sites More sharing options...
mouse Posted September 17, 2013 Author Share Posted September 17, 2013 Well it looks like my own personal mental retardation as subsided enough to allow me to figure it out.For anyone who's looking for a similar solution:First you need to create a new lua file in: <your root mod directory>/scripts/prefabs/Make sure it doesn't share the same name as anything in <don't starve root directory>/data/scripts/prefabs/For example: intergratedredditmod/scripts/prefabs/idiotwrangler.luaIn my case: graverobbers delight/scripts/prefabs/gravestoneplacer.luaThat file is where you'll put your placer. At the top, be sure to include:require "prefabutil"In my case:require "prefabutil"return MakePlacer( "common/gravestone_placer", "gravestone", "gravestones", "grave2")Next, in modmain.lua put the following:PrefabFiles = {"your file name here",}In my case:PrefabFiles = {"gravestoneplacer",}And that's it! It's so depressingly simple looking at it now. Link to comment https://forums.kleientertainment.com/forums/topic/27596-makeplacer-in-modmainlua/#findComment-323948 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