Renarii Posted June 6, 2015 Share Posted June 6, 2015 (edited) I want to add a prefab to spawn in already existing rooms. I've read through the worldgen guide but it doesn't seem that what I want to do is touched on anywhere there. At first I thought I would simply need to make a task and apply it to those rooms, but after looking further into that it appears to adds a prefab to those rooms requires you access that room. Also can anyone explain the relation of rooms -> biomes? Are the biomes just community created terminology to refer to rooms? e.g. the forest biome is simply referring to "map/rooms/terrain_forest". Edited June 6, 2015 by Renarii Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/ Share on other sites More sharing options...
Kzisor Posted June 6, 2015 Share Posted June 6, 2015 @Renarii, Biomes is a community created terminology referring to a location in game, e.g. Desert, Forest, Rocky, etc.. Rooms is the technical terminology used by the code itself. You will need to look in the scripts/maps/rooms folder at the terrains as well as all the rooms as these are what create the "biomes". Please note that if you do add something via modworldgenmain.lua you will need to regenerate your world for it to show up properly. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644295 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 Is there a global variable for the already existing rooms? I haven't been able to dump globals and the only place I see the rooms populated is in the local variable rooms in rooms.lua. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644309 Share on other sites More sharing options...
Kzisor Posted June 6, 2015 Share Posted June 6, 2015 @Renarii, you can access all the existing rooms with code like the following:GLOBAL.require("map/terrain")for k, v in pairs(terrain.rooms) do -- k is the key/index of the room. -- v is the room table.endYou will still need to research what each of the rooms contents are and how each of them work. You can find all rooms in scripts/maps/rooms. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644317 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 Thanks thank's what I was looking for I spent a while looking for a rooms global with the room data. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644327 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 Alright, I've hit another snag from what I understand this should make bamboo now spawn in all the listed rooms.local rooms = GLOBAL.terrain.roomslocal bamboorooms = { BGMarsh=0.05, Marsh=0.05, SlightlyMermySwamp=0.05, Forst=0.05, Clearing=0.05, ForestMole=0.05, DeepForest=0.05, CrappyDeepForest=0.05}for key, room in pairs(rooms) do if bamboorooms[key] then room.contents["distributeprefabs"]["bamboo"] = bamboorooms[key] endendHowever after running this and confirming that bamboo was listed in distributeprefabs correctly for those rooms I can't find it anywhere on the map. Does anyone know why it isn't spawning? At first I thought maybe the weight was to low but even after changing it to .9 I wasn't able to find it anywhere on the map. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644353 Share on other sites More sharing options...
Kzisor Posted June 6, 2015 Share Posted June 6, 2015 Are you sure it's not spawning? Open your console and type c_gonext("prefabname") to see if the animation just is not visible. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644382 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 (edited) Yup, it doesn't seem to have spawned c_gonext("bamboo") returns attempt to index a nil value in consolecommands.lua on line 419 which is where it's assigning the lastfound variable. lastfound = found.GUID -- found is nil so throws an error Edited June 6, 2015 by Renarii Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644428 Share on other sites More sharing options...
Kzisor Posted June 6, 2015 Share Posted June 6, 2015 @Renarii, this code should work.local rooms = GLOBAL.terrain.roomslocal bamboorooms = { BGMarsh=0.05, Marsh=0.05, SlightlyMermySwamp=0.05, Forst=0.05, Clearing=0.05, ForestMole=0.05, DeepForest=0.05, CrappyDeepForest=0.05} for key, room in pairs(rooms) do if bamboorooms[key] then rooms[key].contents.distributeprefabs.bamboo = bamboorooms[key] endend Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644438 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 (edited) @Kzisor I see what you did there, but sadly it doesn't work. I've confirmed that the bamboo key is being added to distributeprefabs it just isn't showing up on the map anywhere. I can get it to spawn by using c_spawn("bamboo") and then it shows up correctly. Edited June 6, 2015 by Renarii Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644450 Share on other sites More sharing options...
Kzisor Posted June 6, 2015 Share Posted June 6, 2015 @Renarii, are you regenerating your world? New prefabs are only spawned in worldgeneration. Please post your mod and I will see what the issue is in the code, it is probably something really stupid. World generation code is finicky unlike other code. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644454 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 Yes, I've deleted the world between every test. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644457 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 This is what I have currently that isn't working. I've tried putting the code in modworldgenman.lua thinking that maybe that was loaded before the modmain.lua and was the reason I was unable to find the item. But to no avail.Shinai.zip Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644513 Share on other sites More sharing options...
Kzisor Posted June 6, 2015 Share Posted June 6, 2015 (edited) @Renarii, you're putting the code I posted in modmain, when it needs to go into modworldgenmain.lua. Also you need to make sure it's named modworldgenmain.lua as right now it's named modworldgenman.lua. Edited June 6, 2015 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644519 Share on other sites More sharing options...
Renarii Posted June 6, 2015 Author Share Posted June 6, 2015 *sigh* That file typo thanks again. Link to comment https://forums.kleientertainment.com/forums/topic/54869-accessing-preexisting-worldgen/#findComment-644529 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