Compare commits

..

10 Commits

Author SHA1 Message Date
loosewheel
c30e5b6947 Add files via upload 2021-11-14 06:05:23 +10:00
loosewheel
92a065b591 Add files via upload 2021-11-14 06:04:46 +10:00
loosewheel
af812515bb Create api.txt 2021-11-14 06:00:58 +10:00
loosewheel
0d27b384a2 Add files via upload 2021-11-14 01:52:55 +10:00
loosewheel
7b6b0176a7 Add files via upload 2021-11-14 00:17:20 +10:00
loosewheel
f475b498e5 Add files via upload 2021-11-14 00:16:22 +10:00
loosewheel
3adc0fcf70 Add files via upload 2021-11-13 23:12:12 +10:00
loosewheel
7ed06d7e94 Add files via upload 2021-11-13 23:11:13 +10:00
loosewheel
35ec093f88 Add files via upload 2021-11-13 23:09:34 +10:00
loosewheel
32df0b8420 Add files via upload 2021-11-12 14:40:43 +10:00
22 changed files with 751 additions and 24 deletions

12
api.lua Normal file
View File

@@ -0,0 +1,12 @@
local utils = ...
-- function (spawn_pos, itemstack, owner, spawner_pos, spawner_dir)
function lwcomponents.register_spawner (itemname, spawn_func)
return utils.register_spawner (itemname, spawn_func)
end
--

View File

@@ -9,3 +9,25 @@ v0.1.1
* Made digilines optional for solid conductor blocks.
* Fixed lighting
* Added puncher
v0.1.2
* Added support for hopper as optional dependency for droppers, dispensers
and collectors.
* Added digilines message to punchers when something is punched.
v0.1.3
* Added hp and height info from detector.
* Added dispensers spawn if spawner with optional dependency on mobs mod.
If mobs:egg is dispensed 10% change a chicken is dispensed instead.
* Added player_button.
v0.1.4
* Bug fix to spawning owned mobs.
v0.1.5
* Added setting Spawn mobs.
* Added lwcomponents.register_spawner api.

View File

@@ -20,7 +20,7 @@ local function send_collect_message (pos, name, count)
if channel:len () > 0 then
utils.digilines_receptor_send (pos,
digiline.rules.default,
utils.digilines_default_rules,
channel,
{ action = "collect",
name = name,
@@ -389,7 +389,7 @@ local function digilines_support ()
{
wire =
{
rules = digiline.rules.default,
rules = utils.digilines_default_rules,
},
effector =
@@ -529,6 +529,38 @@ minetest.register_node("lwcomponents:collector_locked_on", {
utils.hopper_add_container({
{"top", "lwcomponents:collector", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:collector", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:collector", "main"}, -- insert items from hopper at side
})
utils.hopper_add_container({
{"top", "lwcomponents:collector_locked", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:collector_locked", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:collector_locked", "main"}, -- insert items from hopper at side
})
utils.hopper_add_container({
{"top", "lwcomponents:collector_on", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:collector_on", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:collector_on", "main"}, -- insert items from hopper at side
})
utils.hopper_add_container({
{"top", "lwcomponents:collector_locked_on", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:collector_locked_on", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:collector_locked_on", "main"}, -- insert items from hopper at side
})
end -- utils.digilines_supported

View File

@@ -121,6 +121,21 @@ end -- utils.digilines_supported
if utils.digilines_supported and utils.digistuff_supported then
minetest.register_craft({
output = "lwcomponents:player_button",
recipe = {
{ "mesecons_button:button_off", "digilines:wire_std_00000000" }
},
})
end -- utils.digilines_supported and utils.digistuff_supported
if utils.mesecon_supported and mesecon.mvps_push then
minetest.register_craft ({

View File

@@ -4,3 +4,6 @@ mesecons?
digilines?
unifieddyes?
intllib?
hopper?
mobs?
digistuff?

View File

@@ -60,7 +60,7 @@ end
local function send_detect_message (pos, item_type, name, label, item_pos, count)
local function send_detect_message (pos, item_type, name, label, item_pos, count, hp, height)
if utils.digilines_supported then
local meta = minetest.get_meta (pos)
@@ -69,14 +69,16 @@ local function send_detect_message (pos, item_type, name, label, item_pos, count
if channel:len () > 0 then
utils.digilines_receptor_send (pos,
digiline.rules.default,
utils.digilines_default_rules,
channel,
{ action = "detect",
type = item_type,
name = name,
label = label,
pos = to_relative_coords (pos, item_pos),
count = count })
count = count,
hp = hp,
height = height })
end
end
end
@@ -132,6 +134,33 @@ end
local function get_entity_height (objref)
if objref.get_luaentity then
entity = objref:get_luaentity ()
if entity and entity.name then
def = minetest.registered_entities[entity.name]
if def and type (def.collisionbox) == "table" and
type (def.collisionbox[5]) == "number" then
return def.collisionbox[5]
end
end
end
local props = objref:get_properties ()
if props and props.collisionbox and type (props.collisionbox) == "table" and
type (props.collisionbox[5]) == "number" then
return props.collisionbox[5]
end
return 0
end
local function detect (pos)
local meta = minetest.get_meta (pos)
local detected = false
@@ -153,7 +182,9 @@ local function detect (pos)
object[i]:get_player_name (),
object[i]:get_player_name (),
object[i]:get_pos (),
1)
1,
object[i]:get_hp (),
get_entity_height (object[i]))
detected = true
end
@@ -174,7 +205,9 @@ local function detect (pos)
stack:get_name (),
stack:get_name (),
object[i]:get_pos (),
stack:get_count ())
stack:get_count (),
0,
0)
detected = true
end
@@ -203,7 +236,9 @@ local function detect (pos)
name,
label,
object[i]:get_pos (),
1)
1,
object[i]:get_hp (),
get_entity_height (object[i]))
detected = true
@@ -228,7 +263,9 @@ local function detect (pos)
node.name,
node.name,
testpos,
1)
1,
0,
0)
detected = true
end
@@ -565,7 +602,7 @@ local function digilines_support ()
{
wire =
{
rules = digiline.rules.default,
rules = utils.digilines_default_rules,
},
effector =

View File

@@ -7,6 +7,22 @@ if utils.digilines_supported or utils.mesecon_supported then
local function dispense_dir (node)
if node.param2 == 0 then
return { x = 0, y = 0, z = -1 }
elseif node.param2 == 1 then
return { x = -1, y = 0, z = 0 }
elseif node.param2 == 2 then
return { x = 0, y = 0, z = 1 }
elseif node.param2 == 3 then
return { x = 1, y = 0, z = 0 }
else
return { x = 0, y = 0, z = 0 }
end
end
local function dispense_pos (pos, node)
if node.param2 == 0 then
return { x = pos.x, y = pos.y, z = pos.z - 1 }
@@ -52,7 +68,7 @@ local function send_dispense_message (pos, slot, name)
if channel:len () > 0 then
utils.digilines_receptor_send (pos,
digiline.rules.default,
utils.digilines_default_rules,
channel,
{ action = "dispense",
name = name,
@@ -64,6 +80,73 @@ end
local function try_spawn (pos, node, item, owner)
if utils.mobs_supported and utils.settings.spawn_mobs then
local mob = item:get_name ()
local item_def = minetest.registered_craftitems[mob]
local spawn_pos = dispense_pos (pos, node)
if item_def and item_def.groups and item_def.groups.spawn_egg then
if mob:sub (mob:len () - 3) == "_set" then
mob = mob:sub (1, mob:len () - 4)
if minetest.registered_entities[mob] then
local data = item:get_metadata ()
local smob = minetest.add_entity (spawn_pos, mob, data)
local ent = smob and smob:get_luaentity ()
if ent then
-- set owner if not a monster
if owner:len () > 0 and ent.type ~= "monster" then
ent.owner = owner
ent.tamed = true
end
end
return smob
end
else
if minetest.registered_entities[mob] then
local smob = minetest.add_entity (spawn_pos, mob)
local ent = smob and smob:get_luaentity ()
if ent then
-- set owner if not a monster
if owner:len () > 0 and ent.type ~= "monster" then
ent.owner = owner
ent.tamed = true
end
end
return smob
end
end
elseif mob == "mobs:egg" then
if math.random (1, 10) == 1 then
local smob = minetest.add_entity (spawn_pos, "mobs_animal:chicken")
local ent = smob and smob:get_luaentity ()
if ent then
-- set owner if not a monster
if owner:len () > 0 and ent.type ~= "monster" then
ent.owner = owner
ent.tamed = true
end
end
return smob
end
end
end
return nil
end
-- slot:
-- nil - next item, no dispense if empty
-- number - 1 item from slot, no dispense if empty
@@ -118,8 +201,27 @@ local function dispense_item (pos, node, slot)
if item then
item:set_count (1)
local spawn_pos = dispense_pos (pos, node)
local owner = meta:get_string ("owner")
local obj = minetest.add_item (dispense_pos (pos, node), item)
local obj, cancel = utils.spawn_registered (name,
spawn_pos,
item,
owner,
pos,
dispense_dir (node))
if obj == nil and cancel then
return false
end
if not obj then
obj = try_spawn (pos, node, item, owner)
end
if not obj then
obj = minetest.add_item (spawn_pos, item)
end
if obj then
obj:set_velocity (dispense_velocity (node))
@@ -314,7 +416,7 @@ local function digilines_support ()
{
wire =
{
rules = digiline.rules.default,
rules = utils.digilines_default_rules,
},
effector =
@@ -422,6 +524,22 @@ minetest.register_node("lwcomponents:dispenser_locked", {
utils.hopper_add_container({
{"top", "lwcomponents:dispenser", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:dispenser", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:dispenser", "main"}, -- insert items from hopper at side
})
utils.hopper_add_container({
{"top", "lwcomponents:dispenser_locked", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:dispenser_locked", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:dispenser_locked", "main"}, -- insert items from hopper at side
})
end -- utils.digilines_supported or utils.mesecon_supported

47
docs/api.txt Normal file
View File

@@ -0,0 +1,47 @@
lwcomponents.version ()
Returns this mod version as a string. eg. "0.1.5".
lwcomponents.register_spawner (itemname, spawn_func)
itemname:
Registered string name of the spawner item
spawn_func:
The function to call to spawn the mob of the form -
spawn_func (spawn_pos, itemstack, owner, spawner_pos, spawner_dir)
spawn_pos:
The position the entity should be spawned at.
itemstack:
The spawner ItemStack, of the name itemname.
owner:
As string of the player's name that will own the spawned entity,
if applicable. This may be "" for no owner.
spawner_pos:
The position of the block calling this function.
spawner_dir:
A single unit vector of the direction the spawner block is facing.
eg. { x = -1, y = 0, z = 0 }
This function should return the ObjectRef of the spawned entity or
nil. If this function returns nil for ObjectRef a second boolean
value should be returned for weather to cancel the action.
eg. If too many mobs:
return nil, true
eg. If only chance of spawn and out of luck:
return nil, false
The register function return true on success, or false on failure
(parameter type check failed or the spawn item has already been
registered).

View File

@@ -32,7 +32,7 @@ local function send_drop_message (pos, slot, name)
if channel:len () > 0 then
utils.digilines_receptor_send (pos,
digiline.rules.default,
utils.digilines_default_rules,
channel,
{ action = "drop",
name = name,
@@ -290,7 +290,7 @@ local function digilines_support ()
{
wire =
{
rules = digiline.rules.default,
rules = utils.digilines_default_rules,
},
effector =
@@ -398,6 +398,21 @@ minetest.register_node("lwcomponents:dropper_locked", {
utils.hopper_add_container({
{"top", "lwcomponents:dropper", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:dropper", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:dropper", "main"}, -- insert items from hopper at side
})
utils.hopper_add_container({
{"top", "lwcomponents:dropper_locked", "main"}, -- take items from above into hopper below
{"bottom", "lwcomponents:dropper_locked", "main"}, -- insert items below from hopper above
{"side", "lwcomponents:dropper_locked", "main"}, -- insert items from hopper at side
})
end -- utils.digilines_supported or utils.mesecon_supported

View File

@@ -1,4 +1,4 @@
local version = "0.1.1"
local version = "0.1.5"
local mod_storage = minetest.get_mod_storage ()
@@ -16,12 +16,15 @@ local utils = { }
local modpath = minetest.get_modpath ("lwcomponents")
loadfile (modpath.."/utils.lua") (utils, mod_storage)
loadfile (modpath.."/settings.lua") (utils)
loadfile (modpath.."/api.lua") (utils)
loadfile (modpath.."/dropper.lua") (utils)
loadfile (modpath.."/collector.lua") (utils)
loadfile (modpath.."/dispenser.lua") (utils)
loadfile (modpath.."/detector.lua") (utils)
loadfile (modpath.."/siren.lua") (utils)
loadfile (modpath.."/puncher.lua") (utils)
loadfile (modpath.."/player_button.lua") (utils)
loadfile (modpath.."/extras.lua") (utils)
loadfile (modpath.."/digiswitch.lua") (utils)
loadfile (modpath.."/movefloor.lua") (utils)

View File

@@ -64,6 +64,8 @@ Media license
siren images derived from images from https://openclipart.org, which is
public domain.
player button images derived from mesecons button image.
All other media, or media not covered by a licence, is licensed
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)

View File

@@ -3,4 +3,4 @@ description = Various components for mesecons and digilines.
title = LWComponents
name = lwcomponents
depends = default
optional_depends = lwdrops, mesecons, digilines, unifieddyes, intllib
optional_depends = lwdrops, mesecons, digilines, unifieddyes, intllib, hopper, mobs, digistuff

232
player_button.lua Normal file
View File

@@ -0,0 +1,232 @@
local utils = ...
local S = utils.S
if utils.digilines_supported and utils.digistuff_supported then
local function on_contruct (pos)
local meta = minetest.get_meta(pos)
local spec =
"size[7.5,3]"..
"field[1,1;6,2;channel;Channel;${channel}]"..
"button_exit[2.5,2;3,1;submit;Set]"
meta:set_string("formspec", spec)
end
local function on_receive_fields (pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if fields.submit then
if fields.channel ~= "" then
meta:set_string ("channel", fields.channel)
meta:set_string ("formspec", "")
minetest.swap_node (pos, { name = "lwcomponents:player_button_off",
param2 = minetest.get_node(pos).param2 })
else
minetest.chat_send_player (sender:get_player_name(), "Please set a channel!")
end
end
end
local function player_button_push (pos, node, player)
local meta = minetest.get_meta (pos)
if player and player:is_player () then
local channel = meta:get_string ("channel")
local formspec = meta:get_string ("formspec")
if channel:len () > 0 and formspec:len () == 0 then
utils.digilines_receptor_send (pos,
digistuff.button_get_rules (node),
channel,
{ action = "player",
name = player:get_player_name () })
end
end
if node.name == "lwcomponents:player_button_off" then
node.name = "lwcomponents:player_button_on"
minetest.swap_node(pos, node)
if digistuff.mesecons_installed then
minetest.sound_play ("mesecons_button_push", { pos = pos })
end
minetest.get_node_timer (pos):start (0.25)
end
end
local function player_button_turnoff (pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
if node.name == "lwcomponents:player_button_on" then
node.name = "lwcomponents:player_button_off"
minetest.swap_node (pos, node)
if digistuff.mesecons_installed then
minetest.sound_play ("mesecons_button_pop", { pos = pos })
end
end
end
minetest.register_node ("lwcomponents:player_button", {
description = "Player Button",
drawtype = "nodebox",
tiles = {
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button.png"
},
paramtype = "light",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
sunlight_propagates = true,
drop = "lwcomponents:player_button",
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
}
},
groups = { dig_immediate = 2, digiline_receiver = 1 },
_digistuff_channelcopier_fieldname = "channel",
sounds = default and default.node_sound_stone_defaults(),
digiline =
{
receptor = {},
wire = {
rules = digistuff.button_get_rules,
},
},
on_construct = on_contruct,
after_place_node = digistuff.place_receiver,
after_destruct = digistuff.remove_receiver,
on_receive_fields = on_receive_fields,
})
minetest.register_node ("lwcomponents:player_button_off", {
description = "Player Button",
drawtype = "nodebox",
tiles = {
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button.png"
},
paramtype = "light",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
sunlight_propagates = true,
drop = "lwcomponents:player_button",
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
}
},
groups = { dig_immediate = 2, digiline_receiver = 1, not_in_creative_inventory = 1 },
_digistuff_channelcopier_fieldname = "channel",
sounds = default and default.node_sound_stone_defaults(),
digiline =
{
receptor = {},
wire = {
rules = digistuff.button_get_rules,
},
effector = {
action = digistuff.button_handle_digilines,
},
},
after_destruct = digistuff.remove_receiver,
on_rightclick = player_button_push,
})
minetest.register_node ("lwcomponents:player_button_on", {
description = "Player Button",
drawtype = "nodebox",
tiles = {
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_side.png",
"lwplayer_button_on.png"
},
paramtype = "light",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
sunlight_propagates = true,
light_source = 7,
drop = "lwcomponents:player_button",
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 },
{ -4/16, -2/16, 11/32, 4/16, 2/16, 6/16 }
}
},
groups = { dig_immediate = 2, digiline_receiver = 1, not_in_creative_inventory = 1 },
_digistuff_channelcopier_fieldname = "channel",
sounds = default and default.node_sound_stone_defaults(),
digiline =
{
receptor = {},
wire = {
rules = digistuff.button_get_rules,
},
},
after_destruct = digistuff.remove_receiver,
-- on_rightclick = player_button_push,
on_timer = player_button_turnoff,
})
end -- utils.digilines_supported and utils.digistuff_supported

View File

@@ -7,6 +7,28 @@ if utils.digilines_supported or utils.mesecon_supported then
local function send_punch_message (pos, item_type, name, label)
if utils.digilines_supported then
local meta = minetest.get_meta (pos)
if meta then
local channel = meta:get_string ("channel")
if channel:len () > 0 then
utils.digilines_receptor_send (pos,
utils.digilines_default_rules,
channel,
{ action = "punch",
type = item_type,
name = name,
label = label })
end
end
end
end
local function direction_vector (pos)
local meta = minetest.get_meta (pos)
@@ -67,6 +89,11 @@ local function punch (pos)
damage_groups = { fleshy = 4 } },
vector.direction (pos, object[i]:get_pos ()))
send_punch_message (pos,
"player",
object[i]:get_player_name (),
object[i]:get_player_name ())
punched = true
end
@@ -80,6 +107,16 @@ local function punch (pos)
-- entity
if meta:get_string ("entities") == "true" then
local name = object[i]:get_nametag_attributes ()
local label = ""
if type (name) == "table" then
label = tostring (name.text or "")
end
name = (object[i].get_luaentity and
object[i]:get_luaentity () and
object[i]:get_luaentity ().name) or ""
object[i]:punch (object[i],
1.0,
@@ -87,6 +124,11 @@ local function punch (pos)
damage_groups = { fleshy = 4 } },
vector.direction (pos, object[i]:get_pos ()))
send_punch_message (pos,
"entity",
name,
label)
punched = true
end
@@ -368,7 +410,7 @@ local function digilines_support ()
{
wire =
{
rules = digiline.rules.default,
rules = utils.digilines_default_rules,
},
effector =

View File

@@ -13,7 +13,7 @@ CC BY-SA 3.0
Version
=======
0.1.1
0.1.5
Minetest Version
@@ -33,6 +33,9 @@ mesecons
digilines
unifieddyes
intllib
hopper
mobs
digistuff
Installation
@@ -56,7 +59,8 @@ Dropper
* This block is only available if digilines and/or mesecons are loaded.
Contains an inventory and drops an item on command. Also acts as a
digilines conductor.
digilines conductor. If the hopper mod is loaded, will take items from the
top and sides, and release them from the bottom.
UI
@@ -96,7 +100,14 @@ Dispenser
* This block is only available if digilines and/or mesecons are loaded.
Contains an inventory and dispenses (with velocity) an item on command.
Also acts as a digilines conductor.
Also acts as a digilines conductor. If the hopper mod is loaded, will take
items from the top and sides, and release them from the bottom.
Dispensers support mobs mod if loaded and Spawn mobs setting is enabled.
Will spawn the entity from an 'egg' if possible, or the 'egg' is dispensed.
If a chicken egg is dispensed a 10% chance a chicken is dispensed instead.
If the spawned entity can be owned (or tamed) and the dispenser is owned
the owner of the dispenser is set as the owner of the entity.
UI
@@ -137,7 +148,8 @@ Collector
* This block is only available if digilines is loaded.
Picks up dropped items in adjacent block, with optional filtering. Also
acts as a digilines conductor.
acts as a digilines conductor. If the hopper mod is loaded, will take items
from the top and sides, and release them from the bottom.
UI
@@ -230,7 +242,9 @@ message is a table with the following keys:
name = "<name>",
label = "<label>",
pos = { x = n, y = n, z = n },
count = <count>
count = <count>,
hp = <number>,
height = <number>
}
type
@@ -261,6 +275,12 @@ pos
count
The count of items for a "drop", or 1 for everything else.
hp
Health points for players and entities. Zero for everything else.
height
Height for players and entities. Zero for everything else. This is simply
the top position of the object's collision box.
Siren
@@ -357,6 +377,47 @@ Digilines messages
"punch"
Action a single punch if the puncher is turned on.
When a player or entity is punched a digilines message is sent with the
puncher's channel. The message is a table with the following keys:
{
action = "punch",
type = "<type>", -- will be "entity" or "player"
name = "<name>",
label = "<label>"
}
type
Will be "entity" or "player".
name
For "entity" the registered entity name.
For "player" the player's name.
label
For "entity" the name tag text.
For "player" the player's name.
Player Button
-------------
* This block is only available if both digilines and digistuff are loaded.
When pressed sends a digilines message with the name of the player that
pressed the button.
The first time the button is right clicked a form opens to set the
digilines channel. After that right click presses the button. The
digilines cannot be changed after its set.
When the button is pressed a digilines message is sent with the button's
channel in the form:
{
action = "player",
name = <player name>
}
DigiSwitch
----------

11
settings.lua Normal file
View File

@@ -0,0 +1,11 @@
local utils = ...
utils.settings = { }
utils.settings.spawn_mobs =
minetest.settings:get_bool ("lwcomponents_spawn_mobs", true)
--

2
settingtypes.txt Normal file
View File

@@ -0,0 +1,2 @@
# Allow dispensers to spawn mobs instead of spawners.
lwcomponents_spawn_mobs (Spawn mobs) bool true

View File

@@ -422,7 +422,7 @@ local function digilines_support ()
{
wire =
{
rules = digiline.rules.default,
rules = utils.digilines_default_rules,
},
effector =

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

View File

@@ -113,6 +113,40 @@ end
-- check for hopper
if minetest.global_exists ("hopper") then
utils.hopper_supported = true
utils.hopper_add_container = function (list)
hopper:add_container (list)
end
else
utils.hopper_supported = false
utils.hopper_add_container = function (list)
end
end
-- check for mobs
if minetest.global_exists ("mobs") then
utils.mobs_supported = true
else
utils.mobs_supported = false
end
-- check for digistuff
if minetest.global_exists ("digistuff") then
utils.digistuff_supported = true
else
utils.digistuff_supported = false
end
function utils.can_interact_with_node (pos, player)
if not player or not player:is_player () then
return false
@@ -137,4 +171,43 @@ end
utils.registered_spawners = { }
-- each entry [spawner_itemname] = spawner_func
function utils.register_spawner (itemname, spawn_func)
if type (itemname) == "string" and type (spawn_func) == "function" then
if not utils.registered_spawners[itemname] then
utils.registered_spawners[itemname] = spawn_func
return true
end
end
return false
end
function utils.spawn_registered (itemname, spawn_pos, itemstack, owner, spawner_pos, spawner_dir)
local func = utils.registered_spawners[itemname]
if func then
local result, obj, cancel = pcall (func, spawn_pos, itemstack, owner, spawner_pos, spawner_dir)
if result and (obj == nil or type (obj) == "userdata") then
return obj, cancel
end
minetest.log ("error", "lwcomponents.register_spawner spawner function for "..itemname.." failed")
return nil, true
end
return nil, false
end
--