re-import from eco
This commit is contained in:
parent
bd98580eb7
commit
631f7270a7
@ -119,6 +119,12 @@ function building_lib.build_mapgen(mapblock_pos, building_name, rotation)
|
||||
local building_def = building_lib.get_building(building_name)
|
||||
local placement = building_lib.get_placement(building_def.placement)
|
||||
|
||||
-- get or calculate replacements
|
||||
local replacements = building_def.replace
|
||||
if type(building_def.replace) == "function" then
|
||||
replacements = building_def.replace(mapblock_pos, building_def)
|
||||
end
|
||||
|
||||
building_lib.store:merge(mapblock_pos, {
|
||||
building = {
|
||||
name = building_def.name,
|
||||
@ -127,7 +133,7 @@ function building_lib.build_mapgen(mapblock_pos, building_name, rotation)
|
||||
}
|
||||
})
|
||||
|
||||
placement.place(placement, mapblock_pos, building_def, {}, rotation)
|
||||
placement.place(placement, mapblock_pos, building_def, replacements, rotation)
|
||||
building_lib.fire_event("placed_mapgen", {
|
||||
mapblock_pos = mapblock_pos,
|
||||
building_def = building_def,
|
||||
|
2
init.lua
2
init.lua
@ -15,6 +15,7 @@ dofile(MP .. "/api.lua")
|
||||
dofile(MP .. "/wield_events.lua")
|
||||
dofile(MP .. "/common.lua")
|
||||
dofile(MP .. "/placements/mapblock_lib.lua")
|
||||
dofile(MP .. "/placements/dummy.lua")
|
||||
dofile(MP .. "/conditions.lua")
|
||||
dofile(MP .. "/build.lua")
|
||||
dofile(MP .. "/build_tool.lua")
|
||||
@ -28,7 +29,6 @@ dofile(MP .. "/hacks.lua")
|
||||
dofile(MP .. "/mapgen.lua")
|
||||
|
||||
if minetest.get_modpath("mtt") and mtt.enabled then
|
||||
dofile(MP .. "/mtt.lua")
|
||||
dofile(MP .. "/events.spec.lua")
|
||||
dofile(MP .. "/conditions.spec.lua")
|
||||
dofile(MP .. "/build.spec.lua")
|
||||
|
9
placements/dummy.lua
Normal file
9
placements/dummy.lua
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
building_lib.register_placement("dummy", {
|
||||
check = function() return true end,
|
||||
get_size = function(_, _, building_def, rotation)
|
||||
local size = building_def.size or {x=1,y=1,z=1}
|
||||
return mapblock_lib.rotate_size(size, rotation)
|
||||
end,
|
||||
place = function(_, _, _, _, _, callback) callback() end
|
||||
})
|
12
readme.md
12
readme.md
@ -86,10 +86,14 @@ Built-in conditions:
|
||||
## Events
|
||||
|
||||
```lua
|
||||
building_lib.register_on("placed", function(mapblock_pos, playername, building_def, rotation, size) end)
|
||||
building_lib.register_on("placed_over", function(mapblock_pos, playername, old_building_def, new_building_def, rotation, size) end)
|
||||
building_lib.register_on("placed_mapgen", function(mapblock_pos, building_def, rotation) end)
|
||||
building_lib.register_on("removed", function(mapblock_pos, playername, building_info) end)
|
||||
building_lib.register_on("placed", function(event) end)
|
||||
-- event payload fields: mapblock_pos, playername, building_def, rotation, size
|
||||
building_lib.register_on("placed_over", function(event) end)
|
||||
-- event payload fields: mapblock_pos, playername, old_building_def, new_building_def, rotation, size
|
||||
building_lib.register_on("placed_mapgen", function(event) end)
|
||||
-- event payload fields: mapblock_pos, playername, building_def, rotation, size
|
||||
building_lib.register_on("removed", function(event) end)
|
||||
-- event payload fields: mapblock_pos, playername, old_building_def, building_info
|
||||
```
|
||||
|
||||
## Chat commands
|
||||
|
@ -49,7 +49,8 @@ function building_lib.remove(mapblock_pos, playername)
|
||||
building_lib.fire_event("removed", {
|
||||
mapblock_pos = origin,
|
||||
playername = playername,
|
||||
building_info = building_info
|
||||
building_info = building_info,
|
||||
old_building_def = building_lib.get_building(building_info.name)
|
||||
})
|
||||
return true
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user