Skip to content

Instantly share code, notes, and snippets.

@rubenwardy
Created December 12, 2018 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/730aacc7d590e962b496adf2e50f10ee to your computer and use it in GitHub Desktop.
Save rubenwardy/730aacc7d590e962b496adf2e50f10ee to your computer and use it in GitHub Desktop.
local function always_return(v)
return function()
return v
end
end
local burner_can_put_liquid = always_return(true)
local MAX_LEVEL = 1000
local function burner_room(pos, node, side, liquid, millibuckets)
print("======= ROOM =======")
print(dump({pos, node, side, liquid, millibuckets}))
print("======= END ROOM =======")
if liquid ~= "oil:crude" then
minetest.log("error", "Attempt to put non-crude liquid into burner!")
return true
end
local meta = minetest.get_meta(pos)
return meta:get_int("level") + millibuckets < MAX_LEVEL
end
local function burner_put_liquid(pos, node, side, putter, liquid, millibuckets)
print("======= PUT LIQUID =======")
print(dump({pos, node, side, putter, liquid, millibuckets}))
print("======= END PUT LIQUID =======")
local meta = minetest.get_meta(pos)
local level = meta:get_int("level")
local to_add = millibuckets
if level + to_add > MAX_LEVEL then
to_add = MAX_LEVEL - level
end
meta:set_int("level", level + to_add)
meta:set_string("infotext", level .. " / 1000")
return millibuckets - to_add
end
minetest.register_node("oil:burner", {
description = "Burner",
tiles = { "oil_burner_off.png"},
groups = { fluid_container = 1 },
paramtype2 = "facedir",
after_place_node = node_io.update_neighbors,
after_dig_node = node_io.update_neighbors,
node_io_can_put_liquid = burner_can_put_liquid,
node_io_accepts_millibuckets = always_return(true),
node_io_room_for_liquid = always_return(false),
node_io_get_liquid_size = always_return(0),
node_io_get_liquid_name = always_return(nil),
node_io_get_liquid_stack = always_return(nil),
})
minetest.register_node("oil:burner_active", {
description = "Active Burner",
tiles = { "oil_burner_on.png"},
groups = { fluid_container = 1 },
light_source = 8,
paramtype2 = "facedir",
after_place_node = node_io.update_neighbors,
after_dig_node = node_io.update_neighbors,
node_io_can_put_liquid = burner_can_put_liquid,
node_io_put_liquid = burner_put_liquid,
node_io_accepts_millibuckets = always_return(true),
node_io_room_for_liquid = burner_room,
node_io_get_liquid_size = always_return(1),
node_io_get_liquid_name = always_return("oil:crude"),
node_io_get_liquid_stack = always_return(ItemStack("oil:crude 10")),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment