Serpens Posted September 9, 2016 Author Share Posted September 9, 2016 (edited) @DarkXero If I always return 1 for the first initiated room (and for all other rooms 0), all setpieces are of course placed in the same room instance. But it seems they are also placed at exactly the same position =/ Or is this only because the room instance is too small? (it was "Plain") So if I want to use this for my teleportato parts, I have to make sure that: - the function does not return true for the same room instance for more than one part. - after all rooms are initiated, all part layouts have to be used once. Have to think about it, how this can be done.... And also, how are they placed? Is still layout.fill_mask and so on used? So can it happen, that one layout is not placed if the masks are normal? And if they are not normal, they can again spawn at the same like Portal or any other game setpieces? edit: tested it, and yes the fill_mask is still used, so it can happen that they are not placed. So conclusioin would be this is not much better than adding them to taskset, except I can add them to rooms, instead of tasks... Will think about it what to use... Edited September 9, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811701 Share on other sites More sharing options...
DarkXero Posted September 9, 2016 Share Posted September 9, 2016 37 minutes ago, Serpens said: But it seems they are also placed at exactly the same position =/ Or is this only because the room instance is too small? (it was "Plain") That's odd. It happens consistently? You could also make your own rooms with a static layout each, and put those into the tasks. 39 minutes ago, Serpens said: And also, how are they placed? Is still layout.fill_mask and so on used? So can it happen, that one layout is not placed if the masks are normal? And if they are not normal, they can again spawn at the same like Portal or any other game setpieces? edit: tested it, and yes the fill_mask is still used, so it can happen that they are not placed. Actually, this is what used to happen to the Pig King. Now it has the mask that ignores everything. Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811715 Share on other sites More sharing options...
Serpens Posted September 9, 2016 Author Share Posted September 9, 2016 10 minutes ago, DarkXero said: That's odd. It happens consistently? Yes, I think so, tried it two times with the following code (I forgot in that code, that the stuff in addroompreinti is called when the room instance is initialised and not when I call AddRoomPreInit , that's why I used shuffle local teleportato_layouts = { "TeleportatoBoxLayout", "TeleportatoRingLayoutSanityRocks", -- "TeleportatoRingLayout", "TeleportatoPotatoLayout", "TeleportatoCrankLayout", "TeleportatoBaseLayout", } local Terrains = { Badland = {"BGBadlands","Badlands",}, Decidiuous = {"BGDeciduous","DeepDeciduous","DeciduousClearing","PondyGrass",}, Grass = {"BGGrassBurnt","BGGrass","MandrakeHome",}, Dirt = {"BGDirt","BGNoise",}, Forest = {"BGCrappyForest","BGForest","BGDeepForest","BurntForest","CrappyDeepForest","DeepForest","Forest","CrappyForest","BurntClearing","Clearing",}, Marsh = {"BGMarsh","Marsh",}, Rocky = {"BGRocky","Rocky","GenericRockyNoThreat",}, Savanna = {"BGSavanna","Plain","BarePlain",}, } local allowed_rooms = GLOBAL.ArrayUnion(Terrains.Badland,Terrains.Decidiuous,Terrains.Grass,Terrains.Dirt,Terrains.Forest,Terrains.Rocky,Terrains.Savanna) -- no marsh local PlacedLayouts = {} for _,layout in pairs(teleportato_layouts) do PlacedLayouts.layout = false end local function AddtoRooms(layout) local allowed_rooms_shuffled = GLOBAL.shuffleArray(allowed_rooms) -- shuffle the room list ... but does not matter, since this affects not the order rooms are initiated... for _,theroom in pairs(allowed_rooms_shuffled) do AddRoomPreInit(theroom, function(room) if room.contents.countstaticlayouts == nil then room.contents.countstaticlayouts = {} end room.contents.countstaticlayouts[layout] = function() if not PlacedLayouts[layout] then PlacedLayouts[layout] = true print("Added "..tostring(layout).." to room: "..tostring(theroom)) -- so return das erste initiierte roomding 1 und alle andern 0, daher ist alles imselben roomding return 1 -- only allow one, if there is none yet else return 0 end end end) end end for _,layout in pairs(teleportato_layouts) do AddtoRooms(layout) end Quote You could also make your own rooms with a static layout each, and put those into the tasks. What do you mean by this? Putting a static_layout into the tasks sounds like the the first solution we had before (in second post). The difference is of course that you say "own rooms", but I did not found anything in game scripts, that handles how many of each rooms are placed... Anyway, adding own rooms will make things alot more complicated, or not ? Adding the setpieces to the rooms I have in my code above should be good enough, if I find a solution to Quote So if I want to use this for my teleportato parts, I have to make sure that: - the function does not return true for the same room instance for more than one part. - after all rooms are initiated, all part layouts have to be used once. Will think tomorrow about it... Thank you for your continuously help! Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811721 Share on other sites More sharing options...
DarkXero Posted September 9, 2016 Share Posted September 9, 2016 2 hours ago, Serpens said: So can it happen, that one layout is not placed if the masks are normal? And if they are not normal, they can again spawn at the same like Portal or any other game setpieces? Also, the game doesn't "again spawn" the stuff that fails to spawn. It fails. That's when it pops the "Warning!" in the logs. The only one exception is the portal. Because if you check locations.lua: required_prefabs = { "multiplayer_portal", }, and this doesn't even mean that the portal will be spawned again. It means the world resets, regenerates. This table had the Pig King before. You can make your own set pieces, with a special prefab each "serpensmarker1", "serpensmarker2", and add them to the table. 11 minutes ago, Serpens said: What do you mean by this? Putting a static_layout into the tasks sounds like the the first solution we had before (in second post). AddRoom("my_own_room", { colour = {r = 0.8, g = 0.8, b = 0.2, a = 0.50}, value = GLOBAL.GROUND.SAVANNA, tags = {"ExitPiece", "Chester_Eyebone"}, contents = { countstaticlayouts = { ["PigGuardsB"] = function() return 1 end }, distributepercent = 0.1, distributeprefabs = { perma_grass = 0.09, rabbithole = 0.025, flower = 0.003, }, } }) AddTaskPreInit("Make a pick", function(task) task.room_choices["my_own_room"] = 1 end) You make a room, you insert it into a task. Also this local PlacedLayouts = {} for _,layout in pairs(teleportato_layouts) do PlacedLayouts.layout = false end is the same as doing this local PlacedLayouts = {} for _,layout in pairs(teleportato_layouts) do PlacedLayouts["layout"] = false end but since "PlacedLayouts[layout]" is nil (instead of false), then the "if not PlacedLayout[layout] then" evaluates to true. 1 hour ago, Serpens said: Yes, I think so, tried it two times with the following code (I forgot in that code, that the stuff in addroompreinti is called when the room instance is initialised and not when I call AddRoomPreInit , that's why I used shuffle Well, the issue in your code is that when a room runs the preinit function, when it goes to put the static layouts, it will put all of them and set all the PlacedLayouts to true. You shuffle the rooms, but you go through all of them. So all the layouts will end up in any of the rooms. local function AddtoRooms(layout) local allowed_rooms_shuffled = GLOBAL.shuffleArray(allowed_rooms) local random_index = math.random(#allowed_rooms_shuffled) AddRoomPreInit(allowed_rooms_shuffled[random_index], function(room) if room.contents.countstaticlayouts == nil then room.contents.countstaticlayouts = {} end room.contents.countstaticlayouts[layout] = function() if not PlacedLayouts[layout] then PlacedLayouts[layout] = true return 1 else return 0 end end end) end for _, layout in pairs(teleportato_layouts) do AddtoRooms(layout) end Pick a room at random and add the layout. Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811770 Share on other sites More sharing options...
Serpens Posted September 9, 2016 Author Share Posted September 9, 2016 (edited) Ah yes, PlacedLayouts.layout of course has to be PlacedLayouts[layout] , thanks! But since the whole shuffle and add it to every room thing is wrong, the result is the same ^^ Quote Well, the issue in your code is that when a room runs the preinit function, when it goes to put the static layouts, it will put all of them and set all the PlacedLayouts to true. You shuffle the rooms, but you go through all of them. So all the layouts will end up in any of the rooms. Yes, as I already stated, the shuffeling is just rubbish, because I thought it would work different. If I use math.random, there is no need to shuffle it. Quote Pick a room at random and add the layout. But this won't help, if the random room does not exist in the game. E.g I never saw the room BGDirt yet ... And since I still don't know where it is defined, how often a room will occur.. I can't say for sure if the other rooms will always be there. ... That's why I added the layout to every room, with returning 1 or 0... But problem is, that I can't change the order of Initialization of room instances (I thought I could do this with the shuffle, but of course this was wrong) So how to make sure it is added to a room, that is also used ingame?! Quote You make a room, you insert it into a task. Unless this will solve all the problems for sure, I don't think it is a good idea trying to teach me how this works... cause there are literally thousand open questions I would ask you (how big will be my room? How often per world? Why do I have to add it to a task, cause the idea behind using a room, was to not use any of those existing tasks...). And I honestly don't think it is a good idea to add custom rooms... It is better to add setpieces to existing rooms, which don't have important setpieces. Quote You can make your own set pieces, with a special prefab each "serpensmarker1", "serpensmarker2", and add them to the table. I did not understand this yet... will read your other post were you mentioned those markers... So this is only to make sure, that every setpiece is placed, right? I already solved this in modmain. After the game started it checks the number of parts in the game, and if one is missing, it will spawn it at a more or less random location. Without the setpieces stuff around, but this is an easier and maybe also less time consuming solution, than generating the world again and again and again and again (eg in case the world is small and alot of other setpieces are added, this could lead to an enldess loop and this is meant by "time consuming") Edited September 9, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811776 Share on other sites More sharing options...
DarkXero Posted September 9, 2016 Share Posted September 9, 2016 (edited) 43 minutes ago, Serpens said: But this won't help, if the random room does not exist in the game. Then pick rooms that will exist Go into the tasks folder and look at the room_choices of each task. 43 minutes ago, Serpens said: (eg in case the world is small and alot of other setpieces are added, this could lead to an enldess loop and this is meant by "time consuming") Welcome to Don't Starve caves and Shipwrecked archipelago generation. It's not THAT bad. If necessary set pieces just "found another place", then the world would be great. But it doesn't happen like that. Either you stamp it wherever it falls, or you don't get it, or you don't get it and then you regenerate the world. 43 minutes ago, Serpens said: I did not understand this yet... will read your other post were you mentioned those markers... So this is only to make sure, that every setpiece is placed, right? I already solved this in modmain. Alright then. I mentioned the "markers" if you wanted to make custom set pieces with your very own prefabs. For the teleportato, it would look like this: local function GetLocationsTable() local debug = GLOBAL.debug local func = GLOBAL.AddLocation local i = 1 while true do local n, v = debug.getupvalue(func, i) if not n then return {} end if n == "locations" then return v end i = i + 1 end end local locations = GetLocationsTable() local teleportato_prefabs = { "teleportato_base", "teleportato_potato", "teleportato_crank", "teleportato_box", "teleportato_ring", } for i, prefab in ipairs(teleportato_prefabs) do table.insert(locations.forest.required_prefabs, prefab) end local teleportato_layouts = { "TeleportatoBoxLayout", "TeleportatoRingLayoutSanityRocks", -- "TeleportatoRingLayout", "TeleportatoPotatoLayout", "TeleportatoCrankLayout", "TeleportatoBaseLayout", } AddLevelPreInitAny(function(level) if level.location ~= "forest" then return end if level.ordered_story_setpieces == nil then level.ordered_story_setpieces = {} end for i, layout in ipairs(teleportato_layouts) do table.insert(level.ordered_story_setpieces, layout) end end) Edited September 9, 2016 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811792 Share on other sites More sharing options...
Serpens Posted September 9, 2016 Author Share Posted September 9, 2016 Quote Then pick rooms that will exist Go into the tasks folder and look at the room_choices of each task. I thought about it, and I found absolutely no way it would work. I mean even if I add the layouts to rooms that exist and I would make sure that it is only one layout per world, I still can't control the initialization order. And who know how the game adds rooms? Eg. it could be that it always starts on the top left with adding rooms. That way all of the layouts would be somewhere top left each time, cause they are added to the first initialized room instances. Even if I would use a math.random construction, if I return 1 or 0, I know no way to make sure that it returns 1 one time (it could be 0 always). I thought about increasing the chance everytime it returned 0, so eg. at last at the xth room it will return 1. But then again we don't know the total amount of rooms and we don't know how many rooms of each kind will be placed. So if it are 100 rooms, but I return 1 at last after the 10th room, the result won't be good. But if return 1 at last after the 90th room and there are only 20 rooms (because of small map) this also won't work. So all in all I see no way how this can work. Quote Welcome to Don't Starve caves and Shipwrecked archipelago generation. Yes... I saw a server.log from caves... At least 20 warnings each time... Btw. is there a way to reduce the water on map? I know Deja Vus Advanced World generation mod. In his mod you can increase the max size of each biome (=room?) with increasing GLOBAL.SIZE_VARIATION. But if you make the value too big, you will have an infinite error and the world tries to generate again. I tried it as big as possible, but the ~ percentage of water was still the same, only the rooms were bigger. So I guess there is somewehre defined, that it always has to be ~40% water or simular ? Quote Alright then. I mentioned the "markers" if you wanted to make custom set pieces with your very own prefabs. For the teleportato, it would look like this: Thank you. But this still only does regenerating the world, if the the setpiece is not placed succesfully, right? The chances are very high, that at least one of them is not placed, unless I have a Ignore_reserved mask. So it would really regenerate the world ~ 10 times or more often... Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811906 Share on other sites More sharing options...
DarkXero Posted September 9, 2016 Share Posted September 9, 2016 2 hours ago, Serpens said: So I guess there is somewehre defined, that it always has to be ~40% water or simular ? No. That check doesn't exist. You should post the log with the warnings to see why the world regenerates. I think the game tries to give space to all rooms. So if you want to cramp all of them into the space of a task, and you have too many of them, some might not get in, and game wouldn't like it. Instead of increasing SIZE_VARIATION, try adding more tasks to the default task set. 2 hours ago, Serpens said: But this still only does regenerating the world, if the the setpiece is not placed succesfully, right? The chances are very high, that at least one of them is not placed, unless I have a Ignore_reserved mask. So it would really regenerate the world ~ 10 times or more often... ordered_story_setpieces = { "TeleportatoRingLayout", "TeleportatoBoxLayout", "TeleportatoCrankLayout", "TeleportatoPotatoLayout", "AdventurePortalLayout", "TeleportatoBaseLayout", }, required_prefabs = { "teleportato_ring", "teleportato_box", "teleportato_crank", "teleportato_potato", "teleportato_base", "chester_eyebone", "adventure_portal", "pigking", }, This is vanilla Don't Starve. Can't go worse than that. Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-811935 Share on other sites More sharing options...
Serpens Posted September 9, 2016 Author Share Posted September 9, 2016 (edited) Spoiler 21 hours ago, DarkXero said: local function GetLocationsTable() local debug = GLOBAL.debug local func = GLOBAL.AddLocation local i = 1 while true do local n, v = debug.getupvalue(func, i) if not n then return {} end if n == "locations" then return v end i = i + 1 end end local locations = GetLocationsTable() local teleportato_prefabs = { "teleportato_base", "teleportato_potato", "teleportato_crank", "teleportato_box", "teleportato_ring", } for i, prefab in ipairs(teleportato_prefabs) do table.insert(locations.forest.required_prefabs, prefab) end local teleportato_layouts = { "TeleportatoBoxLayout", "TeleportatoRingLayoutSanityRocks", -- "TeleportatoRingLayout", "TeleportatoPotatoLayout", "TeleportatoCrankLayout", "TeleportatoBaseLayout", } AddLevelPreInitAny(function(level) if level.location ~= "forest" then return end if level.ordered_story_setpieces == nil then level.ordered_story_setpieces = {} end for i, layout in ipairs(teleportato_layouts) do table.insert(level.ordered_story_setpieces, layout) end end) I added this code now and it runs, if the mask is set to IgnoreBarren , instead of IgnoreBarren+Reserved. Of course I got warnings, that something could not be placed [00:02:36]: Warning! Could not find a spot for TeleportatoPotatoLayout in node Frogs and bugs:BG_2:BGGrass [00:02:36]: Warning! Could not find a spot for MooseNest in node Frogs and bugs:BG_5:BGGrass [00:02:36]: Warning! Could not find a spot for TeleportatoBaseLayout in node Beeeees!:3:BeeClearing [00:02:36]: Warning! Could not find a spot for WormholeGrass in node Make a pick:6:Plain [00:02:36]: Warning! Could not find a spot for MooseNest in node Forest hunters:4:Clearing [00:02:36]: Warning! Could not find a spot for TeleportatoRingLayoutSanityRocks in node Badlands:8:Lightning [00:02:36]: Warning! Could not find a spot for Maxwell2 in node Magic meadow:2:Clearing [00:02:36]: Warning! Could not find a spot for skeleton_hunter_swamp in node Squeltch:6:Marsh [00:02:36]: Warning! Could not find a spot for LivingTree in node For a nice walk:6:DeepForest so loading the world took a bit more time. But it seems the wordl was not genreated entirely again. The end result was, that the Crank and Box layouts were twice in the game. Why twice? edit: And since we are not able to add the setpieces to rooms instead of tasks, can you tell me a bit more about tasks? E.g Deja Vu in his Advanced worldgeneration mod only had a few tasks to which he added setpieces: tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"} But of course there are alot more tasks, eg. "Resource-rich Tier2" and son on. What does "locks" and "keys_given" ? Is it wise to use all those additional tasks to place the teleportato? Edit: What exactly does your code? After I deactivated the setting, the world kept generating again and again, after I tried to play with caves. 1) Maybe I have to make sure, that for cave it is not a required prefab? 2) My code was the following. The print statement was NOT printet in master server.log, but the prefab was still required. So could it be that the game has to restart until the change is undone? And there was also written, that 2 potatos were required and only 1 is there, therefore he had to generate world again (unfortunately I did not save the log) Spoiler local function GetLocationsTable() local debug = GLOBAL.debug local func = GLOBAL.AddLocation local i = 1 while true do local n, v = debug.getupvalue(func, i) if not n then return {} end if n == "locations" then return v end i = i + 1 end end if GetModConfigData("set_behaviour")==3 or GetModConfigData("set_behaviour")==4 then print("HERE "..tostring(GetModConfigData("set_behaviour"))) local locations = GetLocationsTable() for i, prefab in ipairs(teleportato_prefabs) do table.insert(locations.forest.required_prefabs, prefab) end AddLevelPreInitAny(function(level) if level.location ~= "forest" then return end if level.ordered_story_setpieces == nil then level.ordered_story_setpieces = {} end for i, layout in ipairs(teleportato_layouts) do table.insert(level.ordered_story_setpieces, layout) end end) end Edited September 10, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812025 Share on other sites More sharing options...
DarkXero Posted September 10, 2016 Share Posted September 10, 2016 2 hours ago, Serpens said: so loading the world took a bit more time. But it seems the wordl was not genreated entirely again. The end result was, that the Crank and Box layouts were twice in the game. Why twice? Because I screwed up when editing locations. modworldgenmain loaded twice so I got twice the prefabs. local require = GLOBAL.require local Layouts = require("map/layouts").Layouts Layouts["TeleportatoRingLayoutSanityRocks"] = require("map/layouts/TeleportatoRingLayoutSanityRocks") local teleportato_layouts = { "TeleportatoBoxLayout", "TeleportatoRingLayoutSanityRocks", -- "TeleportatoRingLayout", "TeleportatoPotatoLayout", "TeleportatoCrankLayout", "TeleportatoBaseLayout", } local teleportato_prefabs = { "teleportato_base", "teleportato_potato", "teleportato_crank", "teleportato_box", "teleportato_ring", } AddLevelPreInitAny(function(level) if level.location ~= "forest" then return end if level.ordered_story_setpieces == nil then level.ordered_story_setpieces = {} end if level.required_prefabs == nil then level.required_prefabs = {} end for i, layout in ipairs(teleportato_layouts) do table.insert(level.ordered_story_setpieces, layout) end for i, prefab in ipairs(teleportato_prefabs) do table.insert(level.required_prefabs, prefab) end end) I forgot you could have required_prefabs defined on the level, too. So you should do this. 2 hours ago, Serpens said: And since we are not able to add the setpieces to rooms instead of tasks, can you tell me a bit more about tasks? E.g Deja Vu in his Advanced worldgeneration mod only had a few tasks to which he added setpieces: tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"} But of course there are alot more tasks, eg. "Resource-rich Tier2" and son on. If you understood rooms, you can understand tasks. AddTask("Make a pick", { locks=LOCKS.NONE, keys_given={KEYS.PICKAXE,KEYS.AXE,KEYS.GRASS,KEYS.WOOD,KEYS.TIER1}, room_choices={ ["Forest"] = function() return 1 + math.random(SIZE_VARIATION) end, ["BarePlain"] = 1, ["Plain"] = function() return 1 + math.random(SIZE_VARIATION) end, ["Clearing"] = 1, }, room_bg=GROUND.GRASS, background_room="BGGrass", colour={r=0,g=1,b=0,a=1} }) You can see the rooms that the game will use to fill the task, and how many of them. Empty nodes will be filled by the background_room, and empty tiles that have to be filled will be filled by the room_bg. Locks and keys are involved in world generation. Game builds the map like building a story, tries to fill it with all tasks of the task set, and random picked optionaltasks. In order to put a task on the map, you need to unlock it. Look at locksandkey.lua. -- Locks are unlocked if ANY key is provided. -- However, ALL locks must be opened for a task to be unlocked. [LOCKS.HARD_MONSTERS_DEFEATED] = { KEYS.HARD_WALRUS, KEYS.HARD_SPIDERS, KEYS.HARD_HOUNDS, KEYS.HARD_MERMS, KEYS.HARD_TENTACLES, KEYS.CHESSMEN, }, In order to be able to place a task with the HARD_MONSTERS_DEFEATED lock, you need to have placed a task with any of those keys. Therefore, the tasks on the edges of the map will be the tasks that have more locks. Game starts on the "Make a pick" task, and builds from there. 2 hours ago, Serpens said: But of course there are alot more tasks, eg. "Resource-rich Tier2" and son on. These don't appear on the task set, so they aren't used at all. Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812121 Share on other sites More sharing options...
Serpens Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) @DarkXero Thank you very much how about my second edit? Quote Edit: What exactly does your code? After I deactivated the setting, the world kept generating again and again, after I tried to play with caves. 1) Maybe I have to make sure, that for cave it is not a required prefab? 2) My code was the following. The print statement was NOT printet in master server.log, but the prefab was still required. So could it be that the game has to restart until the change is undone? And there was also written, that 2 potatos were required and only 1 is there, therefore he had to generate world again (unfortunately I did not save the log) I guess it is that way: Since your code adds stuff to game tables, these will stay there as long the game is running. And as long I don't restart the whole game, everytime I create a new world with this mod, the prefabs and layouts are added again and again to that list, resulting in more than 1 each. So I would have to add controlls, if it is already in the list and remove it if setting is disabled.Now it seems to work. And it is like I wrote, at least for locations. But what if my mod is just disabled? I have to undo the changes of locations, otherwise the game won't work until restart for the users.Is there something that is called in a mod, when it gets disabled?!And: I added like you wrote the required prefabs also to the level, but the layouts are still placed twice. Spoiler [00:00:05]: SEED = 1473516132 [00:00:05]: Generating world with these parameters: [00:00:05]: level_type SURVIVAL [00:00:05]: level_data: [00:00:05]: K: 1 V: table: 16169C00 [00:00:05]: K: desc V: The standard Don't Starve experience. [00:00:05]: K: hideminimap V: false [00:00:05]: K: id V: SURVIVAL_TOGETHER [00:00:05]: K: location V: forest [00:00:05]: K: max_playlist_position V: 999 [00:00:05]: K: min_playlist_position V: 0 [00:00:05]: K: name V: Default [00:00:05]: K: numrandom_set_pieces V: 5 [00:00:05]: K: override_level_string V: false [00:00:05]: K: overrides V: table: 1616A268 [00:00:05]: K: alternatehunt V: default [00:00:05]: K: angrybees V: default [00:00:05]: K: autumn V: default [00:00:05]: K: bearger V: default [00:00:05]: K: beefalo V: default [00:00:05]: K: beefaloheat V: default [00:00:05]: K: bees V: default [00:00:05]: K: berrybush V: default [00:00:05]: K: birds V: default [00:00:05]: K: boons V: default [00:00:05]: K: branching V: default [00:00:05]: K: butterfly V: default [00:00:05]: K: buzzard V: default [00:00:05]: K: cactus V: default [00:00:05]: K: carrot V: default [00:00:05]: K: catcoon V: default [00:00:05]: K: chess V: default [00:00:05]: K: day V: default [00:00:05]: K: deciduousmonster V: default [00:00:05]: K: deerclops V: default [00:00:05]: K: dragonfly V: default [00:00:05]: K: flint V: default [00:00:05]: K: flowers V: default [00:00:05]: K: frograin V: default [00:00:05]: K: goosemoose V: default [00:00:05]: K: grass V: default [00:00:05]: K: houndmound V: default [00:00:05]: K: hounds V: default [00:00:05]: K: hunt V: default [00:00:05]: K: krampus V: default [00:00:05]: K: layout_mode V: LinkNodesByKeys [00:00:05]: K: liefs V: default [00:00:05]: K: lightning V: default [00:00:05]: K: lightninggoat V: default [00:00:05]: K: loop V: default [00:00:05]: K: lureplants V: default [00:00:05]: K: marshbush V: default [00:00:05]: K: merm V: default [00:00:05]: K: meteorshowers V: default [00:00:05]: K: meteorspawner V: default [00:00:05]: K: moles V: default [00:00:05]: K: mushroom V: default [00:00:05]: K: penguins V: default [00:00:05]: K: perd V: default [00:00:05]: K: pigs V: default [00:00:05]: K: ponds V: default [00:00:05]: K: prefabswaps V: default [00:00:05]: K: prefabswaps_start V: default [00:00:05]: K: rabbits V: default [00:00:05]: K: reeds V: default [00:00:05]: K: regrowth V: default [00:00:05]: K: roads V: default [00:00:05]: K: rock V: default [00:00:05]: K: rock_ice V: default [00:00:05]: K: sapling V: default [00:00:05]: K: season_start V: default [00:00:05]: K: spiders V: default [00:00:05]: K: spring V: default [00:00:05]: K: start_location V: default [00:00:05]: K: summer V: default [00:00:05]: K: tallbirds V: default [00:00:05]: K: task_set V: default [00:00:05]: K: tentacles V: default [00:00:05]: K: touchstone V: default [00:00:05]: K: trees V: default [00:00:05]: K: tumbleweed V: default [00:00:05]: K: walrus V: default [00:00:05]: K: weather V: default [00:00:05]: K: wildfires V: default [00:00:05]: K: winter V: default [00:00:05]: K: world_size V: small [00:00:05]: K: wormhole_prefab V: wormhole [00:00:05]: K: random_set_pieces V: table: 16169BD8 [00:00:05]: K: 1 V: Chessy_1 [00:00:05]: K: 2 V: Chessy_2 [00:00:05]: K: 3 V: Chessy_3 [00:00:05]: K: 4 V: Chessy_4 [00:00:05]: K: 5 V: Chessy_5 [00:00:05]: K: 6 V: Chessy_6 [00:00:05]: K: 7 V: ChessSpot1 [00:00:05]: K: 8 V: ChessSpot2 [00:00:05]: K: 9 V: ChessSpot3 [00:00:05]: K: 10 V: Maxwell1 [00:00:05]: K: 11 V: Maxwell2 [00:00:05]: K: 12 V: Maxwell3 [00:00:05]: K: 13 V: Maxwell4 [00:00:05]: K: 14 V: Maxwell5 [00:00:05]: K: 15 V: Maxwell6 [00:00:05]: K: 16 V: Maxwell7 [00:00:05]: K: 17 V: Warzone_1 [00:00:05]: K: 18 V: Warzone_2 [00:00:05]: K: 19 V: Warzone_3 [00:00:05]: K: required_prefabs V: table: 16169B60 [00:00:05]: K: 1 V: multiplayer_portal [00:00:05]: K: substitutes V: table: 1616A128 [00:00:05]: K: version V: 2 [00:00:05]: ####### # # Generating SURVIVAL Mode Level # ####### [00:00:05]: Applying mod to current task set [00:00:05]: K: location V: forest [00:00:05]: K: name V: Together [00:00:05]: K: numoptionaltasks V: 6 [00:00:05]: K: optionaltasks V: table: 16170B90 [00:00:05]: K: 1 V: Befriend the pigs [00:00:05]: K: 2 V: Kill the spiders [00:00:05]: K: 3 V: Killer bees! [00:00:05]: K: 4 V: Make a Beehat [00:00:05]: K: 5 V: The hunters [00:00:05]: K: 6 V: Magic meadow [00:00:05]: K: 7 V: Frogs and bugs [00:00:05]: K: 8 V: Oasis [00:00:05]: K: 9 V: Mole Colony Deciduous [00:00:05]: K: 10 V: Mole Colony Rocks [00:00:05]: K: 11 V: MooseBreedingTask [00:00:05]: K: set_pieces V: table: 16171018 [00:00:05]: K: CaveEntrance V: table: 16171540 [00:00:05]: K: count V: 10 [00:00:05]: K: tasks V: table: 16171108 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Squeltch [00:00:05]: K: 5 V: Beeeees! [00:00:05]: K: 6 V: Speak to the king [00:00:05]: K: 7 V: Forest hunters [00:00:05]: K: 8 V: Befriend the pigs [00:00:05]: K: 9 V: For a nice walk [00:00:05]: K: 10 V: Kill the spiders [00:00:05]: K: 11 V: Killer bees! [00:00:05]: K: 12 V: Make a Beehat [00:00:05]: K: 13 V: The hunters [00:00:05]: K: 14 V: Magic meadow [00:00:05]: K: 15 V: Frogs and bugs [00:00:05]: K: DragonflyArena V: table: 16170D20 [00:00:05]: K: count V: 1 [00:00:05]: K: tasks V: table: 16170C58 [00:00:05]: K: 1 V: Badlands [00:00:05]: K: MooseNest V: table: 161711F8 [00:00:05]: K: count V: 9 [00:00:05]: K: tasks V: table: 161713D8 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Beeeees! [00:00:05]: K: 3 V: Speak to the king [00:00:05]: K: 4 V: Forest hunters [00:00:05]: K: 5 V: Befriend the pigs [00:00:05]: K: 6 V: For a nice walk [00:00:05]: K: 7 V: Make a Beehat [00:00:05]: K: 8 V: Magic meadow [00:00:05]: K: 9 V: Frogs and bugs [00:00:05]: K: ResurrectionStone V: table: 16170BB8 [00:00:05]: K: count V: 2 [00:00:05]: K: tasks V: table: 16171450 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Squeltch [00:00:05]: K: 5 V: Beeeees! [00:00:05]: K: 6 V: Speak to the king [00:00:05]: K: 7 V: Forest hunters [00:00:05]: K: 8 V: Badlands [00:00:05]: K: TeleportatoBaseLayout V: table: 16171518 [00:00:05]: K: count V: 1 [00:00:05]: K: tasks V: table: 16171090 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Beeeees! [00:00:05]: K: 5 V: Speak to the king [00:00:05]: K: 6 V: Forest hunters [00:00:05]: K: 7 V: For a nice walk [00:00:05]: K: 8 V: The hunters [00:00:05]: K: 9 V: Magic meadow [00:00:05]: K: 10 V: Frogs and bugs [00:00:05]: K: 11 V: Oasis [00:00:05]: K: 12 V: Badlands [00:00:05]: K: TeleportatoBoxLayout V: table: 161711D0 [00:00:05]: K: count V: 1 [00:00:05]: K: tasks V: table: 16171338 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Beeeees! [00:00:05]: K: 5 V: Speak to the king [00:00:05]: K: 6 V: Forest hunters [00:00:05]: K: 7 V: For a nice walk [00:00:05]: K: 8 V: The hunters [00:00:05]: K: 9 V: Magic meadow [00:00:05]: K: 10 V: Frogs and bugs [00:00:05]: K: 11 V: Oasis [00:00:05]: K: 12 V: Badlands [00:00:05]: K: TeleportatoCrankLayout V: table: 161714C8 [00:00:05]: K: count V: 1 [00:00:05]: K: tasks V: table: 161714F0 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Beeeees! [00:00:05]: K: 5 V: Speak to the king [00:00:05]: K: 6 V: Forest hunters [00:00:05]: K: 7 V: For a nice walk [00:00:05]: K: 8 V: The hunters [00:00:05]: K: 9 V: Magic meadow [00:00:05]: K: 10 V: Frogs and bugs [00:00:05]: K: 11 V: Oasis [00:00:05]: K: 12 V: Badlands [00:00:05]: K: TeleportatoPotatoLayout V: table: 16171428 [00:00:05]: K: count V: 1 [00:00:05]: K: tasks V: table: 161714A0 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Beeeees! [00:00:05]: K: 5 V: Speak to the king [00:00:05]: K: 6 V: Forest hunters [00:00:05]: K: 7 V: For a nice walk [00:00:05]: K: 8 V: The hunters [00:00:05]: K: 9 V: Magic meadow [00:00:05]: K: 10 V: Frogs and bugs [00:00:05]: K: 11 V: Oasis [00:00:05]: K: 12 V: Badlands [00:00:05]: K: TeleportatoRingLayoutSanityRocks V: table: 16171400 [00:00:05]: K: count V: 1 [00:00:05]: K: tasks V: table: 16171310 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Beeeees! [00:00:05]: K: 5 V: Speak to the king [00:00:05]: K: 6 V: Forest hunters [00:00:05]: K: 7 V: For a nice walk [00:00:05]: K: 8 V: The hunters [00:00:05]: K: 9 V: Magic meadow [00:00:05]: K: 10 V: Frogs and bugs [00:00:05]: K: 11 V: Oasis [00:00:05]: K: 12 V: Badlands [00:00:05]: K: WormholeGrass V: table: 16171360 [00:00:05]: K: count V: 8 [00:00:05]: K: tasks V: table: 16171248 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Squeltch [00:00:05]: K: 5 V: Beeeees! [00:00:05]: K: 6 V: Speak to the king [00:00:05]: K: 7 V: Forest hunters [00:00:05]: K: 8 V: Befriend the pigs [00:00:05]: K: 9 V: For a nice walk [00:00:05]: K: 10 V: Kill the spiders [00:00:05]: K: 11 V: Killer bees! [00:00:05]: K: 12 V: Make a Beehat [00:00:05]: K: 13 V: The hunters [00:00:05]: K: 14 V: Magic meadow [00:00:05]: K: 15 V: Frogs and bugs [00:00:05]: K: 16 V: Badlands [00:00:05]: K: tasks V: table: 16171130 [00:00:05]: K: 1 V: Make a pick [00:00:05]: K: 2 V: Dig that rock [00:00:05]: K: 3 V: Great Plains [00:00:05]: K: 4 V: Squeltch [00:00:05]: K: 5 V: Beeeees! [00:00:05]: K: 6 V: Speak to the king [00:00:05]: K: 7 V: Forest hunters [00:00:05]: K: 8 V: Badlands [00:00:05]: K: 9 V: For a nice walk [00:00:05]: K: valid_start_tasks V: table: 16170CF8 [00:00:05]: K: 1 V: Make a pick [00:00:05]: Applying mod to current level [00:00:05]: Applying mod to current level [00:00:05]: Chessy_4 added to MooseBreedingTask [00:00:05]: ChessSpot1 added to MooseBreedingTask [00:00:05]: Maxwell5 added to Beeeees! [00:00:05]: Warzone_3 added to Mole Colony Deciduous [00:00:05]: Maxwell2 added to Great Plains [00:00:05]: New size: 350 small [00:00:05]: Creating story... [00:00:05]: LinkNodesByKeys [00:00:05]: Finding valid start task... [00:00:05]: ...picked Make a pick [00:00:05]: Has start node Clearing [00:00:05]: Baking map... 350 [00:00:05]: [WorldSimActual::GenerateVoronoiMap] [00:00:05]: GenerateVoronoiMap [1]: [00:00:05]: ...Done. [00:00:05]: [AddEmptyNodes] [00:00:05]: GenerateVoronoiMap [100]: [00:00:07]: ...Done. [00:00:07]: [WorldSimActual::GenerateVoronoiMap] complete [success] [00:00:07]: [WorldSimActual::ConvertToTileMap] [00:00:07]: [ConvertToTileMap] [00:00:07]: [WorldSimActual::ConvertToTileMap] complete [00:00:07]: [WorldSimActual::SeparateIslands] [00:00:07]: [SeparateIslands] [00:00:07]: [WorldSimActual::SeparateIslands] complete [00:00:07]: Map Baked! [00:00:07]: [WorldSimActual::ForceConnectivity] [00:00:07]: [GenerateLandmasses] [00:00:07]: [MergeConnectedLandmasses] true [00:00:07]: [WorldSimActual::ForceConnectivity] complete [00:00:07]: [GetWormholesExtra] connected 0 unconnected 1 [00:00:07]: [GetWormholesExtra] after: connected 1 unconnected 0 [00:00:07]: [GetWormholesExtra] pushed 0 wormholes [00:00:07]: [WorldSimActual::DrawRoads] [00:00:07]: [DrawRoads] [00:00:07]: [WorldSimActual::DrawRoads] complete [00:00:07]: Encoding... [00:00:07]: Encoding... DONE [00:00:07]: Checking Tags [00:00:07]: Populating voronoi... [00:00:07]: Warning! Could not find a spot for TeleportatoCrankLayout in node Great Plains:BG_35:BGSavanna [00:00:07]: Warning! Could not find a spot for Maxwell2 in node Great Plains:BG_39:BGSavanna [00:00:07]: Warning! Could not find a spot for TeleportatoBaseLayout in node Oasis:5:Badlands [00:00:07]: Warning! Could not find a spot for Ice Hounds in node Great Plains:BG_37:BGSavanna [00:00:07]: disconnected tiles... 0 [00:00:07]: PREFAB SWAP SELECTION: regular grass [00:00:07]: PREFAB SWAP SELECTION: petrified trees [00:00:07]: PREFAB SWAP SELECTION: twiggy trees [00:00:07]: PREFAB SWAP SELECTION: regular berries [00:00:07]: Badlands:BG_12:BGBadlands Cant process points [00:00:08]: Done forest map gen! [00:00:08]: Checking map... [00:00:08]: Generation complete [00:00:08]: WorldSim::SimThread::Main() complete [00:00:08]: Serializing world: session/7DC0559EB0999A58/0000000002 [00:00:08]: Unload FE [00:00:08]: Unload FE done [00:00:09]: Mod: workshop-756229217 (Teleportato) Registering prefabs [00:00:09]: Mod: workshop-756229217 (Teleportato) Registering default mod prefab [00:00:09]: LOAD BE [00:00:10]: LOAD BE: done [00:00:10]: Begin Session: 7DC0559EB0999A58 [00:00:10]: saving to server_temp/server_save [00:00:10]: MiniMapComponent::AddAtlas( minimap/minimap_data.xml ) [00:00:11]: Loading Nav Grid [00:00:13]: Reconstructing topology [00:00:13]: ...Sorting points [00:00:13]: ...Sorting edges [00:00:13]: ...Connecting nodes [00:00:13]: ...Validating connections [00:00:13]: ...Housekeeping [00:00:13]: ...Done! [00:00:13]: 1 uploads added to server. From server_temp [00:00:13]: About to start a shard with these settings: [00:00:13]: ShardName: [SHDMASTER] [00:00:13]: ShardID: 1 [00:00:13]: ShardRole: MASTER [00:00:13]: MasterHost: (null) [00:00:13]: MasterBind: 127.0.0.1 [00:00:13]: MasterPort: 10888 [00:00:13]: [Shard] Starting master server [00:00:13]: [Warning] Could not confirm port 10888 is open in the firewall. [00:00:13]: [Shard] Shard server started on port: 10888 [00:00:13]: [IPC] Signal 'DST_Master_Ready' opened #00000454 [00:00:13]: [IPC] Sending signal... #00000454 [00:00:13]: Telling Client our new session identifier: 7DC0559EB0999A58 [00:00:13]: [Steam] SteamGameServer_Init(8766, 10999, 27016) [00:00:13]: [Steam] SteamGameServer_Init success [00:00:14]: Validating portal[1] <-> <nil>[1] (inactive) [00:00:14]: Validating portal[2] <-> <nil>[2] (inactive) [00:00:14]: Validating portal[3] <-> <nil>[3] (inactive) [00:00:14]: Validating portal[4] <-> <nil>[4] (inactive) [00:00:14]: Validating portal[5] <-> <nil>[5] (inactive) [00:00:14]: Validating portal[6] <-> <nil>[6] (inactive) [00:00:14]: Validating portal[7] <-> <nil>[7] (inactive) [00:00:14]: Validating portal[8] <-> <nil>[8] (inactive) [00:00:14]: Validating portal[9] <-> <nil>[9] (inactive) [00:00:14]: Validating portal[10] <-> <nil>[10] (inactive) [00:00:14]: Sim paused [00:00:15]: [Shard] Slave Caves(495410750) connected: [LAN] 127.0.0.1 [00:00:15]: [Shard] Slave Caves(495410750) ready! [00:00:15]: World 495410750 is now connected [00:00:15]: Validating portal[1] <-> 495410750[1] (disabled) [00:00:15]: Validating portal[2] <-> 495410750[2] (disabled) [00:00:15]: Validating portal[3] <-> 495410750[3] (disabled) [00:00:15]: Validating portal[4] <-> 495410750[4] (disabled) [00:00:15]: Validating portal[5] <-> 495410750[5] (disabled) [00:00:15]: Validating portal[6] <-> 495410750[6] (disabled) [00:00:15]: Validating portal[7] <-> 495410750[7] (disabled) [00:00:15]: Validating portal[8] <-> 495410750[8] (disabled) [00:00:15]: Validating portal[9] <-> 495410750[9] (disabled) [00:00:15]: Validating portal[10] <-> 495410750[10] (disabled) [00:00:18]: New incoming connection 127.0.0.1|61899 <4285845729864385512> [00:00:18]: Client connected from [LAN] 127.0.0.1|61899 <4285845729864385512> [00:00:18]: ValidateGameSessionToken re^eyJVc2VySUQiOiJLVV9FcXg3VlFfeCIsIkdhbWUiOiJEb250U3RhcnZlVG9nZXRoZXIiLCJQdXJwb3NlIjoiR2FtZVNlc3Npb24ifQ==^eDlCMwiAw3Yv0Kfr6IFrCU3cC0ifSrju for <4285845729864385512> [00:00:18]: Client authenticated: (KU_Eqx7VQ_x) Serpens66 [00:00:18]: [Steam] Authenticated host '76561198102311542' [00:00:19]: [Shard] Read save location file for (KU_Eqx7VQ_x) [00:00:26]: Resuming user: session/7DC0559EB0999A58/KU_Eqx7VQ_x_ [00:01:42]: Spawn request: wilson from Serpens66 [00:01:42]: Skin request: (wilson_none) () () () () [00:01:42]: Spawning player at: [Fixed] (104.00, 0.00, -192.00) [00:01:42]: Serializing user: session/7DC0559EB0999A58/KU_Eqx7VQ_x_/0000000003 [00:01:42]: Sim unpaused [00:01:43]: Teleportato: Initialized [00:01:46]: Teleportato: Try to save part positions again in inst in a few seconds, cause at the moment they are: nil and 0/4 (one time is normal) [00:01:47]: Teleportato: baseposition teleportato_base : (272.87, 0.00, -91.00) [00:01:47]: Teleportato: Only one teleportato_box allowed. Remove additional one at (312.18, 0.00, 140.43) [00:01:47]: Teleportato: Only one teleportato_ring allowed. Remove additional one at (436.00, 0.00, -40.00) [00:01:47]: Teleportato: Only one teleportato_potato allowed. Remove additional one at (-14.82, 0.00, 45.00) The last entries are from my modmain, which checks if exactly 1 of each things is there after word is started. My code looks at the moment like this: Spoiler local function GetLocationsTable() local debug = GLOBAL.debug local func = GLOBAL.AddLocation local i = 1 while true do local n, v = debug.getupvalue(func, i) if not n then return {} end if n == "locations" then return v end i = i + 1 end end local locations = GetLocationsTable() for i, prefab in ipairs(teleportato_prefabs) do if GetModConfigData("set_behaviour")==3 or GetModConfigData("set_behaviour")==4 then if not table.contains(locations.forest.required_prefabs, prefab) then table.insert(locations.forest.required_prefabs, prefab) else print("HIER prefab already in locations") end else if table.contains(locations.forest.required_prefabs, prefab) then GLOBAL.RemoveByValue(locations.forest.required_prefabs, prefab) print("HIER location removed") end end end AddLevelPreInitAny(function(level) if level.location ~= "forest" then return end if level.ordered_story_setpieces == nil then level.ordered_story_setpieces = {} end if level.required_prefabs == nil then level.required_prefabs = {} end for i, layout in ipairs(teleportato_layouts) do if GetModConfigData("set_behaviour")==3 or GetModConfigData("set_behaviour")==4 then if not table.contains(level.ordered_story_setpieces,layout) then table.insert(level.ordered_story_setpieces, layout) end else if table.contains(level.ordered_story_setpieces,layout) then GLOBAL.RemoveByValue(level.ordered_story_setpieces, layout) print("HIER level setpiece removed") end end end for i, prefab in ipairs(teleportato_prefabs) do if GetModConfigData("set_behaviour")==3 or GetModConfigData("set_behaviour")==4 then if not table.contains(level.required_prefabs, prefab) then table.insert(level.required_prefabs, prefab) end else if table.contains(level.required_prefabs, prefab) then GLOBAL.RemoveByValue(level.required_prefabs, prefab) print("HIER level prefab removed") end end end end) require("map/tasks") AddLevelPreInitAny(function(level) local function Add_IIBE_Mask(layout) layout.start_mask = PLACE_MASK.IGNORE_IMPASSABLE_BARREN -- make the layouts from teleportato to ignore impassable layout.layout_position = LAYOUT_POSITION.CENTER if GetModConfigData("set_behaviour")==0 or GetModConfigData("set_behaviour")==3 then layout.fill_mask = PLACE_MASK.NORMAL elseif GetModConfigData("set_behaviour")==1 or GetModConfigData("set_behaviour")==4 then layout.fill_mask = PLACE_MASK.IGNORE_IMPASSABLE_BARREN elseif GetModConfigData("set_behaviour")==2 then layout.fill_mask = PLACE_MASK.IGNORE_IMPASSABLE_BARREN_RESERVED -- also ignore other setpieces end end local layouts = require("map/layouts") for i, v in ipairs(teleportato_layouts) do Add_IIBE_Mask(layouts.Layouts[v]) end end) AddTaskSetPreInitAny(function(tasksetdata) if tasksetdata.location ~= "forest" then return end tasksetdata.set_pieces["TeleportatoRingLayoutSanityRocks"] = { count = 1, tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"}} tasksetdata.set_pieces["TeleportatoBoxLayout"] = { count = 1, tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"}} tasksetdata.set_pieces["TeleportatoPotatoLayout"] = { count = 1, tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"}} tasksetdata.set_pieces["TeleportatoCrankLayout"] = { count = 1, tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"}} tasksetdata.set_pieces["TeleportatoBaseLayout"] = { count = 1, tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands"}} GLOBAL.dumptable(tasksetdata) end) edit:Ah I found out why it is placed twice. It seems I don't need the AddTaskSetPreInitAny() stuff anymore?! But were are the parts now placed? Overall the world? Edited September 10, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812273 Share on other sites More sharing options...
Serpens Posted September 11, 2016 Author Share Posted September 11, 2016 @DarkXeroHow to undo the locations table change I described above, when the mod is deactivated? Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812429 Share on other sites More sharing options...
DarkXero Posted September 11, 2016 Share Posted September 11, 2016 12 minutes ago, Serpens said: How to undo the locations table change I described above, when the mod is deactivated? Don't edit the locations table change. Or do the change in modmain, instead of modworldgenmain. The problem with modworldgenmain is that it runs when you enable the mod, and during world gen. So it runs twice. But instead of using a gimmick solution, please use: local require = GLOBAL.require local Layouts = require("map/layouts").Layouts Layouts["TeleportatoRingLayoutSanityRocks"] = require("map/layouts/TeleportatoRingLayoutSanityRocks") local teleportato_layouts = { "TeleportatoBoxLayout", "TeleportatoRingLayoutSanityRocks", -- "TeleportatoRingLayout", "TeleportatoPotatoLayout", "TeleportatoCrankLayout", "TeleportatoBaseLayout", } local teleportato_prefabs = { "teleportato_base", "teleportato_potato", "teleportato_crank", "teleportato_box", "teleportato_ring", } AddLevelPreInitAny(function(level) if level.location ~= "forest" then return end if level.ordered_story_setpieces == nil then level.ordered_story_setpieces = {} end if level.required_prefabs == nil then level.required_prefabs = {} end for i, layout in ipairs(teleportato_layouts) do table.insert(level.ordered_story_setpieces, layout) end for i, prefab in ipairs(teleportato_prefabs) do table.insert(level.required_prefabs, prefab) end end) The set pieces of ordered_story will be dispersed through all tasks. This replaces your TaskSetPreInitAny. And the world will regenerate if all the required prefabs aren't found. You can include the mask overrides too. So the set pieces will be forced on reserved space and you reduce the chances of having to regenerate. But with this code I didn't have issues. Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812433 Share on other sites More sharing options...
Serpens Posted September 11, 2016 Author Share Posted September 11, 2016 (edited) @DarkXero Of course you don't have issues with that, cause you removed the locations stuff? Is it need or not? I mean this code: local function GetLocationsTable() local debug = GLOBAL.debug local func = GLOBAL.AddLocation local i = 1 while true do local n, v = debug.getupvalue(func, i) if not n then return {} end if n == "locations" then return v end i = i + 1 end end local locations = GetLocationsTable() local teleportato_prefabs = { "teleportato_base", "teleportato_potato", "teleportato_crank", "teleportato_box", "teleportato_ring", } for i, prefab in ipairs(teleportato_prefabs) do table.insert(locations.forest.required_prefabs, prefab) end because this is the problematic code. It adds the prefab to the locations table. But this way of adding a prefab is evil, cause it is not undone when you start a new world, instead it is again again (so it contains it twice now). It is only resetted, when you restart the whole game. So if I don't need this, everything is fine. But if I need it, I need to know a way do undo this locations change, when the mod is deactivated.edit: Okay it seems it really works without that code, great ! So the default setting for teleportato stuff will be now: PLACE_MASK.IGNORE_IMPASSABLE_BARREN + generate new world, if one is missing This is the best combination, cause no other setpieces are on the same place And it is also great, that all tasks are used now So all in all, I think we found the best placing method possible Thank you very very much!! Edited September 11, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812458 Share on other sites More sharing options...
DarkXero Posted September 11, 2016 Share Posted September 11, 2016 39 minutes ago, Serpens said: because this is the problematic code. It adds the prefab to the locations table. But this way of adding a prefab is evil, cause it is not undone when you start a new world, instead it is again again (so it contains it twice now). It is only resetted, when you restart the whole game. So if I don't need this, everything is fine. But if I need it, I need to know a way do undo this locations change, when the mod is deactivated. Yes. It was problematic in the end. The best way turned up to be the one Klei themselves used to put the teleportato parts on the world. Link to comment https://forums.kleientertainment.com/forums/topic/69888-solved-add-own-set-pieces-to-worldgeneration/page/2/#findComment-812481 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