Change some stuff, mostly electricity related.

This commit is contained in:
IamPyu 2024-10-01 22:03:45 -06:00
parent 2ce0077927
commit 0e87b2c9a2
10 changed files with 156 additions and 93 deletions

View File

@ -18,6 +18,12 @@ So I had to go through the tedious process and fix them all.
- Added World Tokens which let you travel between worlds
- Added Fossils
- Removed Vyn Forest, Old Growth Forest and Jungle
- Zinc wires are now configurable like Minecraft's Redstone Repeater
It comes in 4 different levels
1 = 0.1 seconds
2 = 0.2 seconds
3 = 0.4 seconds
4 = 0.8 seconds
# [Sep 29th 2024] Unnamed Minor Update

View File

@ -35,6 +35,27 @@ PyuTest.dorange = function(origin, range, action)
end
end
PyuTest.get_neighbours = function(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),
}
end
PyuTest.create_explosion = function (pos, range, rm_pos, dmg, creator, dmg_creator)
if rm_pos then
minetest.remove_node(pos)

View File

@ -0,0 +1,45 @@
local delay_multipliers = {
100, -- Default, 0.1 seconds
200, -- 0.2 seconds
400, -- 0.4 seconds
800, -- 0.8 seconds
}
local function index_name(n)
if n == 1 then
return "pyutest_electricity:zinc_wire"
else
return string.format("pyutest_electricity:zinc_wire_%d", n)
end
end
for i, v in ipairs(delay_multipliers) do
PyuTest.make_wire(index_name(i), "Zinc Wire", {
snappy = PyuTest.BLOCK_NORMAL,
not_in_creative_inventory = i ~= 1 and 1 or nil
}, "#bed3d4", {
on_rightclick = function (pos, node, clicker)
local ni = v
if i == #delay_multipliers then
ni = 1
else
ni = i + 1
end
minetest.set_node(pos, {name = index_name(ni)})
end
}, function(def, pos, node, clicker, sender_pos)
minetest.after(PyuTest.ELECTRICITY_TICK * v, function()
def.__on_electricity_activated(pos, node, clicker, sender_pos)
end)
end, string.format("pyutest-wire-d%d.png", i))
end
minetest.register_craft({
output = string.format("%s 4", index_name(1)),
recipe = {
"pyutest_ores:zinc_ingot"
},
type = "shapeless"
})

View File

@ -0,0 +1,50 @@
PyuTest.make_electricity_device("pyutest_electricity:freezer_device", "Freezer Device", {
cracky = PyuTest.BLOCK_FAST
}, {"pyutest-freezer.png"}, "pyutest_blocks:ice_block", nil, function (pos, node, clicker, sender_pos)
PyuTest.dorange(pos, 2, function(p)
local n = minetest.get_node(p)
if minetest.get_item_group(n.name, "freezable") ~= 0 then
minetest.set_node(p, { name = "pyutest_blocks:ice_block" })
elseif minetest.get_item_group(n.name, "coolable") ~= 0 then
local def = minetest.registered_nodes[n.name]
local cool_into = def.__cool_into or "pyutest_blocks:water_source"
minetest.set_node(p, { name = cool_into })
end
end)
end)
PyuTest.make_electricity_device("pyutest_electricity:heater_device", "Heater Device", {
cracky = PyuTest.BLOCK_FAST
}, {"pyutest-heater.png"}, "pyutest_blocks:fire", nil, function (pos, node, clicker, sender_pos)
PyuTest.dorange(pos, 2, function(p)
local n = minetest.get_node(p)
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_blocks:water_source"
minetest.set_node(p, { name = thaw_into })
elseif minetest.get_item_group(n.name, "heatable") ~= 0 then
local def = minetest.registered_nodes[n.name]
local heat_into = def.__heat_into or "pyutest_blocks:lava_source"
minetest.set_node(p, { name = heat_into })
end
end)
end)
PyuTest.make_electricity_device("pyutest_electricity:lamp_device", "Lamp Device", {
cracky = PyuTest.BLOCK_FAST,
}, {"pyutest-lamp.png"}, "pyutest_blocks:light", nil, function (pos, node, clicker, sender_pos)
minetest.set_node(pos, {name = "pyutest_electricity:lamp_device_on"})
end)
PyuTest.make_electricity_device("pyutest_electricity:lamp_device_on", "Lamp Device", {
cracky = PyuTest.BLOCK_FAST,
not_in_creative_inventory = 1
}, {"pyutest-lamp.png"}, nil, {
light_source = minetest.LIGHT_MAX,
drop = "pyutest_electricity:lamp_device"
}, function (pos, node, clicker, sender_pos)
minetest.set_node(pos, {name = "pyutest_electricity:lamp_device"})
end)

View File

@ -1,24 +1,6 @@
PyuTest.ELECTRICITY_TICK = 0.02 -- Maybe this will prevent stack overflows?
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),
local modpath = minetest.get_modpath("pyutest_electricity")
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),
}
end
PyuTest.ELECTRICITY_TICK = 1 / 1000
PyuTest.make_button = function(id, desc, groups, tiles)
PyuTest.make_node(id, desc, PyuTest.util.tableconcat(groups, {
@ -31,7 +13,7 @@ PyuTest.make_button = function(id, desc, groups, tiles)
gain = 1
})
for _, v in pairs(get_neighbours(pos)) do
for _, v in pairs(PyuTest.get_neighbours(pos)) do
local n = minetest.get_node(v)
local def = minetest.registered_nodes[n.name]
minetest.after(PyuTest.ELECTRICITY_TICK, function()
@ -44,7 +26,7 @@ PyuTest.make_button = function(id, desc, groups, tiles)
})
end
PyuTest.make_wire = function(id, desc, groups, color, efn)
PyuTest.make_wire = function(id, desc, groups, color, opts, efn, texture)
local fn = efn or function(def, pos, node, clicker, sender_pos)
def.__on_electricity_activated(pos, node, clicker, sender_pos)
end
@ -52,11 +34,11 @@ PyuTest.make_wire = function(id, desc, groups, color, efn)
PyuTest.make_node(id, desc, PyuTest.util.tableconcat(groups, {
electric = 1
}), {
"pyutest-wire.png",
"pyutest-wire.png",
"pyutest-wire.png",
"pyutest-wire.png"
}, {
texture or "pyutest-wire.png",
texture or "pyutest-wire.png",
texture or "pyutest-wire.png",
texture or "pyutest-wire.png"
}, PyuTest.util.tableconcat(opts or {}, {
drawtype = "raillike",
color = color,
paramtype = "light",
@ -65,7 +47,7 @@ PyuTest.make_wire = function(id, desc, groups, color, efn)
inventory_image = "pyutest-wire.png",
__on_electricity_activated = function(pos, node, clicker, sender_pos)
for _, v in pairs(get_neighbours(pos)) do
for _, v in pairs(PyuTest.get_neighbours(pos)) do
local n = minetest.get_node(v)
local def = minetest.registered_nodes[n.name]
@ -83,7 +65,27 @@ PyuTest.make_wire = function(id, desc, groups, color, efn)
::continue::
end
end
})
}))
end
PyuTest.make_electricity_device = function(id, desc, groups, tiles, craftitem, opts, eafn)
PyuTest.make_node(id, desc, PyuTest.util.tableconcat(groups, {
electric = 1
}), tiles, PyuTest.util.tableconcat(opts or {}, {
__on_electricity_activated = eafn
}))
-- Dont create a recipe if it is nil
if craftitem ~= nil then
minetest.register_craft({
output = id,
recipe = {
{ "pyutest_blocks:stone_block", "pyutest_blocks:stone_block", "pyutest_blocks:stone_block" },
{ "pyutest_blocks:stone_block", craftitem, "pyutest_blocks:stone_block" },
{ "pyutest_blocks:stone_block", "pyutest_blocks:stone_block", "pyutest_blocks:stone_block" }
},
})
end
end
PyuTest.make_button("pyutest_electricity:button", "Button", {
@ -94,53 +96,6 @@ PyuTest.make_wire("pyutest_electricity:copper_wire", "Copper Wire", {
snappy = PyuTest.BLOCK_NORMAL
}, "darkgoldenrod")
PyuTest.make_wire("pyutest_electricity:zinc_wire", "Zinc Wire", {
snappy = PyuTest.BLOCK_NORMAL
}, "#bed3d4", function(def, pos, node, clicker, sender_pos)
minetest.after(0.2, function()
def.__on_electricity_activated(pos, node, clicker, sender_pos)
end)
end)
PyuTest.make_node("pyutest_electricity:freezer_device", "Freezer Device", {
cracky = PyuTest.BLOCK_FAST,
electric = 1
}, { "pyutest-freezer.png" }, {
__on_electricity_activated = function(pos, node, clicker)
PyuTest.dorange(pos, 2, function(p)
local n = minetest.get_node(p)
if minetest.get_item_group(n.name, "freezable") ~= 0 then
minetest.set_node(p, { name = "pyutest_blocks:ice_block" })
elseif minetest.get_item_group(n.name, "coolable") ~= 0 then
local def = minetest.registered_nodes[n.name]
local cool_into = def.__cool_into or "pyutest_blocks:water_source"
minetest.set_node(p, { name = cool_into })
end
end)
end
})
PyuTest.make_node("pyutest_electricity:heater_device", "Heater Device", {
cracky = PyuTest.BLOCK_FAST,
electric = 1
}, { "pyutest-heater.png" }, {
__on_electricity_activated = function(pos, node, clicker)
PyuTest.dorange(pos, 2, function(p)
local n = minetest.get_node(p)
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_blocks:water_source"
minetest.set_node(p, { name = thaw_into })
elseif minetest.get_item_group(n.name, "heatable") ~= 0 then
local def = minetest.registered_nodes[n.name]
local heat_into = def.__heat_into or "pyutest_blocks:lava_source"
minetest.set_node(p, { name = heat_into })
end
end)
end
})
minetest.register_craft({
output = "pyutest_electricity:copper_wire 4",
@ -150,14 +105,6 @@ minetest.register_craft({
type = "shapeless"
})
minetest.register_craft({
output = "pyutest_electricity:zinc_wire 4",
recipe = {
"pyutest_ores:zinc_ingot"
},
type = "shapeless"
})
minetest.register_craft({
output = "pyutest_electricity:button",
recipe = {
@ -167,11 +114,5 @@ minetest.register_craft({
},
})
minetest.register_craft({
output = "pyutest_electricity:freezer_device",
recipe = {
{ "pyutest_blocks:stone_block", "pyutest_blocks:stone_block", "pyutest_blocks:stone_block" },
{ "pyutest_blocks:stone_block", "pyutest_blocks:ice_block", "pyutest_blocks:stone_block" },
{ "pyutest_blocks:stone_block", "pyutest_blocks:stone_block", "pyutest_blocks:stone_block" }
},
})
dofile(modpath.."/devices.lua")
dofile(modpath.."/delayer.lua")

View File

@ -116,7 +116,7 @@ PyuTest.IceWorld:create_token("pyutest_mapgen:ice_world_token", "Ice World", "#c
local icy_cavern = PyuTest.IceWorld:register_biome({
name = "icy_cavern",
node_stone = "pyutest_blocks:ice_block",
heat_point = 14,
heat_point = 0,
humidity_point = 0
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B