Predefined firework explosion size
This commit is contained in:
parent
d4ca99f09e
commit
954ba26bb6
@ -202,3 +202,19 @@ tt.register_snippet(function(itemstring, _, itemstack)
|
|||||||
|
|
||||||
return s:trim()
|
return s:trim()
|
||||||
end)
|
end)
|
||||||
|
tt.register_snippet(function(itemstring, _, itemstack)
|
||||||
|
if not itemstack then return end
|
||||||
|
local def = itemstack:get_definition()
|
||||||
|
if not def then return end
|
||||||
|
|
||||||
|
if not def._vl_fireworks_star then return end
|
||||||
|
|
||||||
|
local s = ""
|
||||||
|
local meta = itemstack:get_meta()
|
||||||
|
local effect = meta:get("vl_fireworks:star_effect") or core.serialize({fn="generic"})
|
||||||
|
if effect then
|
||||||
|
s = vl_fireworks.star_tt(core.deserialize(effect))
|
||||||
|
end
|
||||||
|
|
||||||
|
return s
|
||||||
|
end)
|
||||||
|
@ -4,6 +4,37 @@ core.register_craft({ -- temporary
|
|||||||
output = "vl_fireworks:firework_star",
|
output = "vl_fireworks:firework_star",
|
||||||
recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump"}
|
recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump"}
|
||||||
})
|
})
|
||||||
|
core.register_craft({ -- temporary
|
||||||
|
type = "shapeless",
|
||||||
|
output = "vl_fireworks:firework_star",
|
||||||
|
recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump", "mcl_fire:fire_charge"}
|
||||||
|
})
|
||||||
|
core.register_craft({ -- temporary
|
||||||
|
type = "shapeless",
|
||||||
|
output = "vl_fireworks:firework_star",
|
||||||
|
recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump", "mcl_end:crystal"}
|
||||||
|
})
|
||||||
|
|
||||||
|
local function craft_star(itemstack, player, old_grid)
|
||||||
|
if itemstack:get_name() ~= "vl_fireworks:firework_star" then return end
|
||||||
|
local size = 1
|
||||||
|
|
||||||
|
-- analyze the recipe used
|
||||||
|
for _, item in pairs(old_grid) do
|
||||||
|
if item:get_name() == "mcl_fire:fire_charge" then size = 2 end
|
||||||
|
if item:get_name() == "mcl_end:crystal" then size = 3 end
|
||||||
|
end
|
||||||
|
|
||||||
|
local effect = {
|
||||||
|
fn = "generic",
|
||||||
|
size = size
|
||||||
|
}
|
||||||
|
itemstack:get_meta():set_string("vl_fireworks:star_effect", core.serialize(effect))
|
||||||
|
tt.reload_itemstack_description(itemstack)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
core.register_craft_predict(craft_star)
|
||||||
|
core.register_on_craft(craft_star)
|
||||||
|
|
||||||
-- Firework Rocket
|
-- Firework Rocket
|
||||||
local function register_firework_crafts()
|
local function register_firework_crafts()
|
||||||
|
@ -9,8 +9,9 @@ local function explode(self, pos, stars)
|
|||||||
mcl_mobs.mob_class.safe_boom(self, pos, 1)
|
mcl_mobs.mob_class.safe_boom(self, pos, 1)
|
||||||
if not stars then return end
|
if not stars then return end
|
||||||
for _, effect in pairs(stars) do
|
for _, effect in pairs(stars) do
|
||||||
|
if type(effect) == "string" then effect = core.deserialize(effect) end
|
||||||
if effect.fn == "generic" then
|
if effect.fn == "generic" then
|
||||||
vl_fireworks.generic_particle_explosion(pos)
|
vl_fireworks.generic_particle_explosion(pos, effect.size or 1)
|
||||||
end
|
end
|
||||||
-- TODO implement other handlers
|
-- TODO implement other handlers
|
||||||
end
|
end
|
||||||
@ -185,10 +186,8 @@ local firework_def = {
|
|||||||
local retval = S("Duration:") .. " " .. duration
|
local retval = S("Duration:") .. " " .. duration
|
||||||
|
|
||||||
for _, effect in pairs(stars) do
|
for _, effect in pairs(stars) do
|
||||||
retval = retval .. "\n\n"
|
if type(effect) == "string" then effect = core.deserialize(effect) end
|
||||||
if effect.fn == "generic" then
|
retval = retval .. "\n\n" .. vl_fireworks.star_tt(effect)
|
||||||
retval = retval .. S("Generic Firework Star")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
@ -7,7 +7,19 @@ minetest.register_craftitem("vl_fireworks:firework_star", {
|
|||||||
inventory_image = "vl_fireworks_star.png",
|
inventory_image = "vl_fireworks_star.png",
|
||||||
groups = { craftitem = 1 },
|
groups = { craftitem = 1 },
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
|
|
||||||
|
_vl_fireworks_star = true
|
||||||
})
|
})
|
||||||
|
|
||||||
-- TODO tt snippets
|
function vl_fireworks.star_tt(effect)
|
||||||
|
local s = ""
|
||||||
|
if effect.fn == "generic" then
|
||||||
|
s = S("Generic Firework Star")
|
||||||
|
end
|
||||||
|
if effect.size then
|
||||||
|
s = s .. "\nSize: " .. effect.size
|
||||||
|
end
|
||||||
|
return s:trim()
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO image handlers
|
-- TODO image handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user