add fire
This commit is contained in:
parent
05b145175e
commit
aaf80074b3
45
mods/fl_builtin/builtin_item.lua
Normal file
45
mods/fl_builtin/builtin_item.lua
Normal file
@ -0,0 +1,45 @@
|
||||
local floor = math.floor
|
||||
local min = math.min
|
||||
local item_health = 8
|
||||
local on_step = minetest.registered_entities["__builtin:item"].on_step
|
||||
local on_activate = minetest.registered_entities["__builtin:item"].on_activate
|
||||
local get_staticdata = minetest.registered_entities["__builtin:item"].get_staticdata
|
||||
|
||||
--taken from mobkit
|
||||
function timer(self,s) -- returns true approx every s seconds
|
||||
local t1 = floor(self._time_total)
|
||||
local t2 = floor(self._time_total+self._dtime)
|
||||
if t2>t1 and t2%s==0 then return true end
|
||||
end
|
||||
|
||||
minetest.registered_entities["__builtin:item"].get_staticdata = function(self)
|
||||
local data = {_memory = self._memory}
|
||||
data._old = get_staticdata(self)
|
||||
return core.serialize(data)
|
||||
end
|
||||
|
||||
minetest.registered_entities["__builtin:item"].on_activate = function(self, staticdata, dtime_s)
|
||||
local data = core.deserialize(staticdata) or {}
|
||||
if data._memory then self._memory = data._memory else self._memory = {} end
|
||||
|
||||
self._time_total = 0
|
||||
self._memory.health = self._memory.health or item_health
|
||||
|
||||
on_activate(self, data._old or "", dtime_s)
|
||||
end
|
||||
|
||||
minetest.registered_entities["__builtin:item"].on_step = function(self, dtime, moveresult)
|
||||
self._dtime = min(dtime,0.2)
|
||||
--minetest.chat_send_all("test")
|
||||
if not self._memory.thing then self._memory.thing = 1 end
|
||||
if timer(self, 1) and core.get_item_group(self.itemstring, "unburnable") == 0 then
|
||||
local node = minetest.get_node_or_nil(self.object:get_pos()) or {name = "*"}
|
||||
local def = minetest.registered_nodes[node.name] or {}
|
||||
if def.damage_per_second then self._memory.health = self._memory.health - def.damage_per_second end
|
||||
|
||||
if self._memory.health <= 0 then self.object:remove() return end
|
||||
end
|
||||
|
||||
self._time_total=self._time_total+self._dtime
|
||||
on_step(self, dtime, moveresult)
|
||||
end
|
4
mods/fl_builtin/init.lua
Normal file
4
mods/fl_builtin/init.lua
Normal file
@ -0,0 +1,4 @@
|
||||
--this mod is for overriding builtin content
|
||||
local modpath = minetest.get_modpath("fl_builtin")
|
||||
|
||||
dofile(modpath .. "/builtin_item.lua")
|
23
mods/fl_fire/init.lua
Normal file
23
mods/fl_fire/init.lua
Normal file
@ -0,0 +1,23 @@
|
||||
minetest.register_node("fl_fire:fire", {
|
||||
description = "fire",
|
||||
paramtype = "light",
|
||||
drawtype = "firelike",
|
||||
inventory_image = "farlands_fire_inv.png",
|
||||
tiles = {{
|
||||
name = "farlands_fire.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1,
|
||||
}
|
||||
}},
|
||||
light_source = 13,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
floodable = true,
|
||||
damage_per_second = 4,
|
||||
drop = "",
|
||||
groups = {dig_generic = 4, not_in_creative_inventory = 1, unburnable = 1},
|
||||
})
|
BIN
mods/fl_fire/textures/farlands_fire.png
Normal file
BIN
mods/fl_fire/textures/farlands_fire.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
mods/fl_fire/textures/farlands_fire_inv.png
Normal file
BIN
mods/fl_fire/textures/farlands_fire_inv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 635 B |
@ -21,4 +21,26 @@ minetest.register_craftitem(":fl_bucket:bucket", {
|
||||
end
|
||||
end,
|
||||
groups = {bucket = 1},
|
||||
})
|
||||
})
|
||||
|
||||
if minetest.get_modpath("fl_fire") then
|
||||
minetest.register_tool("fl_tools:flint_steel", {
|
||||
description = "flint and steel",
|
||||
inventory_image = "farlands_flint_steel.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then return end
|
||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if not node then return end
|
||||
local nodedef = minetest.registered_nodes[node.name]
|
||||
if not nodedef then return end
|
||||
if nodedef.on_ignite then
|
||||
nodedef.on_ignite(pointed_thing.under, user)
|
||||
elseif minetest.get_item_group(node.name, "flammable") >= 1 then
|
||||
minetest.set_node(pointed_thing.under, {name = "fl_fire:fire"})
|
||||
elseif nodedef.drawtype == "normal" then
|
||||
minetest.set_node(pointed_thing.above, {name = "fl_fire:fire"})
|
||||
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
BIN
mods/fl_tools/textures/farlands_flint_steel.png
Normal file
BIN
mods/fl_tools/textures/farlands_flint_steel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
@ -111,6 +111,7 @@ minetest.register_node("fl_topsoil:snow", {
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
node_placement_prediction = "",
|
||||
buildable_to = true,
|
||||
node_box = {
|
||||
type = "leveled",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.5, 0.5},
|
||||
|
Loading…
x
Reference in New Issue
Block a user