Merge branch 'dev' into mapocalypse
This commit is contained in:
commit
08bc1bce7c
@ -81,6 +81,7 @@ end
|
||||
|
||||
include("compat_vector")
|
||||
include("issue9043")
|
||||
include("nodemetahack")
|
||||
|
||||
include("util_misc")
|
||||
include("util_hookmeta")
|
||||
@ -96,6 +97,7 @@ include("util_translate")
|
||||
include("util_ezschematic")
|
||||
include("util_gametime")
|
||||
include("util_settlescan")
|
||||
include("util_texturemod")
|
||||
include("match")
|
||||
|
||||
include("fx_digparticles")
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local io, minetest, nodecore, pairs, table, type
|
||||
= io, minetest, nodecore, pairs, table, type
|
||||
local io, minetest, nodecore, pairs, table, tostring, type
|
||||
= io, minetest, nodecore, pairs, table, tostring, type
|
||||
local io_open, table_concat, table_sort
|
||||
= io.open, table.concat, table.sort
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -32,7 +32,7 @@ local function overlay(name, img, imgtype)
|
||||
end
|
||||
f:close()
|
||||
|
||||
return img .. "^" .. tpath .. "^[makealpha:255,254,2"
|
||||
return tostring(nodecore.tmod(img):add(tpath):makealpha(255, 254, 2))
|
||||
end
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
|
35
mods/nc_api/nodemetahack.lua
Normal file
35
mods/nc_api/nodemetahack.lua
Normal file
@ -0,0 +1,35 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local getmetatable, minetest, pairs
|
||||
= getmetatable, minetest, pairs
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local publicfields = {
|
||||
formspec = true,
|
||||
infotext = true
|
||||
}
|
||||
|
||||
local function hook(meta)
|
||||
for k, v in pairs(meta) do
|
||||
if k:sub(1, 4) == "set_" then
|
||||
meta[k] = function(data, name, ...)
|
||||
if not publicfields[name] then
|
||||
data:mark_as_private(name)
|
||||
end
|
||||
return v(data, name, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local rawmeta = minetest.get_meta
|
||||
function minetest.get_meta(...)
|
||||
local raw = rawmeta(...)
|
||||
if raw then
|
||||
local meta = getmetatable(raw)
|
||||
if meta then
|
||||
hook(meta)
|
||||
minetest.get_meta = rawmeta
|
||||
end
|
||||
end
|
||||
return raw
|
||||
end
|
95
mods/nc_api/util_texturemod.lua
Normal file
95
mods/nc_api/util_texturemod.lua
Normal file
@ -0,0 +1,95 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local nodecore, pairs, setmetatable, string, tostring
|
||||
= nodecore, pairs, setmetatable, string, tostring
|
||||
local string_find, string_gsub
|
||||
= string.find, string.gsub
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local tmod = {}
|
||||
local tmeta = {}
|
||||
setmetatable(tmod, tmeta)
|
||||
nodecore.tmod = tmod
|
||||
|
||||
function tmod:new(img)
|
||||
local obj = {img = img}
|
||||
local ometa = {}
|
||||
for k, v in pairs(tmeta) do ometa[k] = v end
|
||||
ometa.__index = self
|
||||
setmetatable(obj, ometa)
|
||||
return obj
|
||||
end
|
||||
tmeta.__call = tmod.new
|
||||
|
||||
function tmeta:__tostring()
|
||||
return self.img
|
||||
end
|
||||
|
||||
function tmod:add(img)
|
||||
if not self.img then return tmod:new(img) end
|
||||
img = tostring(img)
|
||||
if string_find(img, "%^") then
|
||||
return tmod:new(self.img .. "^(" .. img .. ")")
|
||||
else
|
||||
return tmod:new(self.img .. "^" .. img)
|
||||
end
|
||||
end
|
||||
|
||||
local function esc(s)
|
||||
return string_gsub(string_gsub(tostring(s),
|
||||
"%^", "\\^"), ":", "\\:")
|
||||
end
|
||||
|
||||
local function addmod(self, name)
|
||||
if self.img then
|
||||
return self.img .. "^[" .. name
|
||||
end
|
||||
return "[" .. name
|
||||
end
|
||||
|
||||
local function simplemod(name, ...)
|
||||
local delims = {...}
|
||||
local lastdelim = delims[#delims]
|
||||
return function(self, ...)
|
||||
local s = addmod(self, name)
|
||||
local args = {...}
|
||||
for i = 1, #args do
|
||||
s = s .. (delims[i] or lastdelim) .. esc(args[i])
|
||||
end
|
||||
return tmod:new(s)
|
||||
end
|
||||
end
|
||||
|
||||
for k in pairs({
|
||||
crack = true,
|
||||
cracko = true,
|
||||
opacity = true,
|
||||
invert = true,
|
||||
brighten = true,
|
||||
noalpha = true,
|
||||
lowpart = true,
|
||||
verticalframe = true,
|
||||
mask = true,
|
||||
colorize = true,
|
||||
multiply = true
|
||||
}) do
|
||||
tmod[k] = simplemod(k, ":")
|
||||
end
|
||||
|
||||
tmod.resize = simplemod("resize", ":", "x")
|
||||
tmod.makealpha = simplemod("makealpha", ":", ",")
|
||||
tmod.transform = simplemod("transform", "")
|
||||
tmod.sheet = simplemod("sheet", ":", "x", ":", ",")
|
||||
|
||||
function tmod:inventorycube(...)
|
||||
local s = addmod(self, "inventorycube")
|
||||
for _, arg in pairs({...}) do
|
||||
s = s .. "{" .. string_gsub(tostring(arg), "%^", "&")
|
||||
end
|
||||
return tmod:new(s)
|
||||
end
|
||||
|
||||
tmod.combine = simplemod("combine", ":", "x")
|
||||
function tmod:layer(x, y, img)
|
||||
return tmod:new((self.img or "") .. ":" .. esc(x) .. ","
|
||||
.. esc(y) .. "=" .. esc(img))
|
||||
end
|
@ -1,22 +1,12 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local nodecore, pairs
|
||||
= nodecore, pairs
|
||||
local nodecore
|
||||
= nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
nodecore.register_playerstep({
|
||||
label = "inventory requires interact",
|
||||
action = function(player, data)
|
||||
action = function(player)
|
||||
if nodecore.interact(player) then return end
|
||||
local pos = player:get_pos()
|
||||
pos.y = pos.y + data.properties.eye_height
|
||||
local inv = player:get_inventory()
|
||||
for i, stack in pairs(inv:get_list("main")) do
|
||||
if not stack:is_empty() then
|
||||
if nodecore.item_is_virtual(stack) then
|
||||
nodecore.item_eject(pos, stack, 0.001)
|
||||
inv:set_stack("main", i, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
return nodecore.inventory_dump(player)
|
||||
end
|
||||
})
|
||||
|
@ -1,6 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
local math, minetest, nodecore, tostring
|
||||
= math, minetest, nodecore, tostring
|
||||
local math_ceil, math_cos, math_pi
|
||||
= math.ceil, math.cos, math.pi
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -35,11 +37,42 @@ minetest.register_node(modname .. ":sponge_wet", {
|
||||
sounds = nodecore.sounds("nc_terrain_swishy")
|
||||
})
|
||||
|
||||
local base = (nodecore.tmod(modname .. ".png")
|
||||
:resize(16, 16))
|
||||
local liv1 = (nodecore.tmod(modname .. "_living.png")
|
||||
:resize(16, 16)
|
||||
:mask(modname .. "_mask1.png"))
|
||||
local liv2 = (nodecore.tmod(modname .. "_living.png")
|
||||
:resize(16, 16)
|
||||
:mask(nodecore.tmod(modname .. "_mask1.png")
|
||||
:invert("a")))
|
||||
local water = (nodecore.tmod("nc_terrain_water.png")
|
||||
:opacity(96))
|
||||
local h = 32
|
||||
local txr = nodecore.tmod:combine(16, h * 16)
|
||||
for i = 0, h - 1 do
|
||||
local a1 = math_ceil(math_cos(i * math_pi * 2 / h) * 63 + 192)
|
||||
local a2 = math_ceil(-math_cos(i * math_pi * 2 / h) * 63 + 192)
|
||||
txr = txr:layer(0, 16 * i, base
|
||||
:add(liv1:opacity(a1))
|
||||
:add(liv2:opacity(a2))
|
||||
:add(water))
|
||||
end
|
||||
|
||||
minetest.register_node(modname .. ":sponge_living", {
|
||||
description = "Living Sponge",
|
||||
drawtype = "allfaces_optional",
|
||||
tiles = {modname .. ".png^" .. modname
|
||||
.. "_living.png^(nc_terrain_water.png^[opacity:96)"},
|
||||
tiles = {
|
||||
{
|
||||
name = tostring(txr),
|
||||
animation = {
|
||||
["type"] = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 2
|
||||
}
|
||||
}
|
||||
},
|
||||
paramtype = "light",
|
||||
groups = {
|
||||
crumbly = 2,
|
||||
|
BIN
mods/nc_sponge/textures/nc_sponge_mask1.png
Normal file
BIN
mods/nc_sponge/textures/nc_sponge_mask1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/nc_sponge/textures/nc_sponge_mask2.png
Normal file
BIN
mods/nc_sponge/textures/nc_sponge_mask2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -1,23 +0,0 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, minetest, nodecore
|
||||
= ItemStack, minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local cheatdesc = "Cheat Torch"
|
||||
local cheattrans = nodecore.translate(cheatdesc)
|
||||
|
||||
minetest.register_chatcommand("torchlite", {
|
||||
description = "Create long-lasting " .. cheattrans,
|
||||
privs = {["give"] = true},
|
||||
func = function(pname)
|
||||
local player = minetest.get_player_by_name(pname)
|
||||
if not player then return end
|
||||
local stack = ItemStack(modname .. ":torch_lit")
|
||||
local meta = stack:get_meta()
|
||||
meta:set_string("description", cheatdesc)
|
||||
meta:set_float("expire", 1e300)
|
||||
player:get_inventory():add_item("main", stack)
|
||||
end
|
||||
})
|
@ -7,4 +7,3 @@ nodecore.amcoremod()
|
||||
|
||||
include("node")
|
||||
include("abm")
|
||||
include("cmd")
|
||||
|
Loading…
x
Reference in New Issue
Block a user