updated digilines, framedglass, mesecons, pipeworks, quartz

technic, unifiedinventory, and unifiedbricks
This commit is contained in:
Vanessa Ezekowitz 2017-03-04 23:58:38 -05:00
parent 3eb0b959da
commit a46f07cbfb
21 changed files with 378 additions and 60 deletions

View File

@ -9,7 +9,7 @@ dofile(modpath .. "/wire_std.lua")
function digiline:receptor_send(pos, rules, channel, msg)
local checked = {}
checked[tostring(pos.x).."_"..tostring(pos.y).."_"..tostring(pos.z)] = true -- exclude itself
checked[minetest.hash_node_position(pos)] = true -- exclude itself
for _,rule in ipairs(rules) do
if digiline:rules_link(pos, digiline:addPosRule(pos, rule)) then
digiline:transmit(digiline:addPosRule(pos, rule), channel, msg, checked)

View File

@ -14,7 +14,7 @@ function digiline:importrules(spec, node)
end
function digiline:getAnyInputRules(pos)
local node = minetest.get_node(pos)
local node = digiline:get_node_force(pos)
local spec = digiline:getspec(node)
if not spec then return end
@ -27,7 +27,7 @@ function digiline:getAnyInputRules(pos)
end
function digiline:getAnyOutputRules(pos)
local node = minetest.get_node(pos)
local node = digiline:get_node_force(pos)
local spec = digiline:getspec(node)
if not spec then return end
@ -63,28 +63,57 @@ function digiline:rules_link_anydir(output, input)
or digiline:rules_link(input, output)
end
local function queue_new()
return {nextRead = 1, nextWrite = 1}
end
local function queue_empty(queue)
return queue.nextRead == queue.nextWrite
end
local function queue_enqueue(queue, object)
local nextWrite = queue.nextWrite
queue[nextWrite] = object
queue.nextWrite = nextWrite + 1
end
local function queue_dequeue(queue)
local nextRead = queue.nextRead
local object = queue[nextRead]
queue[nextRead] = nil
queue.nextRead = nextRead + 1
return object
end
function digiline:transmit(pos, channel, msg, checked)
local checkedid = tostring(pos.x).."_"..tostring(pos.y).."_"..tostring(pos.z)
if checked[checkedid] then return end
checked[checkedid] = true
digiline:vm_begin()
local queue = queue_new()
queue_enqueue(queue, pos)
while not queue_empty(queue) do
local curPos = queue_dequeue(queue)
local node = digiline:get_node_force(curPos)
local spec = digiline:getspec(node)
if spec then
-- Effector actions --> Receive
if spec.effector then
spec.effector.action(curPos, node, channel, msg)
end
local node = minetest.get_node(pos)
local spec = digiline:getspec(node)
if not spec then return end
-- Effector actions --> Receive
if spec.effector then
spec.effector.action(pos, node, channel, msg)
end
-- Cable actions --> Transmit
if spec.wire then
local rules = digiline:importrules(spec.wire.rules, node)
for _,rule in ipairs(rules) do
if digiline:rules_link(pos, digiline:addPosRule(pos, rule)) then
digiline:transmit(digiline:addPosRule(pos, rule), channel, msg, checked)
-- Cable actions --> Transmit
if spec.wire then
local rules = digiline:importrules(spec.wire.rules, node)
for _, rule in ipairs(rules) do
local nextPos = digiline:addPosRule(curPos, rule)
if digiline:rules_link(curPos, nextPos) then
local checkedID = minetest.hash_node_position(nextPos)
if not checked[checkedID] then
checked[checkedID] = true
queue_enqueue(queue, nextPos)
end
end
end
end
end
end
digiline:vm_end()
end

View File

@ -65,3 +65,92 @@ function digiline:tablecopy(table) -- deep table copy
return newtable
end
-- VoxelManipulator-based node access functions:
-- Maps from a hashed mapblock position (as returned by hash_blockpos) to a
-- table.
--
-- Contents of the table are:
-- “va” → the VoxelArea
-- “data” → the data array
-- “param1” → the param1 array
-- “param2” → the param2 array
--
-- Nil if no bulk-VM operation is in progress.
local vm_cache = nil
-- Starts a bulk-VoxelManipulator operation.
--
-- During a bulk-VoxelManipulator operation, calls to get_node_force operate
-- directly on VM-loaded arrays, which should be faster for reading many nodes
-- in rapid succession. However, the cache must be flushed with vm_end once the
-- scan is finished, to avoid using stale data in future.
function digiline:vm_begin()
vm_cache = {}
end
-- Ends a bulk-VoxelManipulator operation, freeing the cached data.
function digiline:vm_end()
vm_cache = nil
end
-- The dimension of a mapblock in nodes.
local MAPBLOCKSIZE = 16
-- Converts a node position into a hash of a mapblock position.
local function vm_hash_blockpos(pos)
return minetest.hash_node_position({
x = math.floor(pos.x / MAPBLOCKSIZE),
y = math.floor(pos.y / MAPBLOCKSIZE),
z = math.floor(pos.z / MAPBLOCKSIZE)
})
end
-- Gets the cache entry covering a position, populating it if necessary.
local function vm_get_or_create_entry(pos)
local hash = vm_hash_blockpos(pos)
local tbl = vm_cache[hash]
if not tbl then
local vm = minetest.get_voxel_manip(pos, pos)
local min_pos, max_pos = vm:get_emerged_area()
local va = VoxelArea:new{MinEdge = min_pos, MaxEdge = max_pos}
tbl = {va = va, data = vm:get_data(), param1 = vm:get_light_data(), param2 = vm:get_param2_data()}
vm_cache[hash] = tbl
end
return tbl
end
-- Gets the node at a position during a bulk-VoxelManipulator operation.
local function vm_get_node(pos)
local tbl = vm_get_or_create_entry(pos)
local index = tbl.va:indexp(pos)
local node_value = tbl.data[index]
local node_param1 = tbl.param1[index]
local node_param2 = tbl.param2[index]
return {name = minetest.get_name_from_content_id(node_value), param1 = node_param1, param2 = node_param2}
end
-- Gets the node at a given position, regardless of whether it is loaded or
-- not.
--
-- Outside a bulk-VoxelManipulator operation, if the mapblock is not loaded, it
-- is pulled into the servers main map data cache and then accessed from
-- there.
--
-- Inside a bulk-VoxelManipulator operation, the operations VM cache is used.
function digiline:get_node_force(pos)
if vm_cache then
return vm_get_node(pos)
end
local node = minetest.get_node(pos)
if node.name == "ignore" then
-- Node is not currently loaded; use a VoxelManipulator to prime
-- the mapblock cache and try again.
minetest.get_voxel_manip(pos, pos)
node = minetest.get_node(pos)
end
return node
end

View File

@ -100,16 +100,8 @@ function framedglass.color_on_punch(pos, node, puncher, pointed_thing)
local itemstack = puncher:get_wielded_item()
local itemname = itemstack:get_name()
if not string.find(itemname, "dye:") then
if minetest.registered_nodes[node.name] then
local pos2 = select_node(pointed_thing)
if pos2 and is_buildable_to(puncher, pos2) then
minetest.set_node(pos2, { name = itemname })
if not creative_mode then
itemstack:take_item()
end
end
end
if not string.find(itemname, "dye:")
and not string.find(itemname, "unifieddyes:") then
return itemstack
end
@ -138,8 +130,6 @@ function framedglass.color_on_punch(pos, node, puncher, pointed_thing)
local inv = puncher:get_inventory()
local prevdye = "dye:"..oldcolor2
print(oldcolor, oldcolor2, newcolor, newcolor2, prevdye)
if not (inv:contains_item("main", prevdye) and creative_mode) and minetest.registered_items[prevdye] then
if inv:room_for_item("main", prevdye) then
inv:add_item("main", prevdye)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -145,7 +145,7 @@ mesecon.register_movestone("mesecons_movestones:sticky_movestone", {
}, true)
minetest.register_craft({
output = "mesecons_movestones:sticky_movestone 2",
output = "mesecons_movestones:sticky_movestone",
recipe = {
{"mesecons_materials:glue", "mesecons_movestones:movestone", "mesecons_materials:glue"},
}

View File

@ -19,5 +19,6 @@ pipeworks.enable_mese_sand_tube = true
pipeworks.enable_one_way_tube = true
pipeworks.enable_priority_tube = true
pipeworks.enable_cyclic_mode = true
pipeworks.drop_on_routing_fail = false
pipeworks.delete_item_on_clearobject = true

View File

@ -175,6 +175,25 @@ local function punch_filter(data, filtpos, filtnode, msg)
local fromdef = minetest.registered_nodes[fromnode.name]
if not fromdef then return end
local fromtube = fromdef.tube
local input_special_cases = {
["technic:mv_furnace"] = "dst",
["technic:mv_furnace_active"] = "dst",
["technic:mv_electric_furnace"] = "dst",
["technic:mv_electric_furnace_active"] = "dst",
["technic:mv_alloy_furnace"] = "dst",
["technic:mv_alloy_furnace_active"] = "dst",
["technic:mv_centrifuge"] = "dst",
["technic:mv_centrifuge_active"] = "dst",
["technic:mv_compressor"] = "dst",
["technic:mv_compressor_active"] = "dst",
["technic:mv_extractor"] = "dst",
["technic:mv_extractor_active"] = "dst",
["technic:mv_grinder"] = "dst",
["technic:mv_grinder_active"] = "dst",
["technic:tool_workshop"] = "src",
}
if fromtube then fromtube.input_inventory = input_special_cases[fromnode.name] or fromtube.input_inventory end
if not (fromtube and fromtube.input_inventory) then return end
local slotseq_mode

View File

@ -246,15 +246,24 @@ luaentity.register_entity("pipeworks:tubed_item", {
if moved then
local found_next, new_velocity = go_next(self.start_pos, velocity, stack) -- todo: color
local rev_vel = vector.multiply(velocity, -1)
local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir)))
local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1
if not found_next then
drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
if drop_pos then
-- Using add_item instead of item_drop since this makes pipeworks backward
-- compatible with Minetest 0.4.13.
-- Using item_drop here makes Minetest 0.4.13 crash.
minetest.add_item(drop_pos, stack)
self:remove()
return
if pipeworks.drop_on_routing_fail or not tube_present then
drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
if drop_pos then
-- Using add_item instead of item_drop since this makes pipeworks backward
-- compatible with Minetest 0.4.13.
-- Using item_drop here makes Minetest 0.4.13 crash.
minetest.add_item(drop_pos, stack)
self:remove()
return
end
else
velocity = vector.multiply(velocity, -1)
self:setvelocity(velocity)
end
end

View File

@ -1,3 +1,4 @@
default
stairs
moreblocks?
intllib?

View File

@ -1,16 +1,20 @@
local settings = Settings(minetest.get_modpath("quartz").."/settings.txt")
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--
-- Item Registration
--
-- Quartz Crystal
minetest.register_craftitem("quartz:quartz_crystal", {
description = "Quartz Crystal",
description = S("Quartz Crystal"),
inventory_image = "quartz_crystal_full.png",
})
minetest.register_craftitem("quartz:quartz_crystal_piece", {
description = "Quartz Crystal Piece",
description = S("Quartz Crystal Piece"),
inventory_image = "quartz_crystal_piece.png",
})
@ -20,7 +24,7 @@ minetest.register_craftitem("quartz:quartz_crystal_piece", {
-- Ore
minetest.register_node("quartz:quartz_ore", {
description = "Quartz Ore",
description = S("Quartz Ore"),
tiles = {"default_stone.png^quartz_ore.png"},
groups = {cracky=3, stone=1},
drop = 'quartz:quartz_crystal',
@ -40,7 +44,7 @@ minetest.register_ore({
-- Quartz Block
minetest.register_node("quartz:block", {
description = "Quartz Block",
description = S("Quartz Block"),
tiles = {"quartz_block.png"},
groups = {cracky=3, oddly_breakable_by_hand=1},
sounds = default.node_sound_glass_defaults(),
@ -48,7 +52,7 @@ minetest.register_node("quartz:block", {
-- Chiseled Quartz
minetest.register_node("quartz:chiseled", {
description = "Chiseled Quartz",
description = S("Chiseled Quartz"),
tiles = {"quartz_chiseled.png"},
groups = {cracky=3, oddly_breakable_by_hand=1},
sounds = default.node_sound_glass_defaults(),
@ -56,7 +60,7 @@ minetest.register_node("quartz:chiseled", {
-- Quartz Pillar
minetest.register_node("quartz:pillar", {
description = "Quartz Pillar",
description = S("Quartz Pillar"),
paramtype2 = "facedir",
tiles = {"quartz_pillar_top.png", "quartz_pillar_top.png", "quartz_pillar_side.png"},
groups = {cracky=3, oddly_breakable_by_hand=1},
@ -68,15 +72,15 @@ minetest.register_node("quartz:pillar", {
stairs.register_stair_and_slab("quartzblock", "quartz:block",
{cracky=3, oddly_breakable_by_hand=1},
{"quartz_block.png"},
"Quartz stair",
"Quartz slab",
S("Quartz stair"),
S("Quartz slab"),
default.node_sound_glass_defaults())
stairs.register_slab("quartzstair", "quartz:pillar",
stairs.register_stair_and_slab("quartzstair", "quartz:pillar",
{cracky=3, oddly_breakable_by_hand=1},
{"quartz_pillar_top.png", "quartz_pillar_top.png", "quartz_pillar_side.png"},
"Quartz Pillar stair",
"Quartz Pillar slab",
S("Quartz Pillar stair"),
S("Quartz Pillar slab"),
default.node_sound_glass_defaults())
--

45
quartz/intllib.lua Normal file
View File

@ -0,0 +1,45 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- Get the latest version of this file at:
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
local function format(str, ...)
local args = { ... }
local function repl(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
replacement = replacement..close
end
return replacement
else
return "@"..open..num..close
end
end
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
end
local gettext, ngettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext = intllib.make_gettext_pair()
else
-- Old method using text files.
gettext = intllib.Getter()
end
end
-- Fill in missing functions.
gettext = gettext or function(msgid, ...)
return format(msgid, ...)
end
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext

59
quartz/locale/es.po Normal file
View File

@ -0,0 +1,59 @@
# Spanish translations for PACKAGE package
# Traducciones al español para el paquete PACKAGE.
# Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Diego Martínez <kaeza@users.noreply.github.com>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-19 21:50-0700\n"
"PO-Revision-Date: 2017-02-20 15:03-0300\n"
"Last-Translator: Diego Martínez <kaeza@users.noreply.github.com>\n"
"Language-Team: Spanish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: init.lua:13
msgid "Quartz Crystal"
msgstr "Cristal de cuarzo"
#: init.lua:17
msgid "Quartz Crystal Piece"
msgstr "Trozo de cristal de cuarzo"
#: init.lua:27
msgid "Quartz Ore"
msgstr "Mineral de cuarzo"
#: init.lua:47
msgid "Quartz Block"
msgstr "Bloque de cuarzo"
#: init.lua:55
msgid "Chiseled Quartz"
msgstr "Cuarzo cincelado"
#: init.lua:63
msgid "Quartz Pillar"
msgstr "Pilar de cuarzo"
#: init.lua:75
msgid "Quartz stair"
msgstr "Escaleras de cuarzo"
#: init.lua:76
msgid "Quartz slab"
msgstr "Losa de cuarzo"
#: init.lua:82
msgid "Quartz Pillar stair"
msgstr "Escaleras de pilar de cuarzo"
#: init.lua:83
msgid "Quartz Pillar slab"
msgstr "Losa de pilar de cuarzo"

View File

@ -0,0 +1,57 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-19 21:50-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua:13
msgid "Quartz Crystal"
msgstr ""
#: init.lua:17
msgid "Quartz Crystal Piece"
msgstr ""
#: init.lua:27
msgid "Quartz Ore"
msgstr ""
#: init.lua:47
msgid "Quartz Block"
msgstr ""
#: init.lua:55
msgid "Chiseled Quartz"
msgstr ""
#: init.lua:63
msgid "Quartz Pillar"
msgstr ""
#: init.lua:75
msgid "Quartz stair"
msgstr ""
#: init.lua:76
msgid "Quartz slab"
msgstr ""
#: init.lua:82
msgid "Quartz Pillar stair"
msgstr ""
#: init.lua:83
msgid "Quartz Pillar slab"
msgstr ""

View File

@ -30,7 +30,7 @@ local run = function(pos, node)
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
local max_output = 50 * 45 -- four param2's at 15 makes 60, cap it lower for "overload protection"
local max_output = 35 * 45 -- four param2's at 15 makes 60, cap it lower for "overload protection"
-- (plus we want the gen to report 100% if three sides have full flow)
local positions = {
@ -47,7 +47,7 @@ local run = function(pos, node)
end
end
eu_supply = math.min(50 * water_flow, max_output)
eu_supply = math.min(35 * water_flow, max_output)
production_level = math.floor(100 * eu_supply / max_output)
if production_level > 0 then

View File

@ -51,8 +51,11 @@ for i = 1, 4 do
elseif slots == 24 then
formspec = formspec.."background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]"
end
formspec = (formspec.."background[6.06,0;0.92,0.92;ui_bags_trash.png]"
.."list[detached:trash;main;6,0.1;1,1;]")
local player_name = player:get_player_name() -- For if statement.
if unified_inventory.trash_enabled or unified_inventory.is_creative(player_name) or minetest.get_player_privs(player_name).give then
formspec = (formspec.."background[6.06,0;0.92,0.92;ui_bags_trash.png]"
.."list[detached:trash;main;6,0.1;1,1;]")
end
return {formspec=formspec}
end,
})

View File

@ -45,6 +45,9 @@ unified_inventory = {
-- "Lite" mode
lite_mode = minetest.setting_getbool("unified_inventory_lite"),
-- Trash enabled
trash_enabled = (minetest.setting_getbool("unified_inventory_trash") ~= false),
pagecols = 8,
pagerows = 10,

View File

@ -175,8 +175,11 @@ unified_inventory.register_page("craft", {
formspec = formspec.."listcolors[#00000000;#00000000]"
formspec = formspec.."list[current_player;craftpreview;6,"..formspecy..";1,1;]"
formspec = formspec.."list[current_player;craft;2,"..formspecy..";3,3;]"
formspec = formspec.."label[7,"..(formspecy + 1.5)..";" .. F("Trash:") .. "]"
formspec = formspec.."list[detached:trash;main;7,"..(formspecy + 2)..";1,1;]"
if unified_inventory.trash_enabled or unified_inventory.is_creative(player_name) or minetest.get_player_privs(player_name).give then
formspec = formspec.."label[7,"..(formspecy + 1.5)..";" .. F("Trash:") .. "]"
formspec = formspec.."background[7,"..(formspecy + 2)..";1,1;ui_single_slot.png]"
formspec = formspec.."list[detached:trash;main;7,"..(formspecy + 2)..";1,1;]"
end
formspec = formspec.."listring[current_name;craft]"
formspec = formspec.."listring[current_player;main]"
if unified_inventory.is_creative(player_name) then

View File

@ -5,3 +5,7 @@ unified_inventory_lite (Lite mode) bool false
#If enabled, bags will be made available which can be used to extend
#inventory storage size.
unified_inventory_bags (Enable bags) bool true
#If enabled, the trash slot can be used by those without both creative
#and the give privilege.
unified_inventory_trash (Enable trash) bool true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -113,6 +113,7 @@ minetest.register_node("unifiedbricks:brickblock", {
minetest.override_item("default:brick", {
ud_replacement_node = "unifiedbricks:brickblock",
palette = "unifieddyes_palette_extended.png",
groups = {cracky = 3, ud_param2_colorable = 1}
})
@ -136,6 +137,7 @@ minetest.register_node("unifiedbricks:clayblock", {
minetest.override_item("default:clay", {
ud_replacement_node = "unifiedbricks:clayblock",
palette = "unifieddyes_palette_extended.png",
groups = {crumbly = 3, ud_param2_colorable = 1}
})