* return stack handler function * defer item consumption until later mainly after all checks have been done otherwise items get used even if they can't be placed * pointed_thing rework after this change, nodes don't skip to neighbour coordinates anymore. This commit also gives users the ability to define direction of pointed_thing. It leaves open the posibility of non-directional pointed_thing, which could cause trouble but from the experience with replacer:replacer, these seem to be only few edge cases where a zero-orientation pointed_thing causes trouble. In my tests, all the facedir nodes I tried are positioned correctly. Some of the wallmounted are still not working. * improve item usage items with metadata can alter the result: a new technic:river_water_can is empty where as the one in the inventory may contain water. * improve return stack handling some items return empty or less full containers also snuck in ammendment to item usage in this commit * enforce param2 again replacer:replacer experience: enforce rotation. In the case of replacer, we know that a node had that setting, so we could assume this was legal. Here user can set arbitrary param2, but the previous checks seem to protect from e.g. building rotated water. * comments about inventory check * debug messages * satisfy luacheck * add a default pointed_thing.under to avoid zero-orientation bugs * add back the digtron-way of pointe_thing handling but only when user does not specify a direction * adds neutral orientation option because that was what worked best before a default was added back last two commits * give fake player inventory This enables using items such as seeds. This commit also adds inventory scan for best item. e.g. technic cans, look for fullest. Maybe in a later commit we'll simplify and only check for next non-empty item. Good news, placing river water on river water fails without consuming any :) Also seeds that couldn't be placed are returned. * does this satisfy luacheck? * adds examples of special nodes - cable plates around a stone - a box of slabs containing water * update readme explaining pointed_thing handling * give fake player a position and look direction Because this might help with some nodes. Have no imperical data to support this yet. * removes neutral field adds auto field This commit makes neutral i.e. non directional pointed_thing the default again. It adds auto-field to allow digtron-style handling based on param2 * move predefined param2 override up It makes more sense to check this before setting pointed_thing, am I wrong? * debug messages * remove debug crud * adjust for luacheck
46 lines
1.1 KiB
Lua
46 lines
1.1 KiB
Lua
-- places a box of slabs and places water inside it
|
|
|
|
local s = "moreblocks:slab_super_glow_glass_1"
|
|
local w = "bucket:bucket_river_water"
|
|
-- list of setnode commands
|
|
local data = {
|
|
{ name = s, param2 = 21, pos = { x = 0, y = 1, z = 0 } },
|
|
{ name = s, param2 = 3, pos = { x = 0, y = 3, z = 0 } },
|
|
{ name = s, param2 = 11, pos = { x = 0, y = 2, z = -1 } },
|
|
{ name = s, param2 = 5, pos = { x = 0, y = 2, z = 1 } },
|
|
{ name = s, param2 = 12, pos = { x = 1, y = 2, z = 0 } },
|
|
{ name = s, param2 = 18, pos = { x = -1, y = 2, z = 0 } },
|
|
{ name = w, pos = { x = 0, y = 2, z = 0 }
|
|
}
|
|
}
|
|
|
|
-- initial start
|
|
if event.type == "program" then
|
|
mem.pos = 1
|
|
interrupt(1)
|
|
end
|
|
|
|
-- timer interrupt
|
|
if event.type == "interrupt" then
|
|
local entry = data[mem.pos]
|
|
if not entry then
|
|
-- done
|
|
return
|
|
end
|
|
|
|
entry.command = "setnode"
|
|
digiline_send("digibuilder", entry)
|
|
end
|
|
|
|
-- callback from digibuilder node
|
|
if event.type == "digiline" and event.channel == "digibuilder" then
|
|
if event.error then
|
|
-- error state
|
|
error(event.message)
|
|
end
|
|
|
|
-- next command
|
|
mem.pos = mem.pos + 1
|
|
interrupt(1)
|
|
end
|