Kzisor Posted October 15, 2015 Share Posted October 15, 2015 (edited) I'm releasing my code bank to the public for those that wish to use it. LEGAL STUFF:Copyright © 2015 Kzisor/Ysovuka Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE. CODE: MOD ENGINE: engine.luamodimport("directory/engine.lua") -- replace directory with location engine.lua is located.--[[ NOTE: Because we're using the engine we no longer have to type modimport( "directory/file.lua" ) in order to load a file. Instead we use Load( "directory/file" ) note that we do not use .lua NOTE: Another side affect of using the engine is we no longer have to type GLOBAL.TUNING in order to access the TUNING table. Instead we simply type TUNING to access it, this goes for all global objects.--]]PrefabFiles = Load( "prefabs" )SetPieces setpiece.lua Prefabs prefab.luaTasks task.lua Tiles tile.lua World Generation -> Usage:-- Table to put the functions in.Map = {}modimport("directory/setpiece.lua") -- replace directory with location setpiece.lua is located.modimport("directory/prefab.lua") -- replace directory with location prefab.lua is located.modimport("directory/task.lua") -- replace directory with location task.lua is located.modimport("directory/tile.lua") -- replace directory with location tile.lua is located.--[[ This function acts as a wrapper which we will use to add our custom layout as a set piece. ------------------------------------------------------------------------------------------------------------ level_id - Level Identification (LEVELTYPE.ALL, LEVELTYPE.SURVIVAL, LEVELTYPE.CAVE, LEVELTYPE.ADVENTURE, LEVELTYPE.TEST, LEVELTYPE.UNKNOWN, LEVELTYPE.CUSTOM) layout_name - The name of the layout which we will be adding, if the layout has not already been added we will add the layout. layout_type - Layout Type (LAYOUT_TYPE.RANDOM, LAYOUT_TYPE.GROUND, LAYOUT_TYPE.ROOM) Default is LAYOUT_TYPE.RANDOM. count - The amount of set pieces we want to spawn. Default is 1. chance - The percentage change the layout will spawn. Default is 100. terrain - Identification of the ground or room. Identification must coincide with the type or it will error out. Ground Example: GROUND.GRASS or GROUND.DIRT Room Example: Badlands or BGGrass--]]-- The layout will automatically be loaded with this function, as long as the static_layout is located-- in the proper folder directory: scripts/map/static_layoutsMap.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.GROUND, count, chance, GROUND.DIRT )Map.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.GROUND, count, chance, "Any" )Map.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.ROOM, count, chance, "Graveyard" )Map.CreateSetPiece( Map.LEVELTYPE.ALL, "example", Map.LAYOUT_TYPE.RANDOM )--[[ This function acts as a wrapper which we will use to add our custom prefab to the room. ---------------------------------------------------------------------------------------- room_id - Room Identification (ex. Badlands or BGGrass) spawn_type - Spawn Type (SPAWNTYPE.RANDOM, SPAWNTYPE.STATIC) Default is SPAWNTYPE.STATIC. prefab_name - The name of the prefab which we want to spawn. count - The amount of prefbs you want to spawn. Default is 1. chance - The percentages chance the prefab has to spawn. Default is 100.--]]Map.CreateRoomPrefab( "Graveyard", Map.SPAWN_TYPE.STATIC, "cane", count, chance )Map.CreateRoomPrefab( "Graveyard", Map.SPAWN_TYPE.RANDOM, "cane", count )--[[ This function acts as a wrapper which we will use to add our custom room to a task. -------------------------------------------------------------------------- task_name - The name of the task. modification_type - Modification Type (MODIFICATION_TYPE.LOCKS, MODIFICATION_TYPE.KEYS, MODIFICATION_TYPE.ROOM_CHOICES, MODIFICATION_TYPE.GROUND, MODIFICATION_TYPE.BACKGROUND_ROOM, MODIFICATION_TYPE.COLOUR, MODIFICATION_TYPE.ENTRANCE_ROOM, MODIFICATION_TYPE.ENTRANCE_ROOM_CHANCE, MODIFICATION_TYPE.MAZE_TILES, MODIFICATION_TYPE.CROSSLINK_FACTORS, MODIFICATION_TYPE.MAKE_LOOP) ... - Depending on the modification type will depend on the acceptable additional arguments. ---------------------------------------------------------------------------- Usage Examples: Locks - ModifyTask( "task name here", MODIFICATION_TYPES.LOCKS, { key = "ADD", values = { LOCKS.TIER1 } ) Keys - ModifyTask( "task name here", MODIFICATION_TYPES.KEYS, { key = "ADD", values = { KEYS.TIER1 } ) Room_Choices - ModifyTask( "task name here", MODIFICATION_TYPES.ROOM_CHOICES, { key = "ADD", values = { ["room name here"] = 1 } } ) All Other - ModifyTask( "task name here", MODIFICATION_TYPE.X, { VALUE } )--]]Map.ModifyTask( "Magic meadow", Map.MODIFICATION_TYPE.LOCKS, { key = "ADD", values = { LOCKS.TIER2, LOCKS.TIER3 } } )Map.ModifyTask( "Magic meadow", Map.MODIFICATION_TYPE.KEYS, { key = "ADD", values = { KEYS.TIER1, KEYS.TIER2, KEYS.TIER3, KEYS.TIER4 } } )Map.ModifyTask( "Magic meadow", Map.MODIFICATION_TYPE.ROOM_CHOICES, { key = "ADD", values = { ["Graveyard"] = 1, ["BGGrass"] = 5 } } )Map.ModifyTask( "Magic meadow", Map.MODIFICATION_TYPE.GROUND, { GROUND.DIRT } )--[[ This function acts as a wrapper which we will use to create our custom task. -------------------------------------------------------------------------- level_id - Level Identification (LEVELTYPE.ALL, LEVELTYPE.SURVIVAL, LEVELTYPE.CAVE, LEVELTYPE.ADVENTURE, LEVELTYPE.TEST, LEVELTYPE.UNKNOWN, LEVELTYPE.CUSTOM) task_name - Name of the task to create. task_type - Task Type (TASK_TYPE.STATIC, TASK_TYPE.OPTIONAL) Default is TASK_TYPE.STATIC. locks - Table which holds the locks. Default is LOCKS.NONE. keys - Table which holds the keys. Default is KEYS.NONE. room_choices - Table which holds the rooms. Default is empty. room_choices_special - Currently not being used, this should be nil. ground - GROUND which the room background will contain. Default is GROUND.DIRT. background_room - Room which will be used as the background. Default is BGNoise. colour - Optional, a default is already given in every scenario it's needed. entrance_room - Room which will be used as the entrance to the maze. entrance_room_chance - Percentages chance the entrance room spawns. maze_tiles - Table which holds two tables, one rooms and one bosses. crosslink_factor - Determines if a world story will be crosslinked. Not used, but is an integer. make_loop - Determines if a world story will loop. Not used, but is a boolean.--]]Map.CreateTask( Map.LEVELTYPE.ALL, "Task Name Here", Map.TASK_TYPE.STATIC, { LOCKS.TIER1, LOCKS.TIER2 }, { KEYS.TIER1, KEYS.TIER2 }, { ["Graveyard"] = 1, ["BGGrass"] = 1 }, nil, GROUND.GRASS, "BGGrass" )Map.CreateTask( Map.LEVELTYPE.ALL, "Task Name Here", Map.TASK_TYPE.OPTIONAL, { LOCKS.TIER1, LOCKS.TIER2 }, { KEYS.TIER1, KEYS.TIER2 }, { ["Graveyard"] = 1, ["BGGrass"] = 1 }, nil, GROUND.GRASS, "BGGrass" )--[[ This function acts as a wrapper which we will use to add our custom tiles. -------------------------------------------------------------------------- tile_name - Name of the tile which will be inserted into the GROUND table. texture_name - The tiling style of the tile. See levels/tiles for the types. noise_texture - Name of the noise texture file. Noise Textures are always located at MODROOT/levels/textures/ runsound - Sound which will be played when you run on the tile. walksound - Sound which will be played when you walk on the tile. snowsound - Sound which will be played when snow is on the tile. mudsound - Sound which will be played when mud is on the tile. flashpoint_modifier - Flashpoint at which items will begin to combust while on the tile.--]]Map.CreateTile( "EXAMPLE", "blocky", "noise_example", "dontstarve/movement/run_dirt", "dontstarve/movement/walk_dirt", "dontstarve/movement/run_ice", "dontstarve/movement/run_mud", 0)DEFAULT TILE SET Don't Starve Together Tileset.zip USAGE:In Tiled after creating a new map, go to Map -> Add External -> Navigate and Select 'Don't Starve Together Tileset.tsx' NOTE: If you want to create a custom set piece with a custom world tile you must use the setpiece.lua functions from this code bank. Klei does not support this feature currently. GLOBAL -> Utility Functionsutil.lua Utility Function -> Usage:modimport("directory/util.lua") -- replace directory with location util.lua is located.--[[ This function acts as a wrapper which we will use to add our custom settings to the game. ---------------------------------------------------------------------------------------- t - Table which to input the settings. settings - Settings table which to get the settings from. --]]AddSetting( TUNING, modimport( "tuning_file.lua" ) )tuning_file.lua Example:return { -- CLOCK TOTAL_SEGS = 16, WX78_MIN_HEALTH = 150, WX78_MIN_HUNGER = 150, -- 100 For pax we are increasing this. Hungers out too easily. WX78_MIN_SANITY = 150,}I have more code in my code bank, but I have to test to make sure everything works correctly before releasing it to the public.Regards,Kzisor/Ysovuka Edited December 13, 2015 by Kzisor Link to comment Share on other sites More sharing options...
Developer PeterA Posted October 15, 2015 Developer Share Posted October 15, 2015 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM I'm going to personally hold you liable for all the awesome mods that other people make with these tools! Link to comment Share on other sites More sharing options...
Kzisor Posted October 16, 2015 Author Share Posted October 16, 2015 I'm going to personally hold you liable for all the awesome mods that other people make with these tools! It should definitely make doing set pieces, rooms, tasks, etc. a lot easier with this code. As always if anyone wants to see a real life working example of this code in action you can look at Additional Set Pieces for Don't Starve Together. Regards,Kzisor/Ysovuka Link to comment 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