Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c30e5b6947 | ||
|
92a065b591 | ||
|
af812515bb | ||
|
0d27b384a2 | ||
|
7b6b0176a7 | ||
|
f475b498e5 | ||
|
3adc0fcf70 | ||
|
7ed06d7e94 | ||
|
35ec093f88 |
12
api.lua
Normal file
12
api.lua
Normal 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--
|
16
change.log
16
change.log
@@ -15,3 +15,19 @@ v0.1.2
|
|||||||
* Added support for hopper as optional dependency for droppers, dispensers
|
* Added support for hopper as optional dependency for droppers, dispensers
|
||||||
and collectors.
|
and collectors.
|
||||||
* Added digilines message to punchers when something is punched.
|
* 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.
|
||||||
|
15
crafting.lua
15
crafting.lua
@@ -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
|
if utils.mesecon_supported and mesecon.mvps_push then
|
||||||
|
|
||||||
minetest.register_craft ({
|
minetest.register_craft ({
|
||||||
|
@@ -5,3 +5,5 @@ digilines?
|
|||||||
unifieddyes?
|
unifieddyes?
|
||||||
intllib?
|
intllib?
|
||||||
hopper?
|
hopper?
|
||||||
|
mobs?
|
||||||
|
digistuff?
|
||||||
|
49
detector.lua
49
detector.lua
@@ -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
|
if utils.digilines_supported then
|
||||||
local meta = minetest.get_meta (pos)
|
local meta = minetest.get_meta (pos)
|
||||||
|
|
||||||
@@ -76,7 +76,9 @@ local function send_detect_message (pos, item_type, name, label, item_pos, count
|
|||||||
name = name,
|
name = name,
|
||||||
label = label,
|
label = label,
|
||||||
pos = to_relative_coords (pos, item_pos),
|
pos = to_relative_coords (pos, item_pos),
|
||||||
count = count })
|
count = count,
|
||||||
|
hp = hp,
|
||||||
|
height = height })
|
||||||
end
|
end
|
||||||
end
|
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 function detect (pos)
|
||||||
local meta = minetest.get_meta (pos)
|
local meta = minetest.get_meta (pos)
|
||||||
local detected = false
|
local detected = false
|
||||||
@@ -153,7 +182,9 @@ local function detect (pos)
|
|||||||
object[i]:get_player_name (),
|
object[i]:get_player_name (),
|
||||||
object[i]:get_player_name (),
|
object[i]:get_player_name (),
|
||||||
object[i]:get_pos (),
|
object[i]:get_pos (),
|
||||||
1)
|
1,
|
||||||
|
object[i]:get_hp (),
|
||||||
|
get_entity_height (object[i]))
|
||||||
|
|
||||||
detected = true
|
detected = true
|
||||||
end
|
end
|
||||||
@@ -174,7 +205,9 @@ local function detect (pos)
|
|||||||
stack:get_name (),
|
stack:get_name (),
|
||||||
stack:get_name (),
|
stack:get_name (),
|
||||||
object[i]:get_pos (),
|
object[i]:get_pos (),
|
||||||
stack:get_count ())
|
stack:get_count (),
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
|
||||||
detected = true
|
detected = true
|
||||||
end
|
end
|
||||||
@@ -203,7 +236,9 @@ local function detect (pos)
|
|||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
object[i]:get_pos (),
|
object[i]:get_pos (),
|
||||||
1)
|
1,
|
||||||
|
object[i]:get_hp (),
|
||||||
|
get_entity_height (object[i]))
|
||||||
|
|
||||||
detected = true
|
detected = true
|
||||||
|
|
||||||
@@ -228,7 +263,9 @@ local function detect (pos)
|
|||||||
node.name,
|
node.name,
|
||||||
node.name,
|
node.name,
|
||||||
testpos,
|
testpos,
|
||||||
1)
|
1,
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
|
||||||
detected = true
|
detected = true
|
||||||
end
|
end
|
||||||
|
104
dispenser.lua
104
dispenser.lua
@@ -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)
|
local function dispense_pos (pos, node)
|
||||||
if node.param2 == 0 then
|
if node.param2 == 0 then
|
||||||
return { x = pos.x, y = pos.y, z = pos.z - 1 }
|
return { x = pos.x, y = pos.y, z = pos.z - 1 }
|
||||||
@@ -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:
|
-- slot:
|
||||||
-- nil - next item, no dispense if empty
|
-- nil - next item, no dispense if empty
|
||||||
-- number - 1 item from slot, 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
|
if item then
|
||||||
item:set_count (1)
|
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
|
if obj then
|
||||||
obj:set_velocity (dispense_velocity (node))
|
obj:set_velocity (dispense_velocity (node))
|
||||||
|
47
docs/api.txt
Normal file
47
docs/api.txt
Normal 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).
|
5
init.lua
5
init.lua
@@ -1,4 +1,4 @@
|
|||||||
local version = "0.1.2"
|
local version = "0.1.5"
|
||||||
local mod_storage = minetest.get_mod_storage ()
|
local mod_storage = minetest.get_mod_storage ()
|
||||||
|
|
||||||
|
|
||||||
@@ -16,12 +16,15 @@ local utils = { }
|
|||||||
local modpath = minetest.get_modpath ("lwcomponents")
|
local modpath = minetest.get_modpath ("lwcomponents")
|
||||||
|
|
||||||
loadfile (modpath.."/utils.lua") (utils, mod_storage)
|
loadfile (modpath.."/utils.lua") (utils, mod_storage)
|
||||||
|
loadfile (modpath.."/settings.lua") (utils)
|
||||||
|
loadfile (modpath.."/api.lua") (utils)
|
||||||
loadfile (modpath.."/dropper.lua") (utils)
|
loadfile (modpath.."/dropper.lua") (utils)
|
||||||
loadfile (modpath.."/collector.lua") (utils)
|
loadfile (modpath.."/collector.lua") (utils)
|
||||||
loadfile (modpath.."/dispenser.lua") (utils)
|
loadfile (modpath.."/dispenser.lua") (utils)
|
||||||
loadfile (modpath.."/detector.lua") (utils)
|
loadfile (modpath.."/detector.lua") (utils)
|
||||||
loadfile (modpath.."/siren.lua") (utils)
|
loadfile (modpath.."/siren.lua") (utils)
|
||||||
loadfile (modpath.."/puncher.lua") (utils)
|
loadfile (modpath.."/puncher.lua") (utils)
|
||||||
|
loadfile (modpath.."/player_button.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)
|
||||||
|
@@ -64,6 +64,8 @@ Media license
|
|||||||
siren images derived from images from https://openclipart.org, which is
|
siren images derived from images from https://openclipart.org, which is
|
||||||
public domain.
|
public domain.
|
||||||
|
|
||||||
|
player button images derived from mesecons button image.
|
||||||
|
|
||||||
All other media, or media not covered by a licence, is licensed
|
All other media, or media not covered by a licence, is licensed
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
|
||||||
|
2
mod.conf
2
mod.conf
@@ -3,4 +3,4 @@ description = Various components for mesecons and digilines.
|
|||||||
title = LWComponents
|
title = LWComponents
|
||||||
name = lwcomponents
|
name = lwcomponents
|
||||||
depends = default
|
depends = default
|
||||||
optional_depends = lwdrops, mesecons, digilines, unifieddyes, intllib, hopper
|
optional_depends = lwdrops, mesecons, digilines, unifieddyes, intllib, hopper, mobs, digistuff
|
||||||
|
232
player_button.lua
Normal file
232
player_button.lua
Normal 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
|
40
readme.txt
40
readme.txt
@@ -13,7 +13,7 @@ CC BY-SA 3.0
|
|||||||
|
|
||||||
Version
|
Version
|
||||||
=======
|
=======
|
||||||
0.1.2
|
0.1.5
|
||||||
|
|
||||||
|
|
||||||
Minetest Version
|
Minetest Version
|
||||||
@@ -34,6 +34,8 @@ digilines
|
|||||||
unifieddyes
|
unifieddyes
|
||||||
intllib
|
intllib
|
||||||
hopper
|
hopper
|
||||||
|
mobs
|
||||||
|
digistuff
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
@@ -101,6 +103,12 @@ Contains an inventory and dispenses (with velocity) an item on command.
|
|||||||
Also acts as a digilines conductor. If the hopper mod is loaded, will take
|
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.
|
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
|
UI
|
||||||
|
|
||||||
Channel - digilines channel of dispenser.
|
Channel - digilines channel of dispenser.
|
||||||
@@ -234,7 +242,9 @@ message is a table with the following keys:
|
|||||||
name = "<name>",
|
name = "<name>",
|
||||||
label = "<label>",
|
label = "<label>",
|
||||||
pos = { x = n, y = n, z = n },
|
pos = { x = n, y = n, z = n },
|
||||||
count = <count>
|
count = <count>,
|
||||||
|
hp = <number>,
|
||||||
|
height = <number>
|
||||||
}
|
}
|
||||||
|
|
||||||
type
|
type
|
||||||
@@ -265,6 +275,12 @@ pos
|
|||||||
count
|
count
|
||||||
The count of items for a "drop", or 1 for everything else.
|
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
|
Siren
|
||||||
@@ -383,6 +399,26 @@ label
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
DigiSwitch
|
||||||
----------
|
----------
|
||||||
* This block is only available if both digilines and mesecons are loaded.
|
* This block is only available if both digilines and mesecons are loaded.
|
||||||
|
11
settings.lua
Normal file
11
settings.lua
Normal 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
2
settingtypes.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Allow dispensers to spawn mobs instead of spawners.
|
||||||
|
lwcomponents_spawn_mobs (Spawn mobs) bool true
|
BIN
textures/lwplayer_button.png
Normal file
BIN
textures/lwplayer_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 420 B |
BIN
textures/lwplayer_button_on.png
Normal file
BIN
textures/lwplayer_button_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 431 B |
BIN
textures/lwplayer_button_side.png
Normal file
BIN
textures/lwplayer_button_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 B |
57
utils.lua
57
utils.lua
@@ -129,6 +129,24 @@ 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)
|
function utils.can_interact_with_node (pos, player)
|
||||||
if not player or not player:is_player () then
|
if not player or not player:is_player () then
|
||||||
return false
|
return false
|
||||||
@@ -153,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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
Reference in New Issue
Block a user