This commit is contained in:
root 2021-01-13 21:04:51 +01:00
parent 66164cb73e
commit 4b0d5c0489
23 changed files with 1059 additions and 209 deletions

View File

@ -1,27 +1,28 @@
# [mod] Visible Player Armor [3d_armor]
| | | | |
|--|--|--|--|
|-[Overview](#overview) |||-[API](#api)|
|-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage)
|- - [disable_specific_materials](#to-disable-individual-armor-materials) |||- - [Armor Registration](#armor-registration)
|- - [armor_init_delay](#initialization-glitches-when-a-player-first-joins) |||- - [Registering Armor Groups](#registering-armor-groups)
|- - [armor_init_times](#number-of-initialization-attempts) |||- - [Groups used by 3d_Armor](#groups-used-by-3d_armor)
|- - [armor_bones_delay](#armor-not-in-bones-due-to-server-lag) |||- - - [Elements](#elements)
|- - [armor_update_time](#how-often-player-armor-items-are-updated) |||- - - [Attributes](#attributes)
|- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics)
|- - [armor_destroy](#destroy-armor-when-a-player-dies) |||- - - [Durability](#durability)
|- - [armor_level_multiplier](#armor-level-multiplyer) |||- - [Armour Functions](#armour-functions)
|- - [armor_heal_multiplier](#armor-healing-multiplyer) |||- - - [armor:set_player_armor](#armor-set_player_armor)
|- - [armor_water_protect](#enable-water-protection) |||- - - [armor:punch](#armor-punch)
|- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:damage](#armor-damage)
|- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:remove_all](#armor-remove_all)
|- - [armor_migrate_old_inventory](#migration-of-old-armor-inventories) |||- - - [armor:equip](#armor-equip)
|- - [wieldview_update_time](#how-often-player-wield-items-are-updated) |||- - - [armor:unequip](#armor-unequip)
| - [Credits](#credits) |||- - - [armor:update_skin](#armor-update_skin)
| |||- - [Callbacks](#Callbacks)
| |||- - - [Item callbacks](#item-callbacks)
| |||- - - [Global callbacks](#global-callbacks)
|-[Overview](#overview) |||-[API](#api)
|-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage)
|- - [disable_specific_materials](#to-disable-individual-armor-materials) |||- - [Armor Registration](#armor-registration)
|- - [armor_init_delay](#initialization-glitches-when-a-player-first-joins) |||- - [Registering Armor Groups](#registering-armor-groups)
|- - [armor_init_times](#number-of-initialization-attempts) |||- - [Groups used by 3d_Armor](#groups-used-by-3d_armor)
|- - [armor_bones_delay](#armor-not-in-bones-due-to-server-lag) |||- - - [Elements](#elements)
|- - [armor_update_time](#how-often-player-armor-items-are-updated) |||- - - [Attributes](#attributes)
|- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics)
|- - [armor_destroy](#destroy-armor-when-a-player-dies) |||- - - [Durability](#durability)
|- - [armor_level_multiplier](#armor-level-multiplyer) |||- - - [Armor Material](#armor-material)
|- - [armor_heal_multiplier](#armor-healing-multiplyer) |||- - [Armour Functions](#armor-functions)
|- - [armor_set_elements](#allows-the-customisation-of-armor-set) |||- - - [armor:set_player_armor](#armor-set_player_armor)
|- - [armor_set_bonus](#armor-set-bonus-multiplier) |||- - - [armor:punch](#armor-punch)
|- - [armor_water_protect](#enable-water-protection) |||- - - [armor:damage](#armor-damage)
|- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:remove_all](#armor-remove_all)
|- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:equip](#armor-equip)
|- - [armor_migrate_old_inventory](#migration-of-old-armor-inventories) |||- - - [armor:unequip](#armor-unequip)
|- - [wieldview_update_time](#how-often-player-wield-items-are-updated) |||- - - [armor:update_skin](#armor-update_skin)
|-[Credits](#credits) |||- - [Callbacks](#Callbacks)
| |||- - - [Item callbacks](#item-callbacks)
| |||- - - [Global callbacks](#global-callbacks)
# Overview
@ -39,7 +40,7 @@ Overall level is boosted by 10% when wearing a full matching set.
# Armor Configuration
Override the following default settings by adding them to your ***minetest.conf*** file.
Change the following default settings by going to Main Menu>>Settings(Tab)>>All Settings(Button)>>Mods>>minetest-3d_Armor>>3d_Armor
### To disable individual armor materials
**set the below to false**
@ -94,6 +95,17 @@ Override the following default settings by adding them to your ***minetest.conf*
**eg: armor_heal_multiplier = 0 will disable healing altogether.**
armor_heal_multiplier = 1
### Allows the customisation of armor set
**Shields already configured as need to be worn to complete an armor set**
**These names come from [Element names](#groups-used-by-3d_armor), the second half of the element name only is used eg armor_head is head**
armor_set_elements = head torso legs feet shield
### Armor set bonus multiplier
**Set to 1 to disable set bonus**
armor_set_multiplier = 1.1
### Enable water protection
**periodically restores breath when activated**
@ -174,7 +186,7 @@ Wrapper function for `minetest.register_tool`, which enables the easy registrati
preview = "mod_name_leather_chestplate_preview.png",
groups = {armor_torso=1, armor_heal=0, armor_use=2000, flammable=1},
armor_groups = {fleshy=10},
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1}
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1}
})
*See ***armor.lua*** under **3d_armor>>3d_armor** for further examples*
@ -254,13 +266,9 @@ Adding Elements is more complex but the below code can be used to add new elemen
if minetest.global_exists("armor") and armor.elements then
table.insert(armor.elements, "hands")
local mult = armor.config.level_multiplier or 1
armor.config.level_multiplier = mult * 0.5
end
**1st line** not strictly needed but checks that the global table "armor" and subtable "elements" exists
**2nd line** adds a new value to the armor.elements table called "hands"
**3rd line** in this case will be set to one ***note: need more detail here***
**4th line** simply sets the multiplier, by setting 0.5 smaller armor becomes less effective and larger more effective. good values are between 0.1 and 1 in increments of 0.1.
**2nd line** adds a new value to the armor.elements table called "hands"
See ***init.lua*** under **3d_armor>>shields** for a further example
@ -350,7 +358,41 @@ Durability is determined by the value assigned to the group ***armor_use***. The
All diamond armor items have an ***armor_use=200***;
65535/2000 = 327.6 (327)
After 327 uses(hits) the armor item will break.
After 327 uses(hits) the armor item will break.
### Armor Material
The material the armor is made from is defined by adding the material to the end of registered armor item name. It is very important the material is the last item in the registered item name and it is preceeded by an "_" eg "_materialname".
The material name is what 3d_armor uses to determine if a player is wearing a set of armor. To recieve the set bonus all items worn must be made of the same material.
So to get a set bonus under the default set settings the players armor items listed below must be made of the same material:
* head - Helmet
* torso - Chestplate
* legs - Leggings
* feet - Boots
* shield - Shields
If all of the above were made of material "wood" the player would recieve an ***armor_set_bonus*** of armor_level * 1.1, essentially +10%
**Example One**
armor:register_armor("3d_armor:helmet_bronze", {
description = S("Bronze Helmet"),
inventory_image = "3d_armor_inv_helmet_bronze.png",
groups = {armor_head=1, armor_heal=6, armor_use=400, physics_speed=-0.01, physics_gravity=0.01},
armor_groups = {fleshy=10},
damage_groups = {cracky=3, snappy=2, choppy=2, crumbly=1, level=2},
})
**Example Two**
armor:register_armor("new_mod:helmet_spartan_bronze", {
description = S("Spartan Helmet"),
inventory_image = "new_mod_inv_helmet_spartan_bronze.png",
groups = {armor_head=1, armor_heal=6, armor_use=350, physics_speed=-0.01, physics_gravity=0.01},
armor_groups = {fleshy=12},
damage_groups = {cracky=3, snappy=2, choppy=2, crumbly=1, level=2},
})
***Note: At the moment an armor item can only be made of one material***
## Armor Functions

View File

@ -95,6 +95,8 @@ armor.config = {
material_gold = true,
material_mithril = true,
material_crystal = true,
set_elements = "head torso legs feet shield",
set_multiplier = 1.1,
water_protect = true,
fire_protect = minetest.get_modpath("ethereal") ~= nil,
fire_protect_torch = minetest.get_modpath("ethereal") ~= nil,
@ -117,6 +119,14 @@ armor.register_armor = function(self, name, def)
end
return armor:equip(player, itemstack)
end
-- The below is a very basic check to try and see if a material name exists as part
-- of the item name. However this check is very simple and just checks theres "_something"
-- at the end of the item name and logging an error to debug if not.
local check_mat_exists = string.match(name, "%:.+_(.+)$")
if check_mat_exists == nil then
minetest.log("warning:[3d_armor] Registered armor "..name..
" does not have \"_material\" specified at the end of the item registration name")
end
minetest.register_tool(name, def)
end
@ -197,7 +207,6 @@ armor.set_player_armor = function(self, player)
end
local state = 0
local count = 0
local material = {count=1}
local preview = armor:get_preview(name)
local texture = "3d_armor_trans.png"
local physics = {}
@ -205,6 +214,9 @@ armor.set_player_armor = function(self, player)
local levels = {}
local groups = {}
local change = {}
local set_worn = {}
local armor_multi = 0
local worn_armor = armor:get_weared_armor_elements(player)
for _, phys in pairs(self.physics) do
physics[phys] = 1
end
@ -258,21 +270,38 @@ armor.set_player_armor = function(self, player)
local value = def.groups["armor_"..attr] or 0
attributes[attr] = attributes[attr] + value
end
local mat = string.match(item, "%:.+_(.+)$")
if material.name then
if material.name == mat then
material.count = material.count + 1
end
end
-- The following code compares player worn armor items against requirements
-- of which armor pieces are needed to be worn to meet set bonus requirements
for loc,item in pairs(worn_armor) do
local item_mat = string.match(item, "%:.+_(.+)$")
local worn_key = item_mat or "unknown"
-- Perform location checks to ensure the armor is worn correctly
for k,set_loc in pairs(armor.config.set_elements)do
if set_loc == loc then
if set_worn[worn_key] == nil then
set_worn[worn_key] = 0
set_worn[worn_key] = set_worn[worn_key] + 1
else
set_worn[worn_key] = set_worn[worn_key] + 1
end
else
material.name = mat
end
end
end
-- Apply the armor multiplier only if the player is wearing a full set of armor
for mat_name,arm_piece_num in pairs(set_worn) do
if arm_piece_num == #armor.config.set_elements then
armor_multi = armor.config.set_multiplier
end
end
for group, level in pairs(levels) do
if level > 0 then
level = level * armor.config.level_multiplier
if material.name and material.count == #self.elements then
level = level * 1.1
if armor_multi ~= 0 then
level = level * armor.config.set_multiplier
end
end
local base = self.registered_groups[group]

View File

@ -48,6 +48,8 @@ for name, config in pairs(armor.config) do
local setting = minetest.settings:get("armor_"..name)
if type(config) == "number" then
setting = tonumber(setting)
elseif type(config) == "string" then
setting = tostring(setting)
elseif type(config) == "boolean" then
setting = minetest.settings:get_bool("armor_"..name)
end
@ -62,6 +64,10 @@ for material, _ in pairs(armor.materials) do
end
end
-- Convert set_elements to a Lua table splitting on blank spaces
local t_set_elements = armor.config.set_elements
armor.config.set_elements = string.split(t_set_elements, " ")
-- Remove torch damage if fire_protect_torch == false
if armor.config.fire_protect_torch == false and armor.config.fire_protect == true then
for k,v in pairs(armor.fire_nodes) do

View File

@ -1,4 +1,3 @@
[3d_armor]
armor_material_wood (Enable wood armor) bool true
@ -38,6 +37,12 @@ armor_level_multiplier (Armor effectiveness multiplier) float 1
# eg: armor_heal_multiplier = 0 will disable healing altogether.
armor_heal_multiplier (Armor healing multiplier) float 1
# Armor set item names, remove or add items to include them or remove them from whats considered an Armor set.
armor_set_elements (Armor set items) string head torso legs feet shield
# Bonus multiplier when wearing armor set, set to the same as armor_level_multiplier to disable
armor_set_multiplier (Armor Set Bonus multiplier) float 1.1
# Enable water protection (periodically restores breath when activated).
armor_water_protect (Enable water protection) bool true

View File

@ -1,3 +1,4 @@
default
serialize_lib
mesecons?
digtron?
digtron?

View File

@ -228,6 +228,8 @@ dofile(advtrains.modpath.."/lzb.lua")
--load/save
-- backup variables, used if someone should accidentally delete a sub-mod
-- As of version 4, only used once during migration from version 3 to 4
-- Since version 4, each of the mods stores a separate save file.
local MDS_interlocking, MDS_lines
@ -252,8 +254,12 @@ function advtrains.avt_load()
local version = advtrains.read_component("version")
local tbl
if version and version == 3 then
-- we are dealing with the new, split-up system
if version and version == 4 then
advtrains.load_version_4()
return
-- NOTE: From here, legacy loading code!
elseif version and version == 3 then
-- we are dealing with the split-up system
minetest.log("action", "[advtrains] loading savefiles version 3")
local il_save = {
tcbs = true,
@ -301,7 +307,7 @@ function advtrains.avt_load()
end
advtrains.wagons = tbl.wagon_save
advtrains.player_to_train_mapping = tbl.ptmap or {}
advtrains.ndb.load_data(tbl.ndb)
advtrains.ndb.load_data_pre_v4(tbl.ndb)
advtrains.atc.load_data(tbl.atc)
if advtrains.interlocking then
advtrains.interlocking.db.load(tbl.interlocking)
@ -358,6 +364,65 @@ function advtrains.avt_load()
else
minetest.log("error", " Failed to deserialize advtrains save data: Not a table!")
end
-- moved from advtrains.load()
atlatc.load_pre_v4()
-- end of legacy loading code
end
function advtrains.load_version_4()
minetest.log("action", "[advtrains] loading savefiles version 4 (serialize_lib)")
--== load core ==
local at_save = serialize_lib.load_atomic(advtrains.fpath.."_core.ls")
if at_save then
advtrains.trains = at_save.trains
--Save the train id into the train table to avoid having to pass id around
for id, train in pairs(advtrains.trains) do
train.id = id
end
advtrains.wagons = at_save.wagons
advtrains.player_to_train_mapping = at_save.ptmap or {}
advtrains.atc.load_data(at_save.atc)
--remove wagon_save entries that are not part of a train
local todel=advtrains.merge_tables(advtrains.wagon_save)
for tid, train in pairs(advtrains.trains) do
train.id = tid
for _, wid in ipairs(train.trainparts) do
todel[wid]=nil
end
end
for wid, _ in pairs(todel) do
atwarn("Removing unused wagon", wid, "from wagon_save table.")
advtrains.wagon_save[wid]=nil
end
end
--== load ndb
serialize_lib.load_atomic(advtrains.fpath.."_ndb4.ls", advtrains.ndb.load_callback)
--== load interlocking ==
if advtrains.interlocking then
local il_save = serialize_lib.load_atomic(advtrains.fpath.."_interlocking.ls")
if il_save then
advtrains.interlocking.db.load(il_save)
end
end
--== load lines ==
if advtrains.lines then
local ln_save = serialize_lib.load_atomic(advtrains.fpath.."_lines.ls")
if ln_save then
advtrains.lines.load(ln_save)
end
end
--== load luaatc ==
if atlatc then
local la_save = serialize_lib.load_atomic(advtrains.fpath.."_atlatc.ls")
if la_save then
atlatc.load(la_save)
end
end
end
advtrains.save_component = function (tbl, name)
@ -365,6 +430,7 @@ advtrains.save_component = function (tbl, name)
--
-- required for now to shrink the advtrains db to overcome lua
-- limitations.
-- Note: as of version 4, only used for the "advtrains_version" file
local datastr = minetest.serialize(tbl)
if not datastr then
minetest.log("error", " Failed to serialize advtrains save data!")
@ -380,7 +446,7 @@ advtrains.save_component = function (tbl, name)
end
advtrains.avt_save = function(remove_players_from_wagons)
--atprint("saving")
--atdebug("Saving advtrains files (version 4)")
if remove_players_from_wagons then
for w_id, data in pairs(advtrains.wagons) do
@ -425,50 +491,76 @@ advtrains.avt_save = function(remove_players_from_wagons)
--versions:
-- 1 - Initial new save format.
-- 2 - version as of tss branch 11-2018+
-- 3 - split-up savefile system by gabriel
-- 4 - serialize_lib
-- save of core advtrains
local at_save={
trains = tmp_trains,
wagons = advtrains.wagons,
ptmap = advtrains.player_to_train_mapping,
atc = advtrains.atc.save_data(),
}
--save of interlocking
local il_save
if advtrains.interlocking then
il_save = advtrains.interlocking.db.save()
else
il_save = MDS_interlocking
end
-- save of lines
local ln_save
if advtrains.lines then
ln_save = advtrains.lines.save()
else
ln_save = MDS_lines
end
local save_tbl={
trains = tmp_trains,
wagon_save = advtrains.wagons,
ptmap = advtrains.player_to_train_mapping,
atc = advtrains.atc.save_data(),
ndb = advtrains.ndb.save_data(),
lines = ln_save,
version = 3,
}
for i,k in pairs(save_tbl) do
advtrains.save_component(k,i)
-- save of luaatc
local la_save
if atlatc then
la_save = atlatc.save()
end
for i,k in pairs(il_save) do
advtrains.save_component(k,"interlocking_"..i)
end
-- parts table for serialize_lib API:
-- any table that is nil will not be included and thus not be overwritten
local parts_table = {
["core.ls"] = at_save,
["interlocking.ls"] = il_save,
["lines.ls"] = ln_save,
["atlatc.ls"] = la_save,
["ndb4.ls"] = true, -- data not used
}
local callbacks_table = {
["ndb4.ls"] = advtrains.ndb.save_callback
}
if DUMP_DEBUG_SAVE then
local file, err = io.open(advtrains.fpath.."_DUMP", "w")
if err then
return
end
file:write(dump(save_tbl))
file:write(dump(parts_table))
file:close()
end
--THE MAGIC HAPPENS HERE
local succ, err = serialize_lib.save_atomic_multiple(parts_table, advtrains.fpath.."_", callbacks_table)
if not succ then
atwarn("Saving failed: "..err)
else
-- store version
advtrains.save_component(4, "version")
end
end
--## MAIN LOOP ##--
--Calls all subsequent main tasks of both advtrains and atlatc
local init_load=false
local save_interval=20
local save_interval=60
local save_timer=save_interval
advtrains.mainloop_runcnt=0
@ -505,7 +597,7 @@ minetest.register_globalstep(function(dtime_mt)
advtrains_itm_mainloop(dtime)
end
if atlatc then
atlatc.mainloop_stepcode(dtime)
--atlatc.mainloop_stepcode(dtime)
atlatc.interrupt.mainloop(dtime)
end
if advtrains.lines then
@ -531,9 +623,9 @@ end)
-- first time called in main loop (after the init phase) because luaautomation has to initialize first.
function advtrains.load()
advtrains.avt_load() --loading advtrains. includes ndb at advtrains.ndb.load_data()
if atlatc then
atlatc.load() --includes interrupts
end
--if atlatc then
-- atlatc.load() --includes interrupts
--end == No longer loading here. Now part of avt_save() legacy loading.
if advtrains_itm_init then
advtrains_itm_init()
end

View File

@ -52,11 +52,14 @@ local function ndbset(x,y,z,v)
ndb_nodes[y][x][z]=v
end
-- load/save
local path=minetest.get_worldpath()..DIR_DELIM.."advtrains_ndb2"
--load
local path_pre_v4=minetest.get_worldpath()..DIR_DELIM.."advtrains_ndb2"
--load pre_v4 format
--nodeids get loaded by advtrains init.lua and passed here
function ndb.load_data(data)
function ndb.load_data_pre_v4(data)
atlog("nodedb: Loading pre v4 format")
ndb_nodeids = data and data.nodeids or {}
ndb_ver = data and data.ver or 0
if ndb_ver < 1 then
@ -68,10 +71,11 @@ function ndb.load_data(data)
end
end
end
local file, err = io.open(path, "rb")
local file, err = io.open(path_pre_v4, "rb")
if not file then
atwarn("Couldn't load the node database: ", err or "Unknown Error")
else
-- Note: code duplication because of weird coordinate order in ndb2 format (z,y,x)
local cnt=0
local hst_z=file:read(2)
local hst_y=file:read(2)
@ -88,58 +92,104 @@ function ndb.load_data(data)
hst_x=file:read(2)
cid=file:read(2)
end
atlog("nodedb: read", cnt, "nodes.")
atlog("nodedb (ndb2 format): read", cnt, "nodes.")
file:close()
end
ndb_ver = 1
end
local windows_compat = false
--save
function ndb.save_data()
local tmppath = path.."~"
local file, err
if windows_compat then
-- open ndb file directly
file, err = io.open(path, "wb")
else
-- open another file next to it, then replace atomically
file, err = io.open(tmppath, "wb")
-- the new ndb file format is backported from cellworld, and stores the cids also in the ndb file.
-- These functions have the form of a serialize_lib atomic load/save callback and are called from avt_save/avt_load.
function ndb.load_callback(file)
-- read version
local vers_byte = file:read(1)
local version = string.byte(vers_byte)
if version~=1 then
file:close()
error("Doesn't support v4 nodedb file of version "..version)
end
if not file then
atwarn("Couldn't save the node database: ", err or "Unknown Error")
else
for y, ny in pairs(ndb_nodes) do
for x, nx in pairs(ny) do
for z, cid in pairs(nx) do
file:write(int_to_bytes(z))
file:write(int_to_bytes(y))
file:write(int_to_bytes(x))
file:write(int_to_bytes(cid))
end
-- read cid mappings
local nstr_byte = file:read(2)
local nstr = bytes_to_int(nstr_byte)
for i = 1,nstr do
local stid_byte = file:read(2)
local stid = bytes_to_int(stid_byte)
local stna = file:read("*l")
--atdebug("content id:", stid, "->", stna)
ndb_nodeids[stid] = stna
end
atlog("[nodedb] read", nstr, "node content ids.")
-- read nodes
local cnt=0
local hst_x=file:read(2)
local hst_y=file:read(2)
local hst_z=file:read(2)
local cid=file:read(2)
local cidi
while hst_z and hst_y and hst_x and cid and #hst_z==2 and #hst_y==2 and #hst_x==2 and #cid==2 do
cidi = bytes_to_int(cid)
-- prevent file corruption already here
if not ndb_nodeids[u14b(cidi)] then
-- clear the ndb data, to reinitialize it
-- in strict loading mode, doesn't matter as starting will be interrupted anyway
ndb_nodeids = {}
ndb_nodes = {}
error("NDB file is corrupted (found entry with invalid cid)")
end
ndbset(bytes_to_int(hst_x), bytes_to_int(hst_y), bytes_to_int(hst_z), cidi)
cnt=cnt+1
hst_x=file:read(2)
hst_y=file:read(2)
hst_z=file:read(2)
cid=file:read(2)
end
atlog("[nodedb] read", cnt, "nodes.")
file:close()
end
--save
function ndb.save_callback(data, file)
--atdebug("storing ndb...")
-- write version
file:write(string.char(1))
-- how many cid entries
local cnt = 0
for _,_ in pairs(ndb_nodeids) do
cnt = cnt + 1
end
-- write cids
local nstr = 0
file:write(int_to_bytes(cnt))
for stid,stna in pairs(ndb_nodeids) do
file:write(int_to_bytes(stid))
file:write(stna)
file:write("\n")
nstr = nstr+1
end
--atdebug("saved cids count ", nstr)
-- write entries
local cnt = 0
for y, ny in pairs(ndb_nodes) do
for x, nx in pairs(ny) do
for z, cid in pairs(nx) do
file:write(int_to_bytes(x))
file:write(int_to_bytes(y))
file:write(int_to_bytes(z))
file:write(int_to_bytes(cid))
cnt=cnt+1
end
end
file:close()
end
if not windows_compat then
local success, msg = os.rename(tmppath, path)
--local success, msg = nil, "test"
-- for windows, this fails if the file already exists. Enable windows compatibility and directly write to path.
if not success then
atlog("Replacing the nodedb file atomically failed:",msg)
atlog("Switching to Windows mode (will directly overwrite the nodedb file from now on)")
windows_compat = true
os.remove(tmppath)
-- try again
ndb.save_data()
end
end
return {nodeids = ndb_nodeids, ver = ndb_ver}
--atdebug("saved nodes count ", cnt)
file:close()
end
--function to get node. track database is not helpful here.
function ndb.get_node_or_nil(pos)
-- FIX for bug found on linuxworks server:

View File

@ -431,7 +431,9 @@ end
function ildb.remove_tcb(pos)
local pts = advtrains.roundfloorpts(pos)
if not track_circuit_breaks[pts] then return end
if not track_circuit_breaks[pts] then
return true --FIX: not an error, because tcb is already removed
end
for connid=1,2 do
if not ildb.remove_from_interlocking({p=pos, s=connid}) then
return false

View File

@ -39,7 +39,21 @@ dofile(mp.."/chatcmds.lua")
local filename=minetest.get_worldpath().."/advtrains_luaautomation"
function atlatc.load()
function atlatc.load(tbl)
if tbl.version==1 then
for envname, data in pairs(tbl.envs) do
atlatc.envs[envname]=atlatc.env_load(envname, data)
end
atlatc.active.load(tbl.active)
atlatc.interrupt.load(tbl.interrupt)
atlatc.pcnaming.load(tbl.pcnaming)
end
-- run init code of all environments
atlatc.run_initcode()
end
function atlatc.load_pre_v4()
minetest.log("action", "[atlatc] Loading pre-v4 save file")
local file, err = io.open(filename, "r")
if not file then
minetest.log("warning", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error"))
@ -82,21 +96,10 @@ atlatc.save = function()
pcnaming = atlatc.pcnaming.save(),
}
local datastr = minetest.serialize(save_tbl)
if not datastr then
minetest.log("error", " Failed to save advtrains_luaautomation save data to file "..filename..": Can't serialize!")
return
end
local file, err = io.open(filename, "w")
if err then
minetest.log("error", " Failed to save advtrains_luaautomation save data to file "..filename..": "..(err or "Unknown Error"))
return
end
file:write(datastr)
file:close()
return save_tbl
end
--[[
-- globalstep for step code
local timer, step_int=0, 2
@ -107,3 +110,4 @@ function atlatc.mainloop_stepcode(dtime)
atlatc.run_stepcode()
end
end
]]

View File

@ -0,0 +1,215 @@
-- atomic.lua
-- Utilities for transaction-like handling of serialized state files
-- Also for multiple files that must be synchronous, as advtrains currently requires.
-- Managing files and backups
-- ==========================
--[[
The plain scheme just overwrites the file in place. This however poses problems when we are interrupted right within
the write, so we have incomplete data. So, the following scheme is applied:
Unix:
1. writes to <filename>.new
2. moves <filename>.new to <filename>, clobbering previous file
Windows:
1. writes to <filename>.new
2. delete <filename>
3. moves <filename>.new to <filename>
We count a new version of the state as "committed" after stage 2.
During loading, we apply the following order of precedence:
1. <filename>
2. <filename>.new (windows only, in case we were interrupted just before 3. when saving)
All of these functions return either true on success or nil, error on error.
]]--
local ser = serialize_lib.serialize
local windows_mode = false
-- == local functions ==
local function save_atomic_move_file(filename)
--2. if windows mode, delete main file
if windows_mode then
local delsucc, err = os.remove(filename)
if not delsucc then
serialize_lib.log_error("Unable to delete old savefile '"..filename.."':")
serialize_lib.log_error(err)
return nil, err
end
end
--3. move file
local mvsucc, err = os.rename(filename..".new", filename)
if not mvsucc then
if minetest.settings:get_bool("serialize_lib_no_auto_windows_mode") or windows_mode then
serialize_lib.log_error("Unable to move '"..filename.."':")
serialize_lib.log_error(err)
return nil, err
else
-- enable windows mode and try again
serialize_lib.log_info("Enabling Windows mode for atomic saving...")
windows_mode = true
return save_atomic_move_file(filename)
end
end
return true
end
local function open_file_and_save_callback(callback, filename)
local file, err = io.open(filename, "w")
if not file then
error("Failed opening file '"..filename.."' for write:\n"..err)
end
callback(file)
return true
end
local function open_file_and_load_callback(filename, callback)
local file, err = io.open(filename, "r")
if not file then
error("Failed opening file '"..filename.."' for read:\n"..err)
end
return callback(file)
end
-- == public functions ==
-- Load a saved state (according to comment above)
-- if 'callback' is nil: reads serialized table.
-- returns the read table, or nil,err on error
-- if 'callback' is a function (signature func(file_handle) ):
-- Counterpart to save_atomic with function argument. Opens the file and calls callback on it.
-- If the callback function throws an error, and strict loading is enabled, that error is propagated.
-- The callback's first return value is returned by load_atomic
function serialize_lib.load_atomic(filename, callback)
local cbfunc = callback or ser.read_from_fd
-- try <filename>
local file, ret = io.open(filename, "r")
if file then
-- read the file using the callback
local success
success, ret = pcall(cbfunc, file)
if success then
return ret
end
end
if minetest.settings:get_bool("serialize_lib_strict_loading") then
serialize_lib.save_lock = true
error("Loading data from file '"..filename.."' failed:\n"
..ret.."\nDisable Strict Loading to ignore.")
end
serialize_lib.log_warn("Loading data from file '"..filename.."' failed, trying .new fallback:")
serialize_lib.log_warn(ret)
-- try <filename>.new
file, ret = io.open(filename..".new", "r")
if file then
-- read the file using the callback
local success
success, ret = pcall(cbfunc, file)
if success then
return ret
end
end
serialize_lib.log_error("Unable to load data from '"..filename..".new':")
serialize_lib.log_error(ret)
serialize_lib.log_error("Note: This message is normal when the mod is loaded the first time on this world.")
return nil, ret
end
-- Save a file atomically (as described above)
-- 'data' is the data to be saved (when a callback is used, this can be nil)
-- if 'callback' is nil:
-- data must be a table, and is serialized into the file
-- if 'callback' is a function (signature func(data, file_handle) ):
-- Opens the file and calls callback on it. The 'data' argument is the data passed to save_atomic().
-- If the callback function throws an error, and strict loading is enabled, that error is propagated.
-- The callback's first return value is returned by load_atomic
-- Important: the callback must close the file in all cases!
function serialize_lib.save_atomic(data, filename, callback, config)
if serialize_lib.save_lock then
serialize_lib.log_warn("Instructed to save '"..filename.."', but save lock is active!")
return nil
end
local cbfunc = callback or ser.write_to_fd
local file, ret = io.open(filename..".new", "w")
if file then
-- save the file using the callback
local success
success, ret = pcall(cbfunc, data, file)
if success then
return save_atomic_move_file(filename)
end
end
serialize_lib.log_error("Unable to save data to '"..filename..".new':")
serialize_lib.log_error(ret)
return nil, ret
end
-- Saves multiple files synchronously. First writes all data to all <filename>.new files,
-- then moves all files in quick succession to avoid inconsistent backups.
-- parts_table is a table where the keys are used as part of the filename and the values
-- are the respective data written to it.
-- e.g. if parts_table={foo={...}, bar={...}}, then <filename_prefix>foo and <filename_prefix>bar are written out.
-- if 'callbacks_table' is defined, it is consulted for callbacks the same way save_atomic does.
-- example: if callbacks_table = {foo = func()...}, then the callback is used during writing of file 'foo' (but not for 'bar')
-- Note however that you must at least insert a "true" in the parts_table if you don't use the data argument.
-- Important: the callback must close the file in all cases!
function serialize_lib.save_atomic_multiple(parts_table, filename_prefix, callbacks_table, config)
if serialize_lib.save_lock then
serialize_lib.log_warn("Instructed to save '"..filename_prefix.."' (multiple), but save lock is active!")
return nil
end
for subfile, data in pairs(parts_table) do
local filename = filename_prefix..subfile
local cbfunc = ser.write_to_fd
if callbacks_table and callbacks_table[subfile] then
cbfunc = callbacks_table[subfile]
end
local success = false
local file, ret = io.open(filename..".new", "w")
if file then
-- save the file using the callback
success, ret = pcall(cbfunc, data, file, config)
end
if not success then
serialize_lib.log_error("Unable to save data to '"..filename..".new':")
serialize_lib.log_error(ret)
return nil, ret
end
end
local first_error
for file, _ in pairs(parts_table) do
local filename = filename_prefix..file
local succ, err = save_atomic_move_file(filename)
if not succ and not first_error then
first_error = err
end
end
return not first_error, first_error -- either true,nil or nil,error
end

View File

@ -0,0 +1,74 @@
-- serialize_lib
--[[
Copyright (C) 2020 Moritz Blei (orwell96) and contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
]]--
serialize_lib = {}
--[[ Configuration table
Whenever asked for a "config", the following table structure is expected:
config = {
skip_empty_tables = false -- if true, does not store empty tables
-- On next read, keys that mapped to empty tables resolve to nil
-- Used by: write_table_to_file
}
Not all functions use all of the parameters, so you can simplify your config sometimes
]]
-- log utils
-- =========
function serialize_lib.log_error(text)
minetest.log("error", "[serialize_lib] ("..(minetest.get_current_modname() or "?").."): "..(text or "<nil>"))
end
function serialize_lib.log_warn(text)
minetest.log("warning", "[serialize_lib] ("..(minetest.get_current_modname() or "?").."): "..(text or "<nil>"))
end
function serialize_lib.log_info(text)
minetest.log("action", "[serialize_lib] ("..(minetest.get_current_modname() or "?").."): "..(text or "<nil>"))
end
function serialize_lib.log_debug(text)
minetest.log("action", "[serialize_lib] ("..(minetest.get_current_modname() or "?")..") DEBUG: "..(text or "<nil>"))
end
-- basic serialization/deserialization
-- ===================================
local mp = minetest.get_modpath(minetest.get_current_modname())
serialize_lib.serialize = dofile(mp.."/serialize.lua")
dofile(mp.."/atomic.lua")
local ser = serialize_lib.serialize
-- Opens the passed filename, and returns deserialized table
-- When an error occurs, logs an error and returns false
function serialize_lib.read_table_from_file(filename)
local succ, ret = pcall(ser.read_from_file, filename)
if not succ then
serialize_lib.log_error(ret)
end
return ret
end
-- Writes table into file
-- When an error occurs, logs an error and returns false
function serialize_lib.write_table_to_file(root_table, filename)
local succ, ret = pcall(ser.write_to_file, root_table, filename)
if not succ then
serialize_lib.log_error(ret)
end
return ret
end

View File

@ -0,0 +1 @@
name = serialize_lib

View File

@ -0,0 +1,7 @@
# serialize_lib
A Minetest mod library for safely storing large amounts of data in on-disk files.
Created out of the need to have a robust data store for advtrains.
The main purpose is to load and store large Lua table structures into files, without loading everything in memory and exhausting the function constant limit of LuaJIT.
Also contains various utilities to handle files on disk in a safe manner, retain multiple versions of the same file a.s.o.

View File

@ -0,0 +1,268 @@
-- serialize.lua
-- Lua-conformant library file that has no minetest dependencies
-- Contains the serialization and deserialization routines
--[[
Structure of entry:
[keytype][key]:[valuetype][val]
Types:
B - bool
-> 0=false, 1=true
S - string
-> see below
N - number
-> thing compatible with tonumber()
Table:
[keytype][key]:T
... content is nested in table until the matching
E
example:
LUA_SER v=1 {
Skey:Svalue key = "value",
N1:Seins [1] = "eins",
B1:T [true] = {
Sa:Sb a = "b",
Sc:B0 c = false,
E }
E }
String representations:
In strings the following characters are escaped by &
'&' -> '&&'
(line break) -> '&n'
(CR) -> '&r' --> required?
':' -> '&:'
All other characters are unchanged as they bear no special meaning.
]]
local write_table, literal_to_string, escape_chars, table_is_empty
function table_is_empty(t)
for _,_ in pairs(t) do
return false
end
return true
end
function write_table(t, file, config)
local ks, vs, writeit, istable
for key, value in pairs(t) do
ks = value_to_string(key, false)
writeit = true
istable = type(value)=="table"
if istable then
vs = "T"
if config and config.skip_empty_tables then
writeit = not table_is_empty(value)
end
else
vs = value_to_string(value, true)
end
if writeit then
file:write(ks..":"..vs.."\n")
if istable then
write_table(value, file, config)
file:write("E\n")
end
end
end
end
function value_to_string(t)
if type(t)=="table" then
file:close()
error("Can not serialize a table in the key position!")
elseif type(t)=="boolean" then
if t then
return "B1"
else
return "B0"
end
elseif type(t)=="number" then
return "N"..t
elseif type(t)=="string" then
return "S"..escape_chars(t)
else
--error("Can not serialize '"..type(t).."' type!")
return "S<function>"
end
return str
end
function escape_chars(str)
local rstr = string.gsub(str, "&", "&&")
rstr = string.gsub(rstr, ":", "&:")
rstr = string.gsub(rstr, "\n", "&n")
return rstr
end
------
local read_table, string_to_value, unescape_chars
function read_table(t, file)
local line, ks, vs, kv, vv, vt
while true do
line = file:read("*l")
if not line then
file:close()
error("Unexpected EOF or read error!")
end
if line=="E" then
-- done with this table
return
end
ks, vs = string.match(line, "^(.*[^&]):(.+)$")
if not ks or not vs then
file:close()
error("Unable to parse line: '"..line.."'!")
end
kv = string_to_value(ks)
vv, vt = string_to_value(vs, true)
if vt then
read_table(vv, file)
end
-- put read value in table
t[kv] = vv
end
end
-- returns: value, is_table
function string_to_value(str, table_allow)
local first = string.sub(str, 1,1)
local rest = string.sub(str, 2)
if first=="T" then
if table_allow then
return {}, true
else
file:close()
error("Table not allowed in key component!")
end
elseif first=="N" then
local num = tonumber(rest)
if num then
return num
else
file:close()
error("Unable to parse number: '"..rest.."'!")
end
elseif first=="B" then
if rest=="0" then
return false
elseif rest=="1" then
return true
else
file:close()
error("Unable to parse boolean: '"..rest.."'!")
end
elseif first=="S" then
return unescape_chars(rest)
else
file:close()
error("Unknown literal type '"..first.."' for literal '"..str.."'!")
end
end
function unescape_chars(str) --TODO
local rstr = string.gsub(str, "&:", ":")
rstr = string.gsub(rstr, "&n", "\n")
rstr = string.gsub(rstr, "&&", "&")
return rstr
end
------
--[[
config = {
skip_empty_tables = false -- if true, does not store empty tables
-- On next read, keys that mapped to empty tables resolve to nil
}
]]
-- Writes the passed table into the passed file descriptor, and closes the file
local function write_to_fd(root_table, file, config)
file:write("LUA_SER v=1\n")
write_table(root_table, file, config)
file:write("E\nEND_SER\n")
end
-- Reads the file contents from the passed file descriptor and returns the table on success
-- Throws errors when something is wrong. Closes the file.
-- config: see above
local function read_from_fd(file)
local first_line = file:read("*l")
if first_line ~= "LUA_SER v=1" then
file:close()
error("Expected header, got '"..first_line.."' instead!")
end
local t = {}
read_table(t, file)
local last_line = file:read("*l")
file:close()
if last_line ~= "END_SER" then
error("Missing END_SER, got '"..last_line.."' instead!")
end
return t
end
-- Opens the passed filename and serializes root_table into it
-- config: see above
function write_to_file(root_table, filename, config)
-- try opening the file
local file, err = io.open(filename, "w")
if not file then
error("Failed opening file '"..filename.."' for write:\n"..err)
end
write_to_fd(root_table, file, config)
return true
end
-- Opens the passed filename, and returns its deserialized contents
function read_from_file(filename)
-- try opening the file
local file, err = io.open(filename, "r")
if not file then
error("Failed opening file '"..filename.."' for read:\n"..err)
end
return read_from_fd(file)
end
--[[ simple unit test
local testtable = {
key = "value",
[1] = "eins",
[true] = {
a = "b",
c = false,
},
["es:cape1"] = "foo:bar",
["es&ca\npe2"] = "baz&bam\nbim",
["es&&ca&\npe3"] = "baz&&bam&\nbim",
["es&:cape4"] = "foo\n:bar"
}
local config = {}
--write_to_file(testtable, "test_out", config)
local t = read_from_file("test_out")
write_to_file(t, "test_out_2", config)
local t2 = read_from_file("test_out_2")
write_to_file(t2, "test_out_3", config)
-- test_out_2 and test_out_3 should be equal
--]]
return {
read_from_fd = read_from_fd,
write_to_fd = write_to_fd,
read_from_file = read_from_file,
write_to_file = write_to_file,
}

View File

@ -0,0 +1,12 @@
# Enable strict file loading mode
# If enabled, if any error occurs during loading of a file using the 'atomic' API,
# an error is thrown. You probably need to disable this option for initial loading after
# creating the world.
serialize_lib_strict_loading (Strict loading) bool false
# Do not automatically switch to "Windows mode" when saving atomically
# Normally, when renaming <filename>.new to <filename> fails, serialize_lib automatically
# switches to a mode where it deletes <filename> prior to moving. Enable this option to prevent
# this behavior and abort saving instead.
serialize_lib_no_auto_windows_mode (No automatic Windows Mode) bool false

View File

@ -0,0 +1,7 @@
# textdomain:bonemeal
[MOD] bonemeal loaded=[MOD] bonemeal geladen
Bone=Knochen
Bone Meal=Knochenmehl
Fertiliser=Dünger
Gelatin Powder=Gelatinepulver
Mulch=Mulch

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 KiB

After

Width:  |  Height:  |  Size: 1018 KiB

View File

@ -1,94 +1,94 @@
# textdomain:farming
#%s Hoe=
%s Hoe=%s Hacke
Apple Donut=Apfeldonut
#Apple Pie=
Apple Pie=Apfelkuchen
Baked Potato=Ofenkartoffel
#Baking Tray=
#Banana=
#Banana Leaves=
Baking Tray=Kuchenblech
Banana=Banane
Banana Leaves=Bananenblatt
Bar of Dark Chocolate=Tafel Zartbitterschokolade
Barley=Gerste
Barley Seed=Gerstenkörner
Bean Pole (place on soil before planting beans)=Bohnenstange (vor dem Pflanzen der Bohnen auf den\nAckerboden stellen)
#Beetroot=
#Beetroot Soup=
#Bibimbap=
Beetroot=Rote Beete
Beetroot Soup=Rote Beete Suppe
Bibimbap=Bibimbap
Wild Blueberries=Wilde Blaubeeren
Blueberry Muffin=Blaubeermuffin
#Blueberry Pie=
Blueberry Pie=Blaubeerkuchen
Bottle of Ethanol=Flasche Ethanol
Bottle of Hemp Oil=Flasche mit Hanföl
#Bowl of Chili=
Bowl of Chili=Chili Schale
Bread=Brot
Bronze Hoe=Bronzehacke
#Cabbage=
#Cactus Juice=
Cabbage=Salat
Cactus Juice=Kaktussaft
Carrot=Möhre
#Carrot Juice=
#Chili Pepper=
#Chocolate Block=
Carrot Juice=Möhrensaft
Chili Pepper=Chili
Chocolate Block=Schokoladenstück
Chocolate Donut=Schokodonut
Cocoa Beans=Kakaobohne
Coffee Beans=Kaffeebohnen
Cookie=Keks
#Cooking Pot=
Cooking Pot=Kochtopf
Corn=Mais
Corn on the Cob=Maiskolben
#Cornstarch=
Cornstarch=Speisestärke
Cotton=Baumwolle
Cotton Seed=Baumwollsamen
Cucumber=Gurke
#Cucumber and Potato Salad=
Cucumber and Potato Salad=Gurken und Tomatensalat
Cup of Coffee=Tasse Kaffee
#Cutting Board=
Cutting Board=Schneidebrett
Diamond Hoe=Diamanthacke
Donut=Donut
Flour=Mehl
#Garlic=
#Garlic Braid=
#Garlic Bread=
#Garlic clove=
#Glass Mixing Bowl=
Garlic=Knoblauch
Garlic Braid=Knoblauchzopf
Garlic Bread=Knoblauchbrot
Garlic clove=Knoblauchzehe
Glass Mixing Bowl=Glasschlüssel
Golden Carrot=Goldene Möhre
Grapes=Weintrauben
Green Beans=Grüne Bohnen
#Ground Pepper=
#Hemp Block=
Ground Pepper=Gemahlener Pfeffer
Hemp Block=Hanfblock
Hemp Fibre=Hanffaser
Hemp Leaf=Hanfblatt
Hemp Rope=Hanfseil
Hemp Seed=Hanfsamen
Hoe=Hacke
#Hoe Bomb (use or throw on grassy areas to hoe land)=
Hoe Bomb (use or throw on grassy areas to hoe land)=Hackbombe (Auf Grasland werfen oder benutzen)
Jack 'O Lantern (punch to turn on and off)=Kürbislaterne (Punch zum Ein- und Ausschalten)
#Jaffa Cake=
#Juicer=
Jaffa Cake=Jaffa-Torte
Juicer=Entsafter
Melon=Melone
Melon Slice=Melonenscheibe
Mese Hoe=Mesehacke
#Mint Leaf=
#Mint Seeds=
#Mint Tea=
#Mithril Scythe (Right-click to harvest and replant crops)=
#Mortar and Pestle=
#Multigrain Bread=
#Multigrain Flour=
#Oat seed=
#Oats=
#Onion=
#Onion Soup=
#Orange=
#Pasta=
#Pea Pod=
#Pea Soup=
#Peas=
#Pepper=
#Peppercorn=
#Pineapple=
#Pineapple Juice=
#Pineapple Ring=
#Pineapple Top=
#Porridge=
Mint Leaf=Minzblatt
Mint Seeds=Minzsamen
Mint Tea=Minztee
Mithril Scythe (Right-click to harvest and replant crops)=Mithril-Sense (Rechts-Klick zum Ernten und Wiedereinpflanzen)
Mortar and Pestle=Mörser und Stößel
Multigrain Bread=Mehrkornbrot
Multigrain Flour=Mehrkornmehl
Oat seed=Hafersamen
Oats=Hafer
Onion=Zwiebel
Onion Soup=Zwiebelsuppe
Orange=Apfelsine
Pasta=Pasta
Pea Pod=Erbsenschote
Pea Soup=Erbsensuppe
Peas=Erbsen
Pepper=Pfeffer
Peppercorn=Pfefferkorn
Pineapple=Ananas
Pineapple Juice=Ananassaft
Pineapple Ring=Ananasscheibe
Pineapple Top=Ananasdeckel
Porridge=Brei
Potato=Kartoffel
Pumpkin=Kürbis
Pumpkin Bread=Kürbisbrot
@ -98,37 +98,37 @@ Raspberries=Himbeeren
Raspberry Smoothie=Himbeersmoothie
Rhubarb=Rhabarber
Rhubarb Pie=Rhabarberkuchen
#Rice=
#Rice Bread=
#Rice Flour=
#Rice grains=
#Rose Water=
#Rye=
#Rye seed=
#Salt=
#Saucepan=
#Savanna Soil=
#Scarecrow Bottom=
Rice=Reis
Rice Bread=Reiswaffel
Rice Flour=Reismehl
Rice grains=Reissaat
Rose Water=Rosenwasser
Rye=Roggen
Rye seed=Roggensaat
Salt=Salz
Saucepan=Kasserolle
Savanna Soil=Savannaerde
Scarecrow Bottom=Vogelscheuchengestell
Seed=Saatgut
#Skillet=
#Sliced Bread=
Skillet=Bratpfanne
Sliced Bread=Geschnittenes Brot
Soil=Ackerboden
#Spaghetti=
Spaghetti=Spaghetti
Steel Hoe=Stahlhacke
Stone Hoe=Steinhacke
Straw=Stroh
#Strawberry=
#String=
Strawberry=Erdbeere
String=Faden
Sugar=Zucker
#Toast=
#Toast Sandwich=
Toast=Toast
Toast Sandwich=Toast Sandwich
Tomato=Tomate
Trellis (place on soil before planting grapes)=Spalier (vor dem Pflanzen der Weintrauben auf den\nAckerboden stellen)
#Turkish Delight=
#Wet Savanna Soil=
Turkish Delight=Lokum
Wet Savanna Soil=Feuchte Savannaerde
Wet Soil=Bewässerter Ackerboden
Wheat=Weizen
Wheat Seed=Weizenkörner
#Wild Cotton=
#Wooden Bowl=
Wild Cotton=Wilde Baumwolle
Wooden Bowl=Holzschale
Wooden Hoe=Holzhacke

View File

@ -188,11 +188,13 @@ minetest.register_craft({
type = "shapeless",
output = "mobs:bucket_milk",
recipe = {
"mobs:glass_milk", "mobs:glass_milk",
"mobs:glass_milk", "mobs:glass_milk",
"group:food_milk_glass", "group:food_milk_glass",
"group:food_milk_glass", "group:food_milk_glass",
"bucket:bucket_empty"
},
replacements = { {"mobs:glass_milk", "vessels:drinking_glass 4"} }
replacements = {
{"group:food_milk_glass", "vessels:drinking_glass 4"},
}
})

View File

@ -898,8 +898,26 @@ local color_button_size = ";0.75,0.75;"
local color_square_size = ";0.69,0.69;"
function unifieddyes.make_readable_color(color)
local s = string.gsub(color, "_", " ")
s = string.gsub(s, "s50", "(low saturation)")
-- is this a low saturation color?
local has_low_saturtation = string.find(color, "s50");
-- remove _s50 tag, we care about that later again
local s = string.gsub(color, "_s50", "")
-- replace underscores with spaces to make it look nicer
local s = string.gsub(s, "_", " ")
-- capitalize words, you know, looks nicer ;)
s = string.gsub(s, "(%l)(%w*)", function(a,b) return string.upper(a)..b end)
-- add the word dye, this is what the translations expect
s = s.." Dye"
-- if it is a low sat color, append an appropriate string
if has_low_saturtation then
s = s.." (low saturation)"
end
return s
end
@ -925,7 +943,7 @@ function unifieddyes.make_colored_square(hexcolor, colorname, showall, creative,
end
local tooltip = "tooltip["..colorname..";"..
unifieddyes.make_readable_color(colorname)..
S(unifieddyes.make_readable_color(colorname))..
"\n(dye:"..colorname..")]"
if dye == painting_with then
@ -1103,7 +1121,7 @@ function unifieddyes.show_airbrush_form(player)
t[#t+1] = "label[10.7,"
t[#t+1] = (vps*5.07+vs)
t[#t+1] = ";"
t[#t+1] = unifieddyes.make_readable_color(string.sub(painting_with, 5))
t[#t+1] = S(unifieddyes.make_readable_color(string.sub(painting_with, 5)))
t[#t+1] = "]label[10.7,"
t[#t+1] = (vps*5.24+vs)
t[#t+1] = ";("

View File

@ -74,3 +74,18 @@ Magenta Dye (low saturation)=Magenta Farbstoff (geringe Saettigung) lila
Red-violet Dye (low saturation)=Rotvioletter Farbstoff (geringe Saettigung)
[UnifiedDyes] Loaded!=[UnifiedDyes] geladen!
Dye Airbrush=Farbstroff Airbrush
Select a color:=Wähle eine Farbe
(Right-clicked a node that supports all 256 colors, showing them all)=(Angeklickter Block unterstützt alle 256 Farben, zeige alle)
(Right-clicked a node not supported by the Airbrush, showing all colors)=(Angeklickter Block unterstützt kein Airbrush, zeige alle Farben)
Dyes=Farbstoffe
Your selection=Deine Auswahl
Your selection:=Deine Auswahl:
Cancel=Abbrechen
Accept=Übernehmen
Show Available=Zeige verfügbare
(Currently showing all 256 colors)=(Zeige alle 256 Farben)
Show All Colors=Zeige alle Farben
(Currently only showing what the right-clicked node can use)=(Zeige alle, die der angeklickte Block verwenden kann)

View File

@ -1,7 +1,7 @@
# Credit where credit is due
Copyright (C) 2015-2016 blert2112 and contributors
Copyright (C) 2019-2021 Panquesito7 and contributors
Copyright (C) 2015-2016 blert2112 and contributors\
Copyright (C) 2019-2021 Panquesito7 (halfpacho@gmail.com) and contributors
- Black, Blue, Brown, Cyan, Dark Green, Dark Grey, Green, Grey, Magenta, Orange, Pink, Red, Violet, White, Yellow, Hot Rod, Nyan Ride, Oerkki Bliss, and Road Master from: "Car" by Esteban
- <https://forum.minetest.net/viewtopic.php?f=13&t=7407>

View File

@ -43,8 +43,8 @@ For further information or help, see:\
## License
Copyright (C) 2015-2016 blert2112 and contributors
Copyright (C) 2019-2021 Panquesito7 and contributors
Copyright (C) 2015-2016 blert2112 and contributors\
Copyright (C) 2019-2021 Panquesito7 (halfpacho@gmail.com) and contributors
All licenses of previous works, of course, apply. (see credits below)
As far as the work I did... It's really just a fork of a fork of a fork of a fork, tossed it all into a blender and spun it on puree for a bit. Baked it for a while and set it on the counter to cool. What I mean is, make what you will of it, it matters not to me.