---------------------------------- -- Custom Level mod example -- -- AddLevel(newlevel) -- Inserts a new level into the list of possible levels. This will cause the level -- to show up in Customization -> Presets if it's a survival level, or into the -- random playlist if it's an adventure level. -- -- AddLevelPreInit("levelname", initfn) -- Gets the raw data for a level before it's processed, allowing for modifications -- to its tasks, overrides, etc. -- -- AddLevelPreInitAny(initfn) -- Same as above, but will apply to any level that gets generated, always. -- -- AddTask(newtask) -- Inserts a task into the master tasklist, which can then be used by new or modded -- levels in their "tasks". -- -- AddTaskPreInit("taskname", initfn) -- Gets the raw data for a task before it's processed, allowing for modifications to -- its rooms and locks. -- -- AddRoom(newroom) -- Inserts a room into the master roomlist, which can then be used by new or moded -- tasks in their "room_choices". -- -- AddRoomPreInit("roomname", initfn) -- Gets the raw data for a room before it's processed, allowing for modifications to -- its prefabs, layouts, and tags. -- ----------------------------------- GLOBAL.require("map/levels") GLOBAL.require("map/tasks") GLOBAL.require("map/rooms") local LEVELTYPE = GLOBAL.LEVELTYPE local AddLevel = GLOBAL.AddLevel local AddTask = GLOBAL.AddTask local AddRoom = GLOBAL.AddRoom -- Add a new level i.e. a custom preset. AddLevel(LEVELTYPE.SURVIVAL, { id="MY_CUSTOM_LEVEL", name="My custom level", desc="This is an example of a custom level.", overrides={ {"start_setpeice", "DefaultStart"}, {"start_node", "Clearing"}, }, tasks = { "Make a pick", "Dig that rock", "Great Plains", "Squeltch", "Beeeees!", "Speak to the king", "Forest hunters", }, numoptionaltasks = 4, optionaltasks = { "Befriend the pigs", "For a nice walk", "Kill the spiders", "Killer bees!", "Make a Beehat", "The hunters", "Magic meadow", "Frogs and bugs", }, set_pieces = { ["ResurrectionStone"] = { count=2, tasks={"Make a pick", "Dig that rock", "Great Plains", "Squeltch", "Beeeees!", "Speak to the king", "Forest hunters" } }, ["WormholeGrass"] = { count=8, tasks={"Make a pick", "Dig that rock", "Great Plains", "Squeltch", "Beeeees!", "Speak to the king", "Forest hunters", "Befriend the pigs", "For a nice walk", "Kill the spiders", "Killer bees!", "Make a Beehat", "The hunters", "Magic meadow", "Frogs and bugs"} }, }, }) -- Add a custom task into survival mode default level GLOBAL.require("map/lockandkey") local LOCKS = GLOBAL.LOCKS local KEYS = GLOBAL.KEYS local GROUND = GLOBAL.GROUND AddTask("Swampalo", { locks=LOCKS.NONE, keys_given={KEYS.MEAT,KEYS.WOOL,KEYS.POOP}, room_choices={ ["BeefalowPlain"] = 5, }, room_bg=GROUND.MARSH, background_room="BGMarsh", colour={r=0.5,g=0,b=0.8,a=0.5}, }) local function SurvivalLevelInit(level) table.insert(level.tasks, "Swampalo") end -- This runs while the level is still just data as in levels.lua and not a full working level yet. --AddLevelPreInit("SURVIVAL_DEFAULT", LevelInit) AddLevelPreInitAny(SurvivalLevelInit) -- alternate version runs no matter what level is being generated -- Adds a custom room in a particular task AddRoom("LumpySwamp", { colour={r=.010,g=.010,b=.10,a=.50}, value = GROUND.MARSH, contents = { distributepercent = 0.4, distributeprefabs = { evergreen_sparse = 3, marsh_tree = 0.5, tentacle = 0.1, } } }) local function MakePickTaskPreInit(task) task.room_choices["LumpySwamp"] = 2 end -- This runs while the task is still just data as in tasks.lua and not a full working level yet. AddTaskPreInit("Make a pick", MakePickTaskPreInit) -- Modify the contents of a particular room local function BeefaloRoomPreInit(room) if not room.contents.distributeprefabs then room.contents.distributeprefabs = {} end room.contents.distributeprefabs.rock1 = 0.01 room.contents.distributepercent = 0.1 end -- This runs while the task is still just data as in rooms.lua and not a full working level yet. AddRoomPreInit("BeefalowPlain", BeefaloRoomPreInit)