Improve Fireworks and Crates

This commit is contained in:
IamPyu 2024-11-15 18:21:17 -06:00
parent 01ec9cdbf5
commit 98eb370326
7 changed files with 70 additions and 51 deletions

View File

@ -11,6 +11,7 @@ I should just start giving updates a version number to avoid naming updates.
- Grass Plants and Ferns now require Shears to be obtained
- Added Paper
- Added various new colored blocks variants (How will I make flowers for all of these?)
- Crates now drop what's contained inside of them instead of not allowing the player to destroy it.
## [Oct 20th - Nov 2nd] Update: The Something Update

View File

@ -1,16 +1,16 @@
minetest.register_entity("pyutest_fireworks:firework", {
initial_properties = {
visual = "upright_sprite",
textures = {"pyutest-firework.png", "pyutest-firework.png"},
textures = { "pyutest-firework.png", "pyutest-firework.png" },
physical = true,
glow = minetest.LIGHT_MAX
},
on_activate = function (self)
on_activate = function(self)
self.object:set_velocity(vector.new(0, 10, 0))
end,
on_step = function (self, dtime)
on_step = function(self, dtime)
local vel = self.object:get_velocity()
if vel.y < 0 then
self:explode()
@ -23,20 +23,39 @@ minetest.register_entity("pyutest_fireworks:firework", {
self:trail()
end,
trail = function (self)
local pos = self.object:get_pos() - vector.new(0, .5, 0)
trail = function(self)
local pos = self.object:get_pos() - vector.new(0, 1, 0)
minetest.add_particle({
pos = pos,
size = 1.2,
expirationtime = 0.6,
glow = minetest.LIGHT_MAX,
vertical = true,
texture = "pyutest-firework-blast.png"
})
local velocity = vector.new(math.random(-1, 1), 0, math.random(-1, 1))
if math.random(1, 2) == 1 then
minetest.add_particle({
pos = pos,
size = 1.2,
expirationtime = 0.6,
glow = minetest.LIGHT_MAX,
vertical = true,
velocity = velocity,
collisiondetection = true,
collision_removal = true,
texture = "pyutest-firework-trail1.png"
})
else
minetest.add_particle({
pos = pos,
size = 1.2,
expirationtime = 0.6,
glow = minetest.LIGHT_MAX,
vertical = true,
velocity = velocity,
collisiondetection = true,
collision_removal = true,
texture = "pyutest-firework-trail2.png"
})
end
end,
explode = function (self)
explode = function(self)
local color = {
r = math.random(50, 255),
g = math.random(50, 255),
@ -61,7 +80,7 @@ minetest.register_entity("pyutest_fireworks:firework", {
minpos = pos,
maxpos = pos,
minvel = vector.new(-6, -6, -6),
maxvel = vector.new( 6, 6, 6),
maxvel = vector.new(6, 6, 6),
})
minetest.sound_play({
@ -74,7 +93,7 @@ minetest.register_entity("pyutest_fireworks:firework", {
})
PyuTest.make_item("pyutest_fireworks:firework", "Firework", {}, "pyutest-firework.png", {
on_place = function (itemstack, placer, pointed_thing)
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.above
minetest.add_entity(pos, "pyutest_fireworks:firework")

View File

@ -125,16 +125,13 @@ PyuTest.make_node("pyutest_blocks:crate", "Crate", {
inventory:set_size("main", 8 * 4)
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local empty = inventory:is_empty("main")
on_destruct = function (pos)
local drops = {}
PyuTest.get_inventory_drops(pos, "main", drops)
if not empty then
minetest.chat_send_player(player:get_player_name(), "Cannot destroy crate, it's not empty!")
for _, v in pairs(drops) do
minetest.add_item(pos, v)
end
return empty
end,
on_rightclick = function(pos, node, clicker)

View File

@ -1,14 +1,14 @@
PyuTest.make_grass = function (name, desc, groups, color, ttex, stex, dtex, econf)
local _ttex = {name = ttex or "pyutest-grass-top.png", color = color}
local _stex = {name = stex or "pyutest-grass-side.png", color = color}
local _dtex = {_ttex, dtex or "pyutest-dirt.png"}
PyuTest.make_grass = function(name, desc, groups, color, dont_make_flora, ttex, stex, dtex, econf)
local _ttex = { name = ttex or "pyutest-grass-top.png", color = color }
local _stex = { name = stex or "pyutest-grass-side.png", color = color }
local _dtex = { _ttex, dtex or "pyutest-dirt.png" }
PyuTest.make_building_blocks(name, desc, _dtex, nil, PyuTest.util.tableconcat(groups or {}, {
ground = 1,
grass = 1,
dirt = 1,
}), {
overlay_tiles = {"", "", _stex}
overlay_tiles = { "", "", _stex }
})
local function make_drops(name)
@ -16,48 +16,50 @@ PyuTest.make_grass = function (name, desc, groups, color, ttex, stex, dtex, econ
max_items = 1,
items = {
{
tool_groups = {
"shears"
},
items = {name}
tool_groups = {
"shears"
},
items = { name }
}
}
}
end
PyuTest.make_flower(name.."_plant", desc .. " Plant", "pyutest-grass-plant.png", nil, false, nil, {
color = color,
drop = make_drops(name.."_plant")
})
if dont_make_flora ~= true then
PyuTest.make_flower(name .. "_plant", desc .. " Plant", "pyutest-grass-plant.png", nil, false, nil, {
color = color,
drop = make_drops(name .. "_plant")
})
PyuTest.make_flower(name.."_fern", desc .. " Fern", "pyutest-fern.png", nil, false, nil, {
color = color,
drop = make_drops(name.."_fern")
})
PyuTest.make_flower(name .. "_fern", desc .. " Fern", "pyutest-fern.png", nil, false, nil, {
color = color,
drop = make_drops(name .. "_fern")
})
end
minetest.override_item(name.."_block", econf or {})
minetest.override_item(name .. "_block", econf or {})
minetest.register_craft({
output = name.."_block 2",
output = name .. "_block 2",
recipe = {
name.."_block", "pyutest_blocks:dirt_block"
name .. "_block", "pyutest_blocks:dirt_block"
},
type = "shapeless"
})
minetest.register_decoration({
deco_type = "simple",
place_on = {name.."_block"},
place_on = { name .. "_block" },
sidelen = 16,
fill_ratio = 0.048,
decoration = name.."_plant"
decoration = name .. "_plant"
})
minetest.register_decoration({
deco_type = "simple",
place_on = {name.."_block"},
place_on = { name .. "_block" },
sidelen = 16,
fill_ratio = 0.022,
decoration = name.."_fern"
decoration = name .. "_fern"
})
end
@ -101,7 +103,7 @@ PyuTest.make_grass("pyutest_grass:snowy_grass", "Snowy Grass", {
PyuTest.make_grass("pyutest_grass:dirt_path", "Dirt Path", {
crumbly = PyuTest.BLOCK_FAST,
acid_vulnerable = 1,
}, "#d9a066", nil, nil, nil, {
}, "#d9a066", true, nil, nil, nil, {
drawtype = "nodebox",
node_box = PyuTest.NODE_BOXES.SLIGHTLY_SMALLER,
collision_box = PyuTest.NODE_BOXES.SLIGHTLY_SMALLER,

View File

@ -42,8 +42,8 @@ unified_inventory.register_category("pyutest_inventory:minerals", {
})
unified_inventory.register_category("pyutest_inventory:colored", {
symbol = "pyutest_wool:yellow_wool_block",
label = "Colored Blocks",
symbol = "pyutest_wool:red_wool_block",
label = "Colored Items",
index = 7,
items = get_items_from_group("colored")
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B