Add files via upload

This commit is contained in:
loosewheel
2021-12-05 01:24:47 +10:00
committed by GitHub
parent 2b61dfb872
commit ca31c40d8b
7 changed files with 57 additions and 51 deletions

View File

@@ -74,3 +74,7 @@ v0.1.12
* Added cannon shells. * Added cannon shells.
* Fixed bug in utils.is_creative. * Fixed bug in utils.is_creative.
* Increased cannon pitch to -20 to 70. * Increased cannon pitch to -20 to 70.
v0.1.13
* Removed optional dependency lwdrops.

View File

@@ -1,5 +1,4 @@
default default
lwdrops?
mesecons? mesecons?
digilines? digilines?
unifieddyes? unifieddyes?

View File

@@ -73,7 +73,7 @@ end
local function place_node (itemname, pos) local function place_node (item, pos)
local node = minetest.get_node_or_nil ({ x = pos.x, y = pos.y - 1, z = pos.z }) local node = minetest.get_node_or_nil ({ x = pos.x, y = pos.y - 1, z = pos.z })
if not node then if not node then
@@ -100,8 +100,8 @@ local function place_node (itemname, pos)
end end
end end
local stack = ItemStack (itemname) local stack = ItemStack (item)
local itemdef = utils.find_item_def (itemname) local itemdef = utils.find_item_def (stack:get_name ())
if stack and itemdef then if stack and itemdef then
local placed = false local placed = false
@@ -122,23 +122,23 @@ local function place_node (itemname, pos)
end end
if itemdef and itemdef.on_place then if itemdef and itemdef.on_place then
local result, msg = pcall (itemdef.on_place, stack, nil, pointed_thing) local result, leftover = pcall (itemdef.on_place, stack, nil, pointed_thing)
placed = result placed = result
if not placed then if not placed then
if utils.settings.alert_handler_errors then if utils.settings.alert_handler_errors then
minetest.log ("error", "on_place handler for "..itemname.." crashed - "..msg) minetest.log ("error", "on_place handler for "..stack:get_name ().." crashed - "..leftover)
end end
end end
end end
if not placed then if not placed then
if not minetest.registered_nodes[itemname] then if not minetest.registered_nodes[stack:get_name ()] then
return false return false
end end
minetest.set_node (pos, { name = itemname, param1 = 0, param2 = 0 }) minetest.set_node (pos, { name = stack:get_name (), param1 = 0, param2 = 0 })
if itemdef and itemdef.after_place_node then if itemdef and itemdef.after_place_node then
local result, msg = pcall (itemdef.after_place_node, pos, nil, stack, pointed_thing) local result, msg = pcall (itemdef.after_place_node, pos, nil, stack, pointed_thing)
@@ -154,11 +154,13 @@ local function place_node (itemname, pos)
pcall (minetest.sound_play, itemdef.sounds.place, { pos = pos }) pcall (minetest.sound_play, itemdef.sounds.place, { pos = pos })
end end
end end
end
return true return true
end end
return false
end
-- slot: -- slot:
@@ -219,7 +221,7 @@ local function deploy_item (pos, node, slot, range)
local deploypos = get_deploy_pos (pos, node.param2, range) local deploypos = get_deploy_pos (pos, node.param2, range)
if item and deploypos then if item and deploypos then
if place_node (name, deploypos) then if place_node (stack, deploypos) then
stack:set_count (stack:get_count () - 1) stack:set_count (stack:get_count () - 1)
inv:set_stack ("main", slot, stack) inv:set_stack ("main", slot, stack)

View File

@@ -1,4 +1,4 @@
local version = "0.1.12" local version = "0.1.13"
local mod_storage = minetest.get_mod_storage () local mod_storage = minetest.get_mod_storage ()

View File

@@ -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, digistuff optional_depends = mesecons, digilines, unifieddyes, intllib, hopper, digistuff

View File

@@ -13,7 +13,7 @@ CC BY-SA 3.0
Version Version
======= =======
0.1.12 0.1.13
Minetest Version Minetest Version
@@ -28,7 +28,6 @@ default
Optional Dependencies Optional Dependencies
===================== =====================
lwdrops
mesecons mesecons
digilines digilines
unifieddyes unifieddyes

View File

@@ -67,43 +67,6 @@ end
-- check for lwdrops
if minetest.global_exists ("lwdrops") then
utils.lwdrops_supported = true
utils.on_destroy = lwdrops.on_destroy
utils.item_pickup = lwdrops.item_pickup
utils.item_drop = lwdrops.item_drop
else
utils.lwdrops_supported = false
-- dummy
utils.on_destroy = function (itemstack)
end
utils.item_pickup = function (entity, cleanup)
local stack = nil
if entity and entity.name and entity.name == "__builtin:item" and
entity.itemstring and entity.itemstring ~= "" then
stack = ItemStack (entity.itemstring)
if cleanup ~= false then
entity.itemstring = ""
entity.object:remove ()
end
end
return stack
end
utils.item_drop = function (itemstack, dropper, pos)
return minetest.item_drop (itemstack, dropper, pos)
end
end
-- check for unifieddyes -- check for unifieddyes
if minetest.global_exists ("unifieddyes") then if minetest.global_exists ("unifieddyes") then
utils.unifieddyes_supported = true utils.unifieddyes_supported = true
@@ -138,6 +101,45 @@ end
function utils.on_destroy (itemstack)
local stack = ItemStack (itemstack)
if stack and stack:get_count () > 0 then
local def = utils.find_item_def (stack:get_name ())
if def and def.on_destroy then
def.on_destroy (stack)
end
end
end
function utils.item_pickup (entity, cleanup)
local stack = nil
if entity and entity.name and entity.name == "__builtin:item" and
entity.itemstring and entity.itemstring ~= "" then
stack = ItemStack (entity.itemstring)
if cleanup ~= false then
entity.itemstring = ""
entity.object:remove ()
end
end
return stack
end
function utils.item_drop (itemstack, dropper, pos)
return minetest.item_drop (itemstack, dropper, pos)
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