Compare commits

..

5 Commits

Author SHA1 Message Date
loosewheel
e4b3ae935d Add files via upload 2022-02-27 10:03:39 +10:00
loosewheel
914bdbbe30 Add files via upload 2022-02-27 10:01:16 +10:00
loosewheel
86362bbc86 Add files via upload 2022-02-27 09:58:15 +10:00
loosewheel
6ade6a84a2 Add files via upload 2022-02-27 09:57:07 +10:00
loosewheel
c26d7a86ca Add files via upload 2022-02-27 09:56:09 +10:00
22 changed files with 2362 additions and 53 deletions

View File

@@ -15,7 +15,7 @@ local function get_cannon_barrel (pos)
local barrel_pos = { x = pos.x, y = pos.y + 0.65, z = pos.z } local barrel_pos = { x = pos.x, y = pos.y + 0.65, z = pos.z }
local objects = minetest.get_objects_inside_radius (barrel_pos, 0.1) local objects = minetest.get_objects_inside_radius (barrel_pos, 0.1)
for i = 1, #objects do for i = 1, #objects, 1 do
if not objects[i]:is_player () then if not objects[i]:is_player () then
if objects[i].get_luaentity and objects[i]:get_luaentity () and if objects[i].get_luaentity and objects[i]:get_luaentity () and
objects[i]:get_luaentity ().name and objects[i]:get_luaentity ().name and

View File

@@ -153,8 +153,13 @@ local function register_shell (name, description, texture, inventory_image,
end end
elseif c.type == "object" then elseif c.type == "object" then
local c_name = (c.object.get_luaentity and
c.object:get_luaentity () and
c.object:get_luaentity ().name) or ""
local s_name = (self.name) or ""
-- explode at this pos -- explode at this pos
if c.object:get_armor_groups ().immortal then if c.object:get_armor_groups ().immortal or s_name == c_name then
self.object:set_velocity (c.old_velocity) self.object:set_velocity (c.old_velocity)
else else
explode_pos = vector.new (c.object:get_pos ()) explode_pos = vector.new (c.object:get_pos ())
@@ -198,7 +203,6 @@ local function register_shell (name, description, texture, inventory_image,
local obj = minetest.add_entity (spawn_pos, name.."_entity") local obj = minetest.add_entity (spawn_pos, name.."_entity")
if obj then if obj then
obj:set_armor_groups ({ immortal = 1 })
obj:set_acceleration ({ x = 0, y = -9.81, z = 0 }) obj:set_acceleration ({ x = 0, y = -9.81, z = 0 })
obj:set_rotation (vector.dir_to_rotation (vector.multiply (spawner_dir, shell_speed))) obj:set_rotation (vector.dir_to_rotation (vector.multiply (spawner_dir, shell_speed)))
obj:set_velocity (vector.multiply (spawner_dir, shell_speed)) obj:set_velocity (vector.multiply (spawner_dir, shell_speed))

View File

@@ -135,3 +135,12 @@ v0.1.23
* Fixed conduits sending items in groups. * Fixed conduits sending items in groups.
* Fixed player attached to controller moving forever when they get blown up. * Fixed player attached to controller moving forever when they get blown up.
* Fixed pistons being powered from the pusher side. * Fixed pistons being powered from the pusher side.
v0.1.24
* Limited requested count from storage indexer from digilines message to max stack.
* Fixed receptor state in detector.
* Fixed receptor state in digiswitch.
* Fixed bug in utils.is_same_item ().
* Added force field generators.
* Removed immortal from cannon shells (shells test for same type of shell and ignore).

View File

@@ -61,6 +61,26 @@ minetest.register_craft( {
}) })
minetest.register_craft( {
output = "lwcomponents:force_field",
recipe = {
{ "default:steel_ingot", "default:mese_crystal", "group:wood" },
{ "default:mese_crystal", "default:diamondblock", "default:mese_crystal" },
{ "default:stone", "default:mese_crystal", "default:chest" }
},
})
minetest.register_craft( {
output = "lwcomponents:force_field_locked",
recipe = {
{ "default:steel_ingot", "default:mese_crystal", "group:wood" },
{ "default:mese_crystal", "default:diamondblock", "default:mese_crystal" },
{ "default:stone", "default:mese_crystal", "default:chest_locked" }
},
})
minetest.register_craft( { minetest.register_craft( {
output = "lwcomponents:cannon_shell 10", output = "lwcomponents:cannon_shell 10",
recipe = { recipe = {

View File

@@ -18,6 +18,12 @@ local function mesecons_on (pos)
if meta:get_int ("power_on") == 0 then if meta:get_int ("power_on") == 0 then
utils.mesecon_receptor_on (pos, utils.mesecon_default_rules) utils.mesecon_receptor_on (pos, utils.mesecon_default_rules)
meta:set_int ("power_on", 1) meta:set_int ("power_on", 1)
local node = utils.get_far_node (pos)
if node then
node.param1 = 1
minetest.swap_node (pos, node)
end
end end
end end
end end
@@ -31,6 +37,12 @@ local function mesecons_off (pos)
if meta:get_int ("power_on") ~= 0 then if meta:get_int ("power_on") ~= 0 then
utils.mesecon_receptor_off (pos, utils.mesecon_default_rules) utils.mesecon_receptor_off (pos, utils.mesecon_default_rules)
meta:set_int ("power_on", 0) meta:set_int ("power_on", 0)
local node = utils.get_far_node (pos)
if node then
node.param1 = 0
minetest.swap_node (pos, node)
end
end end
end end
end end
@@ -692,8 +704,10 @@ local function mesecon_support ()
{ {
receptor = receptor =
{ {
state = utils.mesecon_state_off, state = utils.mesecon_state_on,
rules = utils.mesecon_default_rules rules = function (node)
return (node.param1 == 0 and { }) or utils.mesecon_default_rules
end
} }
} }
end end

View File

@@ -13,7 +13,7 @@ local function get_mesecon_rule_for_side (side)
if side == "white" then if side == "white" then
return { { x = 0, y = 1, z = 0 } } return { { x = 0, y = 1, z = 0 } }
elseif side == "black" then elseif side == "black" then
return { { x = 0, y = -1, z = 0 } } -- down doesn't work return { { x = 0, y = -1, z = 0 } }
elseif side == "red" then elseif side == "red" then
return { { x = -1, y = 0, z = 0 } } return { { x = -1, y = 0, z = 0 } }
elseif side == "green" then elseif side == "green" then
@@ -32,13 +32,106 @@ local function get_mesecon_rule_for_side (side)
{ x = 0, y = 0, z = 1 }, { x = 0, y = 0, z = 1 },
{ x = 0, y = 0, z = -1 }, { x = 0, y = 0, z = -1 },
{ x = 0, y = 1, z = 0 }, { x = 0, y = 1, z = 0 },
{ x = 0, y = -1, z = 0 }, -- down doesn't work { x = 0, y = -1, z = 0 },
} }
end end
end end
local side_bits =
{
["white"] = 0,
["black"] = 1,
["red"] = 2,
["green"] = 3,
["blue"] = 4,
["yellow"] = 5
}
local function get_side_bit (side)
if side then
if side == "switch" then
return 64
end
local bit = side_bits[side]
if bit then
return math.pow (2, bit)
end
end
return 63
end
local function is_side_on (bits, side)
local bit = get_side_bit (side)
for i = 0, 6, 1 do
if (bit % 2) == 1 and (bits % 2) ~= 1 then
return false
end
bit = math.floor (bit / 2)
bits = math.floor (bits / 2)
end
return true
end
local function set_side_bit (bits, side, on)
local bit = get_side_bit (side)
local result = 0
for i = 0, 6, 1 do
if (bit % 2) == 1 then
if on then
result = result + math.pow (2, i)
end
elseif (bits % 2) == 1 then
result = result + math.pow (2, i)
end
bit = math.floor (bit / 2)
bits = math.floor (bits / 2)
end
return result
end
local function switch_on (pos, side)
utils.mesecon_receptor_on (pos, get_mesecon_rule_for_side (side))
local node = utils.get_far_node (pos)
if node then
node.param1 = set_side_bit (node.param1, side, true)
minetest.swap_node (pos, node)
end
end
local function switch_off (pos, side)
utils.mesecon_receptor_off (pos, get_mesecon_rule_for_side (side))
local node = utils.get_far_node (pos)
if node then
node.param1 = set_side_bit (node.param1, side, false)
minetest.swap_node (pos, node)
end
end
local function digilines_support () local function digilines_support ()
return return
{ {
@@ -80,9 +173,9 @@ local function digilines_support ()
end end
if words[1] == "on" then if words[1] == "on" then
utils.mesecon_receptor_on (pos, get_mesecon_rule_for_side (words[2])) switch_on (pos, words[2])
elseif words[1] == "off" then elseif words[1] == "off" then
utils.mesecon_receptor_off (pos, get_mesecon_rule_for_side (words[2])) switch_off (pos, words[2])
end end
end end
end end
@@ -99,16 +192,32 @@ local function mesecon_support ()
{ {
receptor = receptor =
{ {
state = mesecon.state.off, state = mesecon.state.on,
rules =
{ rules = function (node)
{ x = 1, y = 0, z = 0 }, if is_side_on (node.param1, "switch") then
{ x = -1, y = 0, z = 0 }, return utils.mesecon_default_rules
{ x = 0, y = 0, z = 1 }, end
{ x = 0, y = 0, z = -1 },
{ x = 0, y = 1, z = 0 }, local r = { }
{ x = 0, y = -1, z = 0 }, -- down doesn't work local sides =
} {
"white",
"black",
"red",
"green",
"blue",
"yellow",
}
for _, side in ipairs (sides) do
if is_side_on (node.param1, side) then
r[#r + 1] = get_mesecon_rule_for_side (side)[1]
end
end
return r
end
}, },
} }
end end
@@ -124,7 +233,7 @@ local function on_construct (pos)
local formspec = local formspec =
"formspec_version[3]\n".. "formspec_version[3]\n"..
"size[6.0,4.0]\n".. "size[6.0,4.0]\n"..
"field[1.0,0.8;4.0,1.0;channel;Channel;]\n".. "field[1.0,0.8;4.0,1.0;channel;Channel;${channel}]\n"..
"button_exit[2.0,2.5;2.0,1.0;set;Set]\n" "button_exit[2.0,2.5;2.0,1.0;set;Set]\n"
meta:set_string ("formspec", formspec) meta:set_string ("formspec", formspec)
@@ -145,14 +254,6 @@ local function on_receive_fields (pos, formname, fields, sender)
if meta then if meta then
meta:set_string ("channel", fields.channel or "") meta:set_string ("channel", fields.channel or "")
local formspec =
"formspec_version[3]\n"..
"size[6.0,4.0]\n"..
"field[1.0,0.8;4.0,1.0;channel;Channel;"..minetest.formspec_escape (meta:get_string ("channel")).."]\n"..
"button_exit[2.0,2.5;2.0,1.0;set;Set]\n"
meta:set_string ("formspec", formspec)
end end
end end
end end
@@ -172,6 +273,8 @@ minetest.register_node ("lwcomponents:digiswitch", {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
} }
}, },
paramtype = "none",
param1 = 0,
groups = { cracky = 2, oddly_breakable_by_hand = 2 }, groups = { cracky = 2, oddly_breakable_by_hand = 2 },
sounds = default.node_sound_stone_defaults (), sounds = default.node_sound_stone_defaults (),
mesecons = mesecon_support (), mesecons = mesecon_support (),

View File

@@ -0,0 +1,67 @@
Force Field Generator
---------------------
Force field generators repel players and mobs within a given radius from
the generator. The radius can be 5 to 25 and is in all directions. An
'electric dome' appears marking the field. The generator consumes fuel
relative to the radius. A radius of 25 uses 1 coal in 10 seconds, 5 uses
1 coal in 50 seconds. Each time an entity is repelled it cost 1 fuel value
(1/40 of a coal). Any players or mobs permitted inside the field can be
added to the Permit list. Each entry must be on a new line with no extra
spaces. Empty lines (not even a space) are ignored. The mob's registered
name or tag can be used. The owner of a locked generator will not be
repelled. When something is repelled it takes a small amount of damage.
Only the owner can dig or access the form of the locked version.
UI
Channel - digilines channel of generator.
Radius - the node radius to repel, in every direction. 5 to 25.
Permit - list of players or mobs to allow within field. Mobs can be registered
entity name or tag.
Start/Stop button - starts and stops the field.
Fuel - single slot inventory.
Player inventor - 32 slot inventory at bottom.
Mesecons
Turns the generator on and off.
Digilines messages
"start"
Start the generator.
"stop"
Stop the generator.
"radius n"
Set the radius to n, where n is a number between 5 to 25.
"add <name>"
Add a name to the permit list.
"remove <name>"
Remove a name from the permit list.
"status"
Query the status of the generator. The generator will send a digilines
message with its own channel as the following table:
{
action = "status",
state = "on" | "off",
radius = n, -- radius as number
permit =
{
<list of names>
},
fuel =
{
name = name, -- eg. "default:coal_lump", will be "" if empty
count = n, -- count of fuel
}
}
Hoppers and pipeworks tubes can be used to push or pull the fuel.

View File

@@ -70,7 +70,8 @@ or
} }
Moves the item/s to the output. If count is omitted defaults to 1. If Moves the item/s to the output. If count is omitted defaults to 1. If
the requested amount is greater than in storage, only the stored amount the requested amount is greater than in storage, only the stored amount
is moved. is moved. If the requested amount is greater than a full stack of the
item a full stack is moved.
"inventory" "inventory"

View File

@@ -70,24 +70,6 @@ end
--local function is_same_item (stack1, stack2)
--local copy1 = ItemStack (stack1)
--local copy2 = ItemStack (stack2)
--if copy1 and copy2 then
--copy1:set_count (1)
--copy2:set_count (1)
--if copy1:to_string () == copy2:to_string () then
--return true
--end
--end
--return false
--end
local function dig_node (pos, toolname) local function dig_node (pos, toolname)
local node = utils.get_far_node (pos) local node = utils.get_far_node (pos)
local dig = false local dig = false
@@ -335,7 +317,7 @@ local function add_effects (pos, radius, drops)
collisiondetection = false, collisiondetection = false,
vertical = false, vertical = false,
texture = "lwcomponents_boom.png", texture = "lwcomponents_boom.png",
glow = 15, glow = 14,
}) })
minetest.add_particlespawner ({ minetest.add_particlespawner ({

1052
force_field.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
local version = "0.1.23" local version = "0.1.24"
local mod_storage = minetest.get_mod_storage () local mod_storage = minetest.get_mod_storage ()
@@ -38,6 +38,7 @@ loadfile (modpath.."/pistons.lua") (utils)
loadfile (modpath.."/through_wire.lua") (utils) loadfile (modpath.."/through_wire.lua") (utils)
loadfile (modpath.."/camera.lua") (utils) loadfile (modpath.."/camera.lua") (utils)
loadfile (modpath.."/storage.lua") (utils) loadfile (modpath.."/storage.lua") (utils)
loadfile (modpath.."/force_field.lua") (utils)
loadfile (modpath.."/extras.lua") (utils) loadfile (modpath.."/extras.lua") (utils)
loadfile (modpath.."/digiswitch.lua") (utils) loadfile (modpath.."/digiswitch.lua") (utils)
loadfile (modpath.."/movefloor.lua") (utils) loadfile (modpath.."/movefloor.lua") (utils)

View File

@@ -15,6 +15,8 @@ https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
Mesecons through wire code was adapted from mesecons_receiver. Mesecons through wire code was adapted from mesecons_receiver.
Fragments of code were gleaned from tnt mod.
lwsiren-buzz.ogg lwsiren-buzz.ogg
@@ -70,6 +72,14 @@ sound effects free of charge and royalty free in your multimedia projects
for commercial or non-commercial purposes. for commercial or non-commercial purposes.
lwforce_field_zap.ogg
---------------------
https://orangefreesounds.com/electricity-zap/
Licence: The sound effect is permitted for non-commercial use under license
Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
Media license Media license
------------- -------------

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,7 @@ CC BY-SA 3.0
Version Version
======= =======
0.1.23 0.1.24
Minetest Version Minetest Version
@@ -69,6 +69,7 @@ Various components for mesecons and digilines.
* Movefloor, similar to vertical mesecons movestone. * Movefloor, similar to vertical mesecons movestone.
* Camera, takes a representative image. * Camera, takes a representative image.
* Storage, indexed storage units. * Storage, indexed storage units.
* Force Field Generator, repels players and mobs within a radius.
* Mesecons Through Wire, transmits through 1 to 2 solid blocks. * Mesecons Through Wire, transmits through 1 to 2 solid blocks.
* Solid color conductor blocks, same as Solid Color Block but also mesecons * Solid color conductor blocks, same as Solid Color Block but also mesecons
and digilines conductor. and digilines conductor.

Binary file not shown.

View File

@@ -389,6 +389,11 @@ local function output_items (pos, name, count)
end end
local stack = ItemStack (name) local stack = ItemStack (name)
if stack:get_stack_max () < count then
count = stack:get_stack_max ()
end
stack:set_count (count) stack:set_count (count)
while stack:get_count () > 0 do while stack:get_count () > 0 do
@@ -738,7 +743,7 @@ local function get_formspec_list (pos)
} }
end end
local foo = table.sort (list , function (e1, e2) table.sort (list , function (e1, e2)
return (e1.description:lower () < e2.description:lower ()) return (e1.description:lower () < e2.description:lower ())
end) end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -226,8 +226,8 @@ end
function utils.is_same_item (item1, item2) function utils.is_same_item (item1, item2)
local copy1 = ItemStack (stack1) local copy1 = ItemStack (item1)
local copy2 = ItemStack (stack2) local copy2 = ItemStack (item2)
if copy1 and copy2 then if copy1 and copy2 then
copy1:set_count (1) copy1:set_count (1)