Update: Electricity Update

This commit is contained in:
IamPyu 2024-09-28 12:14:08 -06:00
parent b6d0daced2
commit 2414df6c97
12 changed files with 578 additions and 629 deletions

View File

@ -1,5 +1,16 @@
# Changelog
# [Sep 27th - Sep 28th 2024] Update: The Electricity Update
- Add a new electricity system to replace the old discontinued one
- Added "devices":
- Freezer Device (Freezes nodes with freezable group)
- Heater Device (Thaws nodes with thawable group (Converts to water by default, __thaw_node in the node definition can change this))
- Added wires:
- Copper Wire
- Delayer Wire (Like Copper Wire but waits 0.2 seconds before sending a pulse, meaning 5 delayers = 1 second)
- Humans now have a chance to drop 1 to 4 apples.
# [Sep 3rd - Sep 4th 2024] Unnamed Minor Update
- Vyn forest is now a snowy forest like biome

View File

@ -12,7 +12,7 @@ PyuTestCore.make_node = function(name, desc, groups, tiles, extra_conf)
description = Translate(desc),
tiles = tiles,
groups = PyuTestCore.util.tableconcat(groups, {
block = 1
block = 1
}),
}
@ -66,482 +66,486 @@ PyuTestCore.make_building_blocks = function (name, desc, tex, colortint, cgroups
local id_fence = name.."_fence"
table.insert(PyuTestCore.building_blocks, {
name = name,
desc = desc,
tiles = tex,
groups = groups,
econf = econf
name = name,
desc = desc,
tiles = tex,
groups = groups,
econf = econf
})
minetest.register_node(id_block, PyuTestCore.util.tableconcat({
description = Translate(desc.." Block"),
tiles = tex,
groups = PyuTestCore.util.tableconcat(groups, {
solid = 1
}),
sounds = PyuTestCore.make_node_sounds(),
description = Translate(desc.." Block"),
tiles = tex,
groups = PyuTestCore.util.tableconcat(groups, {
solid = 1
}),
sounds = PyuTestCore.make_node_sounds(),
}, econf))
minetest.register_node(id_carpet, PyuTestCore.util.tableconcat({
description = Translate(desc .. " Carpet"),
tiles = tex,
groups = PyuTestCore.util.tableconcat(PyuTestCore.util.tablecopy(groups), {
attached_node = 1
}),
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.CARPET,
sounds = PyuTestCore.make_node_sounds(),
buildable_to = true
description = Translate(desc .. " Carpet"),
tiles = tex,
groups = PyuTestCore.util.tableconcat(PyuTestCore.util.tablecopy(groups), {
attached_node = 1
}),
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.CARPET,
sounds = PyuTestCore.make_node_sounds(),
buildable_to = true
}, econf))
minetest.register_node(id_slab, PyuTestCore.util.tableconcat({
description = Translate(desc.." Slab"),
tiles = tex,
groups = groups,
drawtype = "nodebox",
paramtype = "light",
node_box = PyuTestCore.node_boxes.SLAB,
sounds = PyuTestCore.make_node_sounds(),
description = Translate(desc.." Slab"),
tiles = tex,
groups = groups,
drawtype = "nodebox",
paramtype = "light",
node_box = PyuTestCore.node_boxes.SLAB,
sounds = PyuTestCore.make_node_sounds(),
}, econf))
minetest.register_node(id_pillar, PyuTestCore.util.tableconcat({
description = Translate(desc.." Pillar"),
tiles = tex,
groups = groups,
drawtype = "nodebox",
paramtype = "light",
node_box = PyuTestCore.node_boxes.PILLAR,
sounds = PyuTestCore.make_node_sounds(),
description = Translate(desc.." Pillar"),
tiles = tex,
groups = groups,
drawtype = "nodebox",
paramtype = "light",
node_box = PyuTestCore.node_boxes.PILLAR,
sounds = PyuTestCore.make_node_sounds(),
}, econf))
minetest.register_node(id_stairs, PyuTestCore.util.tableconcat({
description = Translate(desc.." Stairs"),
tiles = tex,
groups = groups,
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.STAIRS,
sounds = PyuTestCore.make_node_sounds(),
description = Translate(desc.." Stairs"),
tiles = tex,
groups = groups,
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = PyuTestCore.node_boxes.STAIRS,
sounds = PyuTestCore.make_node_sounds(),
}, econf))
minetest.register_node(id_fence, PyuTestCore.util.tableconcat({
description = Translate(desc.." Fence"),
tiles = tex,
groups = groups,
drawtype = "fencelike",
paramtype = "light",
collision_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}
},
sounds = PyuTestCore.make_node_sounds(),
description = Translate(desc.." Fence"),
tiles = tex,
groups = groups,
drawtype = "fencelike",
paramtype = "light",
collision_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}
},
sounds = PyuTestCore.make_node_sounds(),
}, econf))
minetest.register_craft({
output = id_carpet .. " 2",
recipe = {
{id_block, id_block}
}
output = id_carpet .. " 2",
recipe = {
{id_block, id_block}
}
})
minetest.register_craft({
output = id_slab .. " 3",
recipe = {
{id_block, id_block, id_block}
}
output = id_slab .. " 3",
recipe = {
{id_block, id_block, id_block}
}
})
minetest.register_craft({
output = id_pillar .. " 3",
recipe = {
{id_block},
{id_block},
{id_block}
}
output = id_pillar .. " 3",
recipe = {
{id_block},
{id_block},
{id_block}
}
})
minetest.register_craft({
output = id_stairs .. " 4",
recipe = {
{id_block, "", ""},
{id_block, id_block, ""},
{id_block, id_block, id_block}
}
output = id_stairs .. " 4",
recipe = {
{id_block, "", ""},
{id_block, id_block, ""},
{id_block, id_block, id_block}
}
})
minetest.register_craft({
output = id_fence .. " 4",
recipe = {
{id_block, "pyutest_core:stick", id_block},
{id_block, "pyutest_core:stick", id_block}
}
output = id_fence .. " 4",
recipe = {
{id_block, "pyutest_core:stick", id_block},
{id_block, "pyutest_core:stick", id_block}
}
})
end
PyuTestCore.make_building_blocks("pyutest_core:grass", "Grass", {
"pyutest-grass.png"
"pyutest-grass.png"
}, nil, {
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:dark_grass", "Dark Grass", {
"pyutest-dark-grass.png"
"pyutest-dark-grass.png"
}, nil, {
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:swampy_grass", "Swampy Grass", {
"pyutest-swampy-grass.png"
"pyutest-swampy-grass.png"
}, nil, {
ground = 1,
acid_vulnerable = 1,
sugarcane_spawn_on = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
sugarcane_spawn_on = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:savanna_grass", "Savanna Grass", {
"pyutest-savanna-grass.png"
"pyutest-savanna-grass.png"
}, nil, {
ground = 1,
acid_vulnerable = 1,
sugarcane_spawn_on = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
sugarcane_spawn_on = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:aspen_grass", "Aspen Grass", {
"pyutest-aspen-grass.png"
"pyutest-aspen-grass.png"
}, nil, {
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:jungle_grass", "Jungle Grass", {
"pyutest-jungle-grass.png"
"pyutest-jungle-grass.png"
}, nil, {
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
grass = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:dirt", "Dirt", {"pyutest-dirt.png"}, nil, {
ground = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:podzol", "Podzol", {"pyutest-podzol.png"}, nil, {
ground = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:snow", "Snow", {"pyutest-snow.png"}, nil, {
ground = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:sand", "Sand", {"pyutest-sand.png"}, nil, {
ground = 1,
acid_vulnerable = 1,
falling_node = 1,
sugarcane_spawn_on = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
acid_vulnerable = 1,
falling_node = 1,
sugarcane_spawn_on = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:mycelium", "Mycelium", {
"pyutest-mycelium.png"
"pyutest-mycelium.png"
}, nil, {
ground = 1,
crumbly = PyuTestCore.BLOCK_FAST
ground = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:clay", "Clay", {"pyutest-clay-block.png"}, nil, {
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:gravel", "Gravel", {"pyutest-gravel.png"}, nil, {
falling_node = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
falling_node = 1,
acid_vulnerable = 1,
crumbly = PyuTestCore.BLOCK_FAST
})
-- Cracky
PyuTestCore.make_building_blocks("pyutest_core:stone", "Stone", {"pyutest-stone.png"}, nil, {
ground = 1,
stone = 1,
cracky = PyuTestCore.BLOCK_NORMAL,
level = 1
ground = 1,
stone = 1,
cracky = PyuTestCore.BLOCK_NORMAL,
level = 1
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:sandstone", "Sandstone", {"pyutest-sandstone.png"}, nil, {
ground = 1,
acid_vulnerable = 1,
cracky = PyuTestCore.BLOCK_FAST,
ground = 1,
acid_vulnerable = 1,
cracky = PyuTestCore.BLOCK_FAST,
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:ice", "Ice", {"pyutest-ice.png"}, nil, {
ground = 1,
acid_vulnerable = 1,
slippery = 4,
cracky = PyuTestCore.BLOCK_FAST,
ground = 1,
acid_vulnerable = 1,
slippery = 4,
cracky = PyuTestCore.BLOCK_FAST,
thawable = 1
})
PyuTestCore.make_building_blocks("pyutest_core:molten_rock", "Molten Rock", {"pyutest-molten-rock.png"}, nil, {
ground = 1,
cracky = PyuTestCore.BLOCK_FAST,
ground = 1,
cracky = PyuTestCore.BLOCK_FAST,
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:basalt", "Basalt", {"pyutest-basalt.png"}, nil, {
ground = 1,
cracky = PyuTestCore.BLOCK_FAST,
ground = 1,
cracky = PyuTestCore.BLOCK_FAST,
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:obsidian", "Obsidian", {"pyutest-obsidian.png"}, nil, {
cracky = PyuTestCore.BLOCK_SLOW,
cracky = PyuTestCore.BLOCK_SLOW,
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:crystal_lantern", "Crystal Lantern", {"pyutest-crystal-lantern.png"}, nil, {
cracky = PyuTestCore.BLOCK_FAST
cracky = PyuTestCore.BLOCK_FAST
}, {
light_source = minetest.LIGHT_MAX
light_source = minetest.LIGHT_MAX
})
PyuTestCore.make_building_blocks("pyutest_core:bone", "Bone", {
"pyutest-bone-block-top-bottom.png",
"pyutest-bone-block-top-bottom.png",
"pyutest-bone-block.png"
"pyutest-bone-block-top-bottom.png",
"pyutest-bone-block-top-bottom.png",
"pyutest-bone-block.png"
}, nil, {
cracky = PyuTestCore.BLOCK_FAST
cracky = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:enchanted_obsidian", "Enchanted Obsidian", {
"pyutest-enchanted-obsidian.png"
"pyutest-enchanted-obsidian.png"
}, nil, {
cracky = PyuTestCore.BLOCK_SLOW
cracky = PyuTestCore.BLOCK_SLOW
}, {
is_ground_content = false
is_ground_content = false
})
PyuTestCore.make_building_blocks("pyutest_core:brick", "Brick", {"pyutest-bricks.png"}, nil, {
cracky = PyuTestCore.BLOCK_NORMAL
cracky = PyuTestCore.BLOCK_NORMAL
}, {
is_ground_content = false
is_ground_content = false
})
PyuTestCore.make_building_blocks("pyutest_core:stone_bricks", "Stone Bricks", {"pyutest-stone-bricks.png"}, nil, {
cracky = PyuTestCore.BLOCK_SLOW
cracky = PyuTestCore.BLOCK_SLOW
}, {
is_ground_content = false
is_ground_content = false
})
-- Choppy
PyuTestCore.make_building_blocks("pyutest_core:mushroom", "Mushroom", {"pyutest-mushroom.png"}, nil, {
flammable = 1,
choppy = PyuTestCore.BLOCK_FAST
flammable = 1,
choppy = PyuTestCore.BLOCK_FAST
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:mushroom_stem", "Mushroom Stem", {"pyutest-mushroom-stem.png"}, nil, {
flammable = 1,
choppy = PyuTestCore.BLOCK_FAST
flammable = 1,
choppy = PyuTestCore.BLOCK_FAST
}, {is_ground_content = false})
PyuTestCore.make_building_blocks("pyutest_core:purple_mushroom", "Purple Mushroom", {
"pyutest-purple-mushroom.png"
"pyutest-purple-mushroom.png"
}, nil, {
flammable = 1,
choppy = PyuTestCore.BLOCK_FAST
flammable = 1,
choppy = PyuTestCore.BLOCK_FAST
}, {is_ground_content = false})
-- Breakable by hand
PyuTestCore.make_building_blocks("pyutest_core:haybale", "Haybale", {
"pyutest-haybale-top-bottom.png",
"pyutest-haybale-top-bottom.png",
"pyutest-haybale.png"
"pyutest-haybale-top-bottom.png",
"pyutest-haybale-top-bottom.png",
"pyutest-haybale.png"
}, nil, {
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_building_blocks("pyutest_core:slime", "Slime", {"pyutest-slime.png"}, nil, {
bouncy = 85,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
bouncy = 85,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
})
PyuTestCore.make_node("pyutest_core:sponge", "Sponge", {
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
}, {"pyutest-sponge.png"})
PyuTestCore.make_node("pyutest_core:light", "Light", {
light = 1,
dig_immediate = 1,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
light = 1,
dig_immediate = 1,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
}, {
"pyutest-light.png"
"pyutest-light.png"
}, {
drawtype = "torchlike",
walkable = false,
paramtype = "light",
sunlight_propagates = true,
light_source = minetest.LIGHT_MAX,
floodable = true
drawtype = "torchlike",
walkable = false,
paramtype = "light",
sunlight_propagates = true,
light_source = minetest.LIGHT_MAX,
floodable = true
})
PyuTestCore.make_node("pyutest_core:torch", "Torch", {
dig_immediate = 1,
light = 1,
attached_node = 1,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
dig_immediate = 1,
light = 1,
attached_node = 1,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
}, {
"pyutest-torch.png",
"pyutest-torch.png^[transform6",
"pyutest-torch.png^[transform1"
"pyutest-torch.png",
"pyutest-torch.png^[transform6",
"pyutest-torch.png^[transform1"
}, {
light_source = minetest.LIGHT_MAX,
walkable = false,
drawtype = "torchlike",
paramtype = "light",
inventory_image = "pyutest-torch.png",
paramtype2 = "wallmounted",
floodable = true
light_source = minetest.LIGHT_MAX,
walkable = false,
drawtype = "torchlike",
paramtype = "light",
inventory_image = "pyutest-torch.png",
paramtype2 = "wallmounted",
floodable = true
})
PyuTestCore.make_node("pyutest_core:glass", "Glass", {
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
}, {"pyutest-glass.png"}, {
drawtype = "glasslike_framed",
paramtype = "light",
sunlight_propagates = true
drawtype = "glasslike_framed",
paramtype = "light",
sunlight_propagates = true
})
-- FIXME: This has been in the game for a month, implement it already!
PyuTestCore.make_node("pyutest_core:trapdoor", "Trapdoor", {
choppy = PyuTestCore.BLOCK_NORMAL,
flammable = 1
choppy = PyuTestCore.BLOCK_NORMAL,
flammable = 1
}, {"pyutest-trapdoor.png"}, {
drawtype = "nodebox",
paramtype = "light",
sunlight_propagates = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.15, 0.5}
}
drawtype = "nodebox",
paramtype = "light",
sunlight_propagates = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.15, 0.5}
}
})
PyuTestCore.make_node("pyutest_core:contagious_acid", "Contagious Acid", {
crumbly = PyuTestCore.BLOCK_NORMAL,
solid_node = 1
crumbly = PyuTestCore.BLOCK_NORMAL,
solid_node = 1
}, {"pyutest-acid.png"}, {})
PyuTestCore.make_node("pyutest_core:fire", "Fire", {
dig_immediate = 1
dig_immediate = 1
}, {"pyutest-fire.png"}, {
drawtype = "firelike",
walkable = false,
buildable_to = true,
paramtype = "light",
sunlight_propagates = true,
damage_per_second = 2,
light_source = 8,
drop = "pyutest_core:ash 4"
drawtype = "firelike",
walkable = false,
buildable_to = true,
paramtype = "light",
sunlight_propagates = true,
damage_per_second = 2,
light_source = 8,
drop = "pyutest_core:ash 4"
})
PyuTestCore.make_node("pyutest_core:tnt", "TNT", {
dig_immediate = 1,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
dig_immediate = 1,
oddly_breakable_by_hand = PyuTestCore.BLOCK_FAST
}, {
"pyutest-tnt-top-bottom.png",
"pyutest-tnt-top-bottom.png",
"pyutest-tnt-side.png" -- Affects all other sides
"pyutest-tnt-top-bottom.png",
"pyutest-tnt-top-bottom.png",
"pyutest-tnt-side.png" -- Affects all other sides
}, {
on_rightclick = function (pos, _, clicker)
local timer = minetest.get_node_timer(pos)
minetest.after(3, function()
PyuTestCore.create_explosion(pos, 3, true, 7, clicker, true)
end)
end,
on_rightclick = function (pos, _, clicker)
minetest.after(3, function()
-- minetest.remove_node(pos)
PyuTestCore.create_explosion(pos, 3, true, 7, clicker, true)
end)
end,
on_timer = function (pos)
PyuTestCore.create_explosion(pos, 3, true, 3)
end
__on_electricity_activated = function (pos, _, clicker)
minetest.after(3, function()
-- minetest.remove_node(pos)
PyuTestCore.create_explosion(pos, 3, true, 7, clicker, true)
end)
end,
})
PyuTestCore.make_node("pyutest_core:crate", "Crate", {
choppy = PyuTestCore.BLOCK_NORMAL
choppy = PyuTestCore.BLOCK_NORMAL
}, {"pyutest-crate.png"}, {
on_construct = function (pos)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
inventory:set_size("main", 8 * 4)
end,
on_construct = function (pos)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
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")
can_dig = function (pos, player)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local empty = inventory:is_empty("main")
if not empty then
minetest.chat_send_player(player:get_player_name(), "Cannot destroy crate, it's not empty!")
end
return empty
end,
on_rightclick = function (pos, node, clicker)
local spos = string.format("%d,%d,%d", pos.x, pos.y, pos.z)
local formspec =
"size[8,9]" ..
"list[nodemeta:"..spos..";main;0,0;8,4;]" ..
"list[current_player;main;0,5;8,4;]" ..
"listring[nodemeta:"..spos..";main]" ..
"listring[current_player;main]"
minetest.show_formspec(clicker:get_player_name(), string.format("pyutest_core:crate_%d_%d_%d", pos.x, pos.y, pos.z), formspec)
minetest.sound_play({name = "crate_open", gain = 1}, {pos = pos})
if not empty then
minetest.chat_send_player(player:get_player_name(), "Cannot destroy crate, it's not empty!")
end
return empty
end,
on_rightclick = function (pos, node, clicker)
local spos = string.format("%d,%d,%d", pos.x, pos.y, pos.z)
local formspec =
"size[8,9]" ..
"list[nodemeta:"..spos..";main;0,0;8,4;]" ..
"list[current_player;main;0,5;8,4;]" ..
"listring[nodemeta:"..spos..";main]" ..
"listring[current_player;main]"
minetest.show_formspec(clicker:get_player_name(), string.format("pyutest_core:crate_%d_%d_%d", pos.x, pos.y, pos.z), formspec)
minetest.sound_play({name = "crate_open", gain = 1}, {pos = pos})
end
})
PyuTestCore.make_node("pyutest_core:workbench", "Workbench", {
choppy = PyuTestCore.BLOCK_NORMAL
choppy = PyuTestCore.BLOCK_NORMAL
}, {
"pyutest-workbench-top.png",
"pyutest-workbench-bottom.png",
"pyutest-workbench-sides.png"
"pyutest-workbench-top.png",
"pyutest-workbench-bottom.png",
"pyutest-workbench-sides.png"
}, {
on_rightclick = function(pos, node, clicker)
minetest.show_formspec(clicker:get_player_name(), "pyutest_core:workbench", table.concat({
"size[8,9]",
"list[current_player;craft;2.5,1;3,3;]",
"list[current_player;main;0,5;8,4;]"
}))
end
on_rightclick = function(pos, node, clicker)
minetest.show_formspec(clicker:get_player_name(), "pyutest_core:workbench", table.concat({
"size[8,9]",
"list[current_player;craft;2.5,1;3,3;]",
"list[current_player;main;0,5;8,4;]"
}))
end
})
PyuTestCore.make_node("pyutest_core:ladder", "Ladder", {
dig_immediate = 1
dig_immediate = 1
}, {"pyutest-ladder.png"}, {
drawtype = "signlike",
paramtype = "light",
walkable = false,
climbable = true,
buildable_to = true,
sunlight_propagates = true,
paramtype2 = "wallmounted",
selection_box = {
type = "wallmounted"
},
inventory_image = "pyutest-ladder.png"
drawtype = "signlike",
paramtype = "light",
walkable = false,
climbable = true,
buildable_to = true,
sunlight_propagates = true,
paramtype2 = "wallmounted",
selection_box = {
type = "wallmounted"
},
inventory_image = "pyutest-ladder.png"
})

View File

@ -1,253 +1,172 @@
-- TODO: Bring electricity back one day.
PyuTestCore.ELECTRICITY_UPDATE_TIME = 0.1
local function set_electrified(pos, value)
local meta = minetest.get_meta(pos)
if value then
meta:set_int("electrified", 1)
else
meta:set_int("electrified", 0)
end
end
local function get_electrified(pos)
local meta = minetest.get_meta(pos)
return meta:get_int("electrified") == 1 and true or false
end
local function set_powered(pos, value)
local meta = minetest.get_meta(pos)
if value then
meta:set_int("powered", 1)
else
meta:set_int("powered", 0)
end
end
local function get_powered(pos)
local meta = minetest.get_meta(pos)
return meta:get_int("powered") == 1 and true or false
end
local function set_negated(pos, value)
local meta = minetest.get_meta(pos)
if value then
meta:set_int("negated", 1)
else
meta:set_int("negated", 0)
end
end
local function get_negated(pos)
local meta = minetest.get_meta(pos)
return meta:get_int("negated") == 1 and true or false
end
local function is_electrified(pos, log)
local positions = {
local function get_neighbours(pos)
return {
vector.new(pos.x + 1, pos.y, pos.z),
vector.new(pos.x - 1, pos.y, pos.z),
vector.new(pos.x + 1, pos.y + 1, pos.z),
vector.new(pos.x + 1, pos.y - 1, pos.z),
vector.new(pos.x - 1, pos.y - 1, pos.z),
vector.new(pos.x - 1, pos.y + 1, pos.z),
vector.new(pos.x, pos.y, pos.z + 1),
vector.new(pos.x, pos.y, pos.z - 1),
vector.new(pos.x, pos.y + 1, pos.z + 1),
vector.new(pos.x, pos.y - 1, pos.z + 1),
vector.new(pos.x, pos.y + 1, pos.z - 1),
vector.new(pos.x, pos.y - 1, pos.z - 1),
vector.new(pos.x, pos.y + 1, pos.z),
vector.new(pos.x, pos.y - 1, pos.z),
vector.new(pos.x, pos.y, pos.z + 1),
vector.new(pos.x, pos.y, pos.z - 1)
}
local result = false
for _, v in pairs(positions) do
local powered = get_powered(v)
local electrified = get_electrified(v)
local negated = get_negated(v)
if log then minetest.log(string.format("Powered: %s", tostring(powered))) end
if log then minetest.log(string.format("Negated: %s", tostring(negated))) end
if powered then
return true
end
if electrified and not negated then
result = true
break
end
if not electrified and negated then
result = true
break
end
end
return result
end
PyuTestCore.make_button = function (id, desc, groups, tiles)
PyuTestCore.make_node(id, desc, PyuTestCore.util.tableconcat(groups, {
electricity = 1
}), tiles, {
is_ground_content = false,
on_rightclick = function (pos, node, clicker)
for _, v in pairs(get_neighbours(pos)) do
local n = minetest.get_node(v)
local def = minetest.registered_nodes[n.name]
PyuTestCore.make_node("pyutest_core:copper_wire", "Copper Wire", {
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
}, {"wire.png"}, {
drawtype = "signlike",
paramtype = "light",
sunlight_propagates = true,
color = "darkgoldenrod",
walkable = false,
inventory_image = "wire.png",
paramtype2 = "wallmounted",
selection_box = {
type = "wallmounted"
},
on_construct = function (pos)
set_powered(pos, false)
local timer = minetest.get_node_timer(pos)
timer:start(PyuTestCore.ELECTRICITY_UPDATE_TIME)
end,
on_timer = function (pos)
if is_electrified(pos) then
set_electrified(pos, true)
else
set_electrified(pos, false)
if def.__on_electricity_activated then
def.__on_electricity_activated(v, n, clicker, pos)
end
end
local timer = minetest.get_node_timer(pos)
timer:start(PyuTestCore.ELECTRICITY_UPDATE_TIME)
minetest.sound_play("button", {
pos = pos,
gain = 1
})
end
})
minetest.register_craft({
output = "pyutest_core:copper_wire 16",
recipe = {
"pyutest_core:copper_ingot"
},
type = "shapeless"
})
PyuTestCore.make_node("pyutest_core:negator", "Negated Copper Wire", {
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
}, {"wire.png"}, {
drawtype = "signlike",
paramtype = "light",
sunlight_propagates = true,
color = "yellowgreen",
walkable = false,
inventory_image = "wire.png",
paramtype2 = "wallmounted",
selection_box = {
type = "wallmounted"
},
on_construct = function (pos)
set_negated(pos, true)
set_powered(pos, false)
local timer = minetest.get_node_timer(pos)
timer:start(PyuTestCore.ELECTRICITY_UPDATE_TIME)
end,
on_timer = function (pos)
if is_electrified(pos) then
set_electrified(pos, true)
else
set_electrified(pos, false)
end
local timer = minetest.get_node_timer(pos)
timer:start(PyuTestCore.ELECTRICITY_UPDATE_TIME)
end
})
PyuTestCore.make_node("pyutest_core:switch", "Switch", {
block = PyuTestCore.BLOCK_BREAKABLE_NORMAL
}, {"device.png"}, {
color = "dimgray",
on_construct = function(pos)
set_powered(pos, false)
end,
on_rightclick = function(pos)
set_powered(pos, not get_powered(pos))
end
})
PyuTestCore.make_device = function (name, desc, color, craftitem, action, setup, extra_conf)
PyuTestCore.make_node(name.."_device", desc, {
block = PyuTestCore.BLOCK_BREAKABLE_NORMAL
}, {"device.png"}, PyuTestCore.util.tableconcat({
color = color,
on_construct = function (pos)
local s = setup or function (_) end
s(pos)
local timer = minetest.get_node_timer(pos)
timer:start(PyuTestCore.ELECTRICITY_UPDATE_TIME)
end,
on_timer = function (pos)
if is_electrified(pos, true) then
action(true, pos)
else
action(false, pos)
end
local timer = minetest.get_node_timer(pos)
timer:start(PyuTestCore.ELECTRICITY_UPDATE_TIME)
end
}, extra_conf or {}))
minetest.register_craft({
output = name.."_device 4",
recipe = {
{"pyutest_core:copper_ingot", "pyutest_core:copper_ingot", "pyutest_core:copper_ingot"},
{"pyutest_core:copper_ingot", craftitem, "pyutest_core:copper_ingot"},
{"pyutest_core:copper_ingot", "pyutest_core:copper_ingot", "pyutest_core:copper_ingot"}
}
})
end
PyuTestCore.make_device("pyutest_core:time", "Time Device", "orange", "pyutest_core:light", function (e)
if not e then
minetest.chat_send_all("Not electrified!")
return
end
minetest.chat_send_all(string.format("Time: " .. os.date("%I:%M:%S", os.time())))
end)
PyuTestCore.make_wire = function (id, desc, groups, color, efn)
local fn = efn or function (def, pos, node, clicker, sender_pos)
def.__on_electricity_activated(pos, node, clicker, sender_pos)
end
PyuTestCore.make_device("pyutest_core:block_setter", "Block Setter Device", "blue", "pyutest_core:stone_block", function (e, pos)
if not e then return end
local blocks = {}
for k, _ in pairs(minetest.registered_nodes) do
local no_disallowed_blocks_match = (k ~= "ignore" and k ~= "pyutest_core:contagious_acid")
PyuTestCore.make_node(id, desc, PyuTestCore.util.tableconcat(groups, {
electricity = 1
}), {"pyutest-wire.png"}, {
drawtype = "signlike",
color = color,
paramtype = "light",
sunlight_propagates = true,
selection_box = {
type = "wallmounted"
},
walkable = false,
inventory_image = "pyutest-wire.png",
if no_disallowed_blocks_match then
table.insert(blocks, k)
__on_electricity_activated = function (pos, node, clicker, sender_pos)
for _, v in pairs(get_neighbours(pos)) do
local n = minetest.get_node(v)
local def = minetest.registered_nodes[n.name]
-- To prevent infinite loops
if v == sender_pos then
goto continue
end
if def.__on_electricity_activated then
fn(def, v, n, clicker, pos)
end
::continue::
end
end
local pos = vector.new(pos.x, pos.y + 1, pos.z)
minetest.remove_node(pos)
minetest.place_node(pos, {name = blocks[math.random(#blocks)]})
})
end
PyuTestCore.make_button("pyutest_core:button", "Button", {
cracky = PyuTestCore.BLOCK_NORMAL,
}, {"pyutest-button.png"})
PyuTestCore.make_wire("pyutest_core:copper_wire", "Copper Wire", {
snappy = PyuTestCore.BLOCK_NORMAL
}, "darkgoldenrod")
PyuTestCore.make_wire("pyutest_core:delayer_wire", "Delayer Wire", {
snappy = PyuTestCore.BLOCK_NORMAL
}, PyuTestCore.COLORS["blue"][2], function (def, pos, node, clicker, sender_pos)
minetest.after(0.2, function ()
def.__on_electricity_activated(pos, node, clicker, sender_pos)
end)
end)
PyuTestCore.make_device("pyutest_core:freezer", "Freezer Device", "skyblue", "pyutest_core:ice_block", function(e, pos)
if not e then return end
PyuTestCore.make_node("pyutest_core:test_device", "Test Device", {
choppy = PyuTestCore.BLOCK_FAST,
electricity = 1
}, {"pyutest-wood.png"}, {
__on_electricity_activated = function(pos, node, clicker)
minetest.add_item(pos + vector.new(0, 1, 0), ItemStack("pyutest_core:apple 1"))
end
})
PyuTestCore.dorange(pos, 3, function(p)
local node = minetest.get_node_or_nil(p)
if node == nil then return end
PyuTestCore.make_node("pyutest_core:freezer_device", "Freezer Device", {
cracky = PyuTestCore.BLOCK_FAST,
electricity = 1
}, {"pyutest-freezer.png"}, {
__on_electricity_activated = function(pos, node, clicker)
PyuTestCore.dorange(pos, 2, function (p)
local n = minetest.get_node(p)
if minetest.get_item_group(node.name, "water") ~= 0 then
minetest.set_node(p, {name = "pyutest_core:ice_block"})
elseif minetest.get_item_group(node.name, "lava") ~= 0 then
minetest.set_node(p, {name = "pyutest_core:hellstone_block"})
end
if minetest.get_item_group(n.name, "freezable") ~= 0 then
minetest.set_node(p, {name = "pyutest_core:ice_block"})
end
end)
end)
end
})
PyuTestCore.make_device("pyutest_core:heater", "Heater Device", "maroon", "pyutest_core:ash", function(e, pos)
if not e then return end
PyuTestCore.make_node("pyutest_core:heater_device", "Heater Device", {
cracky = PyuTestCore.BLOCK_FAST,
electricity = 1
}, {"pyutest-heater.png"}, {
__on_electricity_activated = function(pos, node, clicker)
PyuTestCore.dorange(pos, 2, function (p)
local n = minetest.get_node(p)
PyuTestCore.dorange(pos, 3, function(p)
local node = minetest.get_node_or_nil(p)
if node == nil then return end
if minetest.get_item_group(node.name, "ice") ~= 0 then
minetest.set_node(p, {name = "pyutest_core:water_source"})
end
if minetest.get_item_group(n.name, "thawable") ~= 0 then
local def = minetest.registered_nodes[n.name]
local thaw_into = def.__thaw_into or "pyutest_core:water_source"
minetest.set_node(p, {name = thaw_into})
end
end)
end)
end
})
minetest.register_craft({
output = "pyutest_core:copper_wire 4",
recipe = {
"pyutest_core:copper_ingot"
},
type = "shapeless"
})
minetest.register_craft({
output = "pyutest_core:delayer_wire",
recipe = {
"pyutest_core:copper_wire", "pyutest_core:blue_dye"
},
type = "shapeless"
})
minetest.register_craft({
output = "pyutest_core:button",
recipe = {
{"pyutest_core:stone_block", "pyutest_core:stone_block", "pyutest_core:stone_block"},
{"pyutest_core:stone_block", "pyutest_core:copper_ingot", "pyutest_core:stone_block"},
{"pyutest_core:stone_block", "pyutest_core:stone_block", "pyutest_core:stone_block"}
},
})
minetest.register_craft({
output = "pyutest_core:freezer_device",
recipe = {
{"pyutest_core:stone_block", "pyutest_core:stone_block", "pyutest_core:stone_block"},
{"pyutest_core:stone_block", "pyutest_core:ice_block", "pyutest_core:stone_block"},
{"pyutest_core:stone_block", "pyutest_core:stone_block", "pyutest_core:stone_block"}
},
})

View File

@ -46,3 +46,4 @@ dofile(PyuTestCore_Path.."/furnace.lua")
dofile(PyuTestCore_Path.."/overrides.lua")
dofile(PyuTestCore_Path.."/furniture.lua")
dofile(PyuTestCore_Path.."/electricity.lua")

View File

@ -55,7 +55,8 @@ PyuTestCore.make_liquid = function (name, desc, groups, texture, speed, extra_co
end
PyuTestCore.make_liquid("pyutest_core:water", "Water", {
water = 1
water = 1,
freezable = 1
}, "pyutest-water.png", 1, {
post_effect_color = {a=60, r=24.7, g=46.3, b=89.4},
paramtype2 = "color",

Binary file not shown.

View File

@ -59,7 +59,7 @@ minetest.register_craft({
recipe = "pyutest_core:clay_block"
})
local colors = {
PyuTestCore.COLORS = {
white = {"White", nil},
black = {"Black", {r = 32, g = 32, b = 32}},
brown = {"Brown", "saddlebrown"},
@ -73,7 +73,7 @@ local colors = {
lime = {"Lime", "#64C044"}
}
for k, v in pairs(colors) do
for k, v in pairs(PyuTestCore.COLORS) do
PyuTestCore.make_colored_blocks("pyutest_core:"..k, v[1], v[2])
end

View File

@ -69,3 +69,10 @@ unified_inventory.register_category("pyutest_inventory:solid_nodes", {
index = 10,
items = get_items_from_group("solid")
})
unified_inventory.register_category("pyutest_inventory:electricity", {
symbol = "pyutest_core:button",
label = "Electricity",
index = 11,
items = get_items_from_group("electricity")
})

View File

@ -1,129 +1,135 @@
mobs:register_mob("pyutest_mobs:monster", {
type = "monster",
hp_max = 20,
hp_min = 20,
walk_velocity = 1,
run_velocity = 3,
armor = 100,
passive = false,
walk_chance = 0,
stand_chance = 25,
damage = 2.7,
attack_chance = 1,
attack_type = "dogfight",
pathfinding = 1,
visual = "upright_sprite",
visual_size = {x = 1, y = 2},
collisionbox = PyuTestMobs.HUMAN_LIKE_CBOX,
physical = true,
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
view_range = 30,
reach = 2,
jump = 1,
group_attack = true,
makes_footstep_sound = true,
type = "monster",
hp_max = 20,
hp_min = 20,
walk_velocity = 1,
run_velocity = 3,
armor = 100,
passive = false,
walk_chance = 0,
stand_chance = 25,
damage = 2.7,
attack_chance = 1,
attack_type = "dogfight",
pathfinding = 1,
visual = "upright_sprite",
visual_size = {x = 1, y = 2},
collisionbox = PyuTestMobs.HUMAN_LIKE_CBOX,
physical = true,
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
view_range = 30,
reach = 2,
jump = 1,
group_attack = true,
makes_footstep_sound = true,
textures = {
"pyutest-monster.png", "pyutest-monster_back.png"
},
textures = {
"pyutest-monster.png", "pyutest-monster_back.png"
},
drops = {
{
name = "pyutest_core:bone",
min = 2,
max = 3,
chance = 1
}
drops = {
{
name = "pyutest_core:bone",
min = 2,
max = 3,
chance = 1
}
}
})
mobs:register_egg("pyutest_mobs:monster", "Monster Spawn Egg", "pyutest-egg.png^[multiply:darkgreen", 0)
mobs:register_mob("pyutest_mobs:human", {
type = "npc",
hp_max = 20,
hp_min = 20,
walk_velocity = 1,
run_velocity = 5,
armor = 100,
passive = true,
walk_chance = 50,
stand_chance = 50,
damage = 3,
attack_type = "dogfight",
pathfinding = 1,
visual = "upright_sprite",
visual_size = {x = 1, y = 2},
collisionbox = PyuTestMobs.HUMAN_LIKE_CBOX,
textures = {"player.png", "player_back.png"},
follow = {"pyutest_mobs:coin"},
runaway = true,
view_range = 15,
reach = 2,
fear_height = 7,
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
makes_footstep_sound = true,
drops = {
{
name = "pyutest_core:bone",
min = 2,
max = 3,
chance = 1
}
type = "npc",
hp_max = 20,
hp_min = 20,
walk_velocity = 1,
run_velocity = 5,
armor = 100,
passive = true,
walk_chance = 50,
stand_chance = 50,
damage = 3,
attack_type = "dogfight",
pathfinding = 1,
visual = "upright_sprite",
visual_size = {x = 1, y = 2},
collisionbox = PyuTestMobs.HUMAN_LIKE_CBOX,
textures = {"player.png", "player_back.png"},
follow = {"pyutest_mobs:coin"},
runaway = true,
view_range = 15,
reach = 2,
fear_height = 7,
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
makes_footstep_sound = true,
drops = {
{
name = "pyutest_core:bone",
min = 2,
max = 3,
chance = 1
},
{
name = "pyutest_core:apple",
min = 1,
max = 4,
chance = 2.5
}
}
})
mobs:register_egg("pyutest_mobs:human", "Human Spawn Egg", "pyutest-egg.png^[multiply:peachpuff", 0)
mobs:register_mob("pyutest_mobs:mimic", {
type = "monster",
hp_max = 15,
hp_min = 15,
walk_velocity = 1,
run_velocity = 3,
armor = 100,
passive = false,
stand_chance = 1,
walk_chance = 0,
damage = 4,
attack_type = "dogfight",
pathfinding = 1,
visual = "cube",
visual_size = {x = 1, y = 1, z = 1},
collisionbox = {
-0.25, -0.5, -0.25, 0.25, 0.5, 0.25
},
textures = {
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png"
},
view_range = 12,
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
reach = 2,
type = "monster",
hp_max = 15,
hp_min = 15,
walk_velocity = 1,
run_velocity = 3,
armor = 100,
passive = false,
stand_chance = 1,
walk_chance = 0,
damage = 4,
attack_type = "dogfight",
pathfinding = 1,
visual = "cube",
visual_size = {x = 1, y = 1, z = 1},
collisionbox = {
-0.25, -0.5, -0.25, 0.25, 0.5, 0.25
},
textures = {
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png",
"pyutest-crate.png"
},
view_range = 12,
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
reach = 2,
})
mobs:register_egg("pyutest_mobs:mimic", "Mimic Spawn Egg", "pyutest-egg.png^[multiply:brown", 0)
mobs:register_mob("pyutest_mobs:firefly", {
type = "animal",
hp_max = 3,
hp_min = 3,
walk_velocity = 1,
run_velocity = 3,
armor = 100,
passive = true,
stand_chance = 0,
walk_chance = 100,
fly = true,
keep_flying = true,
visual = "sprite",
visual_size = {x = 0.05, y = 0.05},
collisionbox = {
-0.0, -0.0, -0.0, 0.0, 0.0, 0.0
},
textures = {"pyutest-firefly.png"},
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
glow = 7,
type = "animal",
hp_max = 3,
hp_min = 3,
walk_velocity = 1,
run_velocity = 3,
armor = 100,
passive = true,
stand_chance = 0,
walk_chance = 100,
fly = true,
keep_flying = true,
visual = "sprite",
visual_size = {x = 0.05, y = 0.05},
collisionbox = {
-0.0, -0.0, -0.0, 0.0, 0.0, 0.0
},
textures = {"pyutest-firefly.png"},
blood_amount = PyuTestMobs.ENTITY_BLOOD_AMOUNT,
glow = 7,
})
mobs:register_egg("pyutest_mobs:firefly", "Firefly Spawn Egg", "pyutest-egg.png^[multiply:yellow", 0)

BIN
textures/pyutest-button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
textures/pyutest-heater.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B