Jump to content

Recommended Posts

So I have like 9-10 set pieces for a mod I'm making with friends, but I think the code I have is depreciated. It can't tell what "StaticLayout.Get" is anymore even if it's defined in the code.

Actually, this is the code I have now.

Layouts["HomeCamp"] = StaticLayout.Get("map/static_layouts/fh")
Layouts["Trap1"] = StaticLayout.Get("map/static_layouts/trap1")
Layouts["Trap2"] = StaticLayout.Get("map/static_layouts/trap2")
Layouts["Trap3"] = StaticLayout.Get("map/static_layouts/trap3")
Layouts["Trap4"] = StaticLayout.Get("map/static_layouts/trap4")
AddTaskSetPreInitAny(function(tasksetdata)
	print("TaskPreinit for R.R")
		if tasksetdata.location ~= "forest" then
			print("Bailing!")
			return
		end
	print("Applying!")

	tasksetdata.numoptionaltasks = GetModConfigData("HomeCamps")
	tasksetdata.set_pieces["HomeCamp"] = { count = GetModConfigData("HomeCamps"), tasks={"Make a pick", "Dig that rock", "Great Plains", "Squeltch", "Beeeees!", "Speak to the king", "Forest hunters"}}
		tasksetdata.numoptionaltasks = GetModConfigData("DeathTraps")
	tasksetdata.set_pieces["Trap1"] = { count = GetModConfigData("DeathTraps"), tasks={"Insanity-Blocked Necronomicon", "Necronomicon", "Badlands"}}
	tasksetdata.set_pieces["Trap2"] = { count = GetModConfigData("DeathTraps"), tasks={"Insanity-Blocked Necronomicon", "Necronomicon", "Badlands"}}
	tasksetdata.set_pieces["Trap3"] = { count = GetModConfigData("DeathTraps"), tasks={"Insanity-Blocked Necronomicon", "Necronomicon", "Badlands"}}
	tasksetdata.set_pieces["Trap4"] = { count = GetModConfigData("DeathTraps"), tasks={"Insanity-Blocked Necronomicon", "Necronomicon", "Badlands"}}

	GLOBAL.dumptable(tasksetdata)

And I saw nothing in the posts about the new world gen code pertaining to set pieces, which sucks because set pieces is one way I tell lore in a mod. Could I get some help?:wilson_cry:

Edited by DextersComicLaboratory
require("constants")
local StaticLayout = require("map/static_layout")

return  StaticLayout.Get("map/static_layouts/adventure_portal_layoutnew", {
                            start_mask = PLACE_MASK.IGNORE_IMPASSABLE_BARREN,
                            fill_mask = PLACE_MASK.IGNORE_IMPASSABLE_BARREN_RESERVED,
						})

This is in my scripts/map/layouts folder for a new layout AdventurePortalLayoutNew.lua, but you can put it into modmain direclty (without the return of course)

The start_mask and fill_mask are the placing style. This is important if you want your setpiece 100% placed, even if the place is already blocked or not. The settings I made here are the best I think.

In my modmain is :

local Layouts = GLOBAL.require("map/layouts").Layouts
Layouts["AdventurePortalLayoutNew"] = require("map/layouts/AdventurePortalLayoutNew")



you use "numoptionaltasks" twice in your mod. So with the second time you overwirte your first change.
and this optionaltasks has nothing to do with setpieces. So to add setpieces, dont change this value.
You use it to add more tasks like "Make a pick" and so on to the whole world. You only should change this, if you really know what you are doing and want to create a completely different world. (I use it eg. to create the adventure worlds from DS)

The tasks you list in your "tasksetdata.set_pieces..." can only be tasked, that are actually used in the game. So e.g your insanity_blocked thing is by default not used.

If you need more examples, you can take a look at mods I made at steam, e.g "Increase animals":
http://steamcommunity.com/sharedfiles/filedetails/?id=758921911
(I learned all I know about worldgen of course from great DarkXero :) )

edit:
finished editing :D  post changed a bit ;)

Edited by Serpens
26 minutes ago, Serpens said:

I use this to add new setpieces (in my teleportato mod):
 


local Layouts = require("map/layouts").Layouts
Layouts["TeleportatoRingLayoutSanityRocks"] = require("map/layouts/TeleportatoRingLayoutSanityRocks")

    AddTaskSetPreInitAny(function(tasksetdata)
        if tasksetdata.location ~= "forest" then
            return
        end
        if GetModConfigData("DSlike") then
            tasksetdata.set_pieces["TeleportatoRingLayout"] = { 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"}}
        else
            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"}}
        end
    end)

you use "numoptionaltasks" twice in your mod. So with the second time you overwirte your first change.
and this optionaltasks has nothing to do with setpieces. So to add setpieces, dont change this value.
You use it to add more tasks like "Make a pick" and so on to the whole world. You only should change this, if you really know what you are doing and want to create a completely different world. (I use it eg. to create the adventure worlds from DS)

46: attempt to call global 'require' (a nil value)

Are you sure

15 minutes ago, DextersComicLaboratory said:

I put it back in and we still crashed.

Maybe I need to sit down or something.

maybe it also helps to read my post again. I edited it to make it more clear with another example. If you do it exactly the same way, it will work 100% (of course in addition to your AddTaskSetPreInitAny function)

Edited by Serpens

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...