BuckarooBanzay a512f79a97 tools
2022-11-02 19:39:36 +01:00
2022-10-19 20:54:27 +02:00
2022-11-02 19:27:13 +01:00
2022-11-02 19:27:13 +01:00
2022-11-02 19:27:13 +01:00
2022-11-02 19:39:36 +01:00
2022-10-19 20:54:27 +02:00
2022-10-19 20:54:27 +02:00
2022-11-02 19:27:13 +01:00
2022-10-19 20:54:27 +02:00
2022-10-19 20:54:27 +02:00
2022-10-19 20:54:27 +02:00
2022-10-19 20:54:27 +02:00
2022-10-19 20:54:27 +02:00
2022-11-02 19:39:36 +01:00
2022-10-19 20:54:27 +02:00
2022-10-19 20:54:27 +02:00
2022-11-02 19:39:36 +01:00
2022-11-02 19:27:13 +01:00
2022-11-02 19:39:36 +01:00
2022-11-02 19:39:36 +01:00

Building register and placement library

Api

-- check if something can be built there
local success, message = building_lib.can_build(mapblock_pos, building_def)

-- build it there
local success, message = building_lib.do_build(mapblock_pos, building_def, placement_options, callback)

-- get the building at the position or nil
local building_def = building_lib.get_building_at_pos(mapblock_pos)

-- get all groups of the building on the mapblock position (returns {} if no building found)
local groups = building_lib.get_groups(mapblock_pos)

-- registers a placeable building
building_lib.register_building("buildings:my_building", {
	placement = "default",
	conditions = {
		-- OR
		on_flat_surface = true,
		on_slope = true,
		-- alternatively: OR and AND combined
		{ on_slope = true, on_biome = "grass" },
		{ on_flat_surface = true, on_biome = "water" },
	},
	schematic = "",
	-- optional groups attribute
	groups = {
		building = true
	}
})

-- registers a placement type (connected, simple, etc)
building_lib.register_placement("simple", {
	check = function(self, mapblock_pos, building_def)
		-- placement-related checks
		if ok then
			return true
		else
			return false, "not gonna happen here!"
		end
	end,
	-- place the building
	place = function(mself, apblock_pos, building_def, callback) end,
	-- return the size of the building if it would be placed there
	get_size = function(self, mapblock_pos, building_def)
		return { x=1, y=1, z=1 }
	end,
	-- validation function for startup-checks (optional)
	validate = function(self, building_def)
		return success, err_msg
	end
})

-- registers a condition that checks for certain world conditions
building_lib.register_condition("on_flat_surface", {
    can_build = function(mapblock_pos, building_def, flag_value)
		return false, msg
    end
})

Chat commands

  • /building_place <building_name>
  • /building_check <building_name>
  • /building_info

License

  • Code: MIT
  • Textures: CC-BY-SA-3.0
Description
No description provided
Readme 143 KiB
Languages
Lua 100%