develop #28
|
@ -23,4 +23,4 @@ mt_mg_name="v6"
|
||||||
mt_protector_hurt="8"
|
mt_protector_hurt="8"
|
||||||
mt_protector_flip="true"
|
mt_protector_flip="true"
|
||||||
mt_protector_pvp="false"
|
mt_protector_pvp="false"
|
||||||
|
mt_tubelib_machine_aging_value="600"
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
# [mod] Visible Player Armor [3d_armor]
|
# [mod] Visible Player Armor [3d_armor]
|
||||||
|
|
||||||
| | | | |
|
| | | | |
|
||||||
|--|--|--|--|
|
|--|--|--|--|
|
||||||
|-[Overview](#overview) |||-[API](#api)|
|
|-[Overview](#overview) |||-[API](#api)
|
||||||
|-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage)
|
|-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage)
|
||||||
|- - [disable_specific_materials](#to-disable-individual-armor-materials) |||- - [Armor Registration](#armor-registration)
|
|- - [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_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_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_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_update_time](#how-often-player-armor-items-are-updated) |||- - - [Attributes](#attributes)
|
||||||
|- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics)
|
|- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics)
|
||||||
|- - [armor_destroy](#destroy-armor-when-a-player-dies) |||- - - [Durability](#durability)
|
|- - [armor_destroy](#destroy-armor-when-a-player-dies) |||- - - [Durability](#durability)
|
||||||
|- - [armor_level_multiplier](#armor-level-multiplyer) |||- - [Armour Functions](#armour-functions)
|
|- - [armor_level_multiplier](#armor-level-multiplyer) |||- - - [Armor Material](#armor-material)
|
||||||
|- - [armor_heal_multiplier](#armor-healing-multiplyer) |||- - - [armor:set_player_armor](#armor-set_player_armor)
|
|- - [armor_heal_multiplier](#armor-healing-multiplyer) |||- - [Armour Functions](#armor-functions)
|
||||||
|- - [armor_water_protect](#enable-water-protection) |||- - - [armor:punch](#armor-punch)
|
|- - [armor_set_elements](#allows-the-customisation-of-armor-set) |||- - - [armor:set_player_armor](#armor-set_player_armor)
|
||||||
|- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:damage](#armor-damage)
|
|- - [armor_set_bonus](#armor-set-bonus-multiplier) |||- - - [armor:punch](#armor-punch)
|
||||||
|- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:remove_all](#armor-remove_all)
|
|- - [armor_water_protect](#enable-water-protection) |||- - - [armor:damage](#armor-damage)
|
||||||
|- - [armor_migrate_old_inventory](#migration-of-old-armor-inventories) |||- - - [armor:equip](#armor-equip)
|
|- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:remove_all](#armor-remove_all)
|
||||||
|- - [wieldview_update_time](#how-often-player-wield-items-are-updated) |||- - - [armor:unequip](#armor-unequip)
|
|- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:equip](#armor-equip)
|
||||||
| - [Credits](#credits) |||- - - [armor:update_skin](#armor-update_skin)
|
|- - [armor_migrate_old_inventory](#migration-of-old-armor-inventories) |||- - - [armor:unequip](#armor-unequip)
|
||||||
| |||- - [Callbacks](#Callbacks)
|
|- - [wieldview_update_time](#how-often-player-wield-items-are-updated) |||- - - [armor:update_skin](#armor-update_skin)
|
||||||
| |||- - - [Item callbacks](#item-callbacks)
|
|-[Credits](#credits) |||- - [Callbacks](#Callbacks)
|
||||||
| |||- - - [Global callbacks](#global-callbacks)
|
| |||- - - [Item callbacks](#item-callbacks)
|
||||||
|
| |||- - - [Global callbacks](#global-callbacks)
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ Overall level is boosted by 10% when wearing a full matching set.
|
||||||
|
|
||||||
# Armor Configuration
|
# 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
|
### To disable individual armor materials
|
||||||
**set the below to false**
|
**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.**
|
**eg: armor_heal_multiplier = 0 will disable healing altogether.**
|
||||||
|
|
||||||
armor_heal_multiplier = 1
|
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
|
### Enable water protection
|
||||||
**periodically restores breath when activated**
|
**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",
|
preview = "mod_name_leather_chestplate_preview.png",
|
||||||
groups = {armor_torso=1, armor_heal=0, armor_use=2000, flammable=1},
|
groups = {armor_torso=1, armor_heal=0, armor_use=2000, flammable=1},
|
||||||
armor_groups = {fleshy=10},
|
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*
|
*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
|
if minetest.global_exists("armor") and armor.elements then
|
||||||
table.insert(armor.elements, "hands")
|
table.insert(armor.elements, "hands")
|
||||||
local mult = armor.config.level_multiplier or 1
|
|
||||||
armor.config.level_multiplier = mult * 0.5
|
|
||||||
end
|
end
|
||||||
**1st line** not strictly needed but checks that the global table "armor" and subtable "elements" exists
|
**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"
|
**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.
|
|
||||||
|
|
||||||
See ***init.lua*** under **3d_armor>>shields** for a further example
|
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***;
|
All diamond armor items have an ***armor_use=200***;
|
||||||
|
|
||||||
65535/2000 = 327.6 (327)
|
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
|
## Armor Functions
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,8 @@ armor.config = {
|
||||||
material_gold = true,
|
material_gold = true,
|
||||||
material_mithril = true,
|
material_mithril = true,
|
||||||
material_crystal = true,
|
material_crystal = true,
|
||||||
|
set_elements = "head torso legs feet shield",
|
||||||
|
set_multiplier = 1.1,
|
||||||
water_protect = true,
|
water_protect = true,
|
||||||
fire_protect = minetest.get_modpath("ethereal") ~= nil,
|
fire_protect = minetest.get_modpath("ethereal") ~= nil,
|
||||||
fire_protect_torch = 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
|
end
|
||||||
return armor:equip(player, itemstack)
|
return armor:equip(player, itemstack)
|
||||||
end
|
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)
|
minetest.register_tool(name, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -197,7 +207,6 @@ armor.set_player_armor = function(self, player)
|
||||||
end
|
end
|
||||||
local state = 0
|
local state = 0
|
||||||
local count = 0
|
local count = 0
|
||||||
local material = {count=1}
|
|
||||||
local preview = armor:get_preview(name)
|
local preview = armor:get_preview(name)
|
||||||
local texture = "3d_armor_trans.png"
|
local texture = "3d_armor_trans.png"
|
||||||
local physics = {}
|
local physics = {}
|
||||||
|
@ -205,6 +214,9 @@ armor.set_player_armor = function(self, player)
|
||||||
local levels = {}
|
local levels = {}
|
||||||
local groups = {}
|
local groups = {}
|
||||||
local change = {}
|
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
|
for _, phys in pairs(self.physics) do
|
||||||
physics[phys] = 1
|
physics[phys] = 1
|
||||||
end
|
end
|
||||||
|
@ -258,21 +270,38 @@ armor.set_player_armor = function(self, player)
|
||||||
local value = def.groups["armor_"..attr] or 0
|
local value = def.groups["armor_"..attr] or 0
|
||||||
attributes[attr] = attributes[attr] + value
|
attributes[attr] = attributes[attr] + value
|
||||||
end
|
end
|
||||||
local mat = string.match(item, "%:.+_(.+)$")
|
end
|
||||||
if material.name then
|
end
|
||||||
if material.name == mat then
|
-- The following code compares player worn armor items against requirements
|
||||||
material.count = material.count + 1
|
-- 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
|
end
|
||||||
else
|
|
||||||
material.name = mat
|
|
||||||
end
|
end
|
||||||
end
|
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
|
for group, level in pairs(levels) do
|
||||||
if level > 0 then
|
if level > 0 then
|
||||||
level = level * armor.config.level_multiplier
|
level = level * armor.config.level_multiplier
|
||||||
if material.name and material.count == #self.elements then
|
if armor_multi ~= 0 then
|
||||||
level = level * 1.1
|
level = level * armor.config.set_multiplier
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local base = self.registered_groups[group]
|
local base = self.registered_groups[group]
|
||||||
|
|
|
@ -48,6 +48,8 @@ for name, config in pairs(armor.config) do
|
||||||
local setting = minetest.settings:get("armor_"..name)
|
local setting = minetest.settings:get("armor_"..name)
|
||||||
if type(config) == "number" then
|
if type(config) == "number" then
|
||||||
setting = tonumber(setting)
|
setting = tonumber(setting)
|
||||||
|
elseif type(config) == "string" then
|
||||||
|
setting = tostring(setting)
|
||||||
elseif type(config) == "boolean" then
|
elseif type(config) == "boolean" then
|
||||||
setting = minetest.settings:get_bool("armor_"..name)
|
setting = minetest.settings:get_bool("armor_"..name)
|
||||||
end
|
end
|
||||||
|
@ -62,6 +64,10 @@ for material, _ in pairs(armor.materials) do
|
||||||
end
|
end
|
||||||
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
|
-- Remove torch damage if fire_protect_torch == false
|
||||||
if armor.config.fire_protect_torch == false and armor.config.fire_protect == true then
|
if armor.config.fire_protect_torch == false and armor.config.fire_protect == true then
|
||||||
for k,v in pairs(armor.fire_nodes) do
|
for k,v in pairs(armor.fire_nodes) do
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
[3d_armor]
|
[3d_armor]
|
||||||
|
|
||||||
armor_material_wood (Enable wood armor) bool true
|
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.
|
# eg: armor_heal_multiplier = 0 will disable healing altogether.
|
||||||
armor_heal_multiplier (Armor healing multiplier) float 1
|
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).
|
# Enable water protection (periodically restores breath when activated).
|
||||||
armor_water_protect (Enable water protection) bool true
|
armor_water_protect (Enable water protection) bool true
|
||||||
|
|
||||||
|
|
|
@ -230,6 +230,32 @@ local matchptn={
|
||||||
train.door_open = tt[match]*arr
|
train.door_open = tt[match]*arr
|
||||||
return 2
|
return 2
|
||||||
end,
|
end,
|
||||||
|
["K"] = function(id, train)
|
||||||
|
if train.door_open == 0 then
|
||||||
|
atwarn(sid(id), attrans("ATC Kick command warning: Doors closed"))
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
if train.velocity > 0 then
|
||||||
|
atwarn(sid(id), attrans("ATC Kick command warning: Train moving"))
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
local tp = train.trainparts
|
||||||
|
for i=1,#tp do
|
||||||
|
local data = advtrains.wagons[tp[i]]
|
||||||
|
local obj = advtrains.wagon_objects[tp[i]]
|
||||||
|
if data and obj then
|
||||||
|
local ent = obj:get_luaentity()
|
||||||
|
if ent then
|
||||||
|
for seatno,seat in pairs(ent.seats) do
|
||||||
|
if data.seatp[seatno] and not ent:is_driver_stand(seat) then
|
||||||
|
ent:get_off(seatno)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 1
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
eval_conditional = function(command, arrow, speed)
|
eval_conditional = function(command, arrow, speed)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
default
|
default
|
||||||
|
serialize_lib
|
||||||
mesecons?
|
mesecons?
|
||||||
digtron?
|
digtron?
|
||||||
|
|
|
@ -228,6 +228,8 @@ dofile(advtrains.modpath.."/lzb.lua")
|
||||||
--load/save
|
--load/save
|
||||||
|
|
||||||
-- backup variables, used if someone should accidentally delete a sub-mod
|
-- 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
|
local MDS_interlocking, MDS_lines
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,8 +254,12 @@ function advtrains.avt_load()
|
||||||
|
|
||||||
local version = advtrains.read_component("version")
|
local version = advtrains.read_component("version")
|
||||||
local tbl
|
local tbl
|
||||||
if version and version == 3 then
|
if version and version == 4 then
|
||||||
-- we are dealing with the new, split-up system
|
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")
|
minetest.log("action", "[advtrains] loading savefiles version 3")
|
||||||
local il_save = {
|
local il_save = {
|
||||||
tcbs = true,
|
tcbs = true,
|
||||||
|
@ -301,7 +307,7 @@ function advtrains.avt_load()
|
||||||
end
|
end
|
||||||
advtrains.wagons = tbl.wagon_save
|
advtrains.wagons = tbl.wagon_save
|
||||||
advtrains.player_to_train_mapping = tbl.ptmap or {}
|
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)
|
advtrains.atc.load_data(tbl.atc)
|
||||||
if advtrains.interlocking then
|
if advtrains.interlocking then
|
||||||
advtrains.interlocking.db.load(tbl.interlocking)
|
advtrains.interlocking.db.load(tbl.interlocking)
|
||||||
|
@ -358,6 +364,65 @@ function advtrains.avt_load()
|
||||||
else
|
else
|
||||||
minetest.log("error", " Failed to deserialize advtrains save data: Not a table!")
|
minetest.log("error", " Failed to deserialize advtrains save data: Not a table!")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
advtrains.save_component = function (tbl, name)
|
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
|
-- required for now to shrink the advtrains db to overcome lua
|
||||||
-- limitations.
|
-- limitations.
|
||||||
|
-- Note: as of version 4, only used for the "advtrains_version" file
|
||||||
local datastr = minetest.serialize(tbl)
|
local datastr = minetest.serialize(tbl)
|
||||||
if not datastr then
|
if not datastr then
|
||||||
minetest.log("error", " Failed to serialize advtrains save data!")
|
minetest.log("error", " Failed to serialize advtrains save data!")
|
||||||
|
@ -380,7 +446,7 @@ advtrains.save_component = function (tbl, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
advtrains.avt_save = function(remove_players_from_wagons)
|
advtrains.avt_save = function(remove_players_from_wagons)
|
||||||
--atprint("saving")
|
--atdebug("Saving advtrains files (version 4)")
|
||||||
|
|
||||||
if remove_players_from_wagons then
|
if remove_players_from_wagons then
|
||||||
for w_id, data in pairs(advtrains.wagons) do
|
for w_id, data in pairs(advtrains.wagons) do
|
||||||
|
@ -425,50 +491,76 @@ advtrains.avt_save = function(remove_players_from_wagons)
|
||||||
--versions:
|
--versions:
|
||||||
-- 1 - Initial new save format.
|
-- 1 - Initial new save format.
|
||||||
-- 2 - version as of tss branch 11-2018+
|
-- 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
|
local il_save
|
||||||
if advtrains.interlocking then
|
if advtrains.interlocking then
|
||||||
il_save = advtrains.interlocking.db.save()
|
il_save = advtrains.interlocking.db.save()
|
||||||
else
|
else
|
||||||
il_save = MDS_interlocking
|
il_save = MDS_interlocking
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- save of lines
|
||||||
local ln_save
|
local ln_save
|
||||||
if advtrains.lines then
|
if advtrains.lines then
|
||||||
ln_save = advtrains.lines.save()
|
ln_save = advtrains.lines.save()
|
||||||
else
|
else
|
||||||
ln_save = MDS_lines
|
ln_save = MDS_lines
|
||||||
end
|
end
|
||||||
|
|
||||||
local save_tbl={
|
-- save of luaatc
|
||||||
trains = tmp_trains,
|
local la_save
|
||||||
wagon_save = advtrains.wagons,
|
if atlatc then
|
||||||
ptmap = advtrains.player_to_train_mapping,
|
la_save = atlatc.save()
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for i,k in pairs(il_save) do
|
-- parts table for serialize_lib API:
|
||||||
advtrains.save_component(k,"interlocking_"..i)
|
-- any table that is nil will not be included and thus not be overwritten
|
||||||
end
|
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
|
if DUMP_DEBUG_SAVE then
|
||||||
local file, err = io.open(advtrains.fpath.."_DUMP", "w")
|
local file, err = io.open(advtrains.fpath.."_DUMP", "w")
|
||||||
if err then
|
if err then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
file:write(dump(save_tbl))
|
file:write(dump(parts_table))
|
||||||
file:close()
|
file:close()
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
--## MAIN LOOP ##--
|
--## MAIN LOOP ##--
|
||||||
--Calls all subsequent main tasks of both advtrains and atlatc
|
--Calls all subsequent main tasks of both advtrains and atlatc
|
||||||
local init_load=false
|
local init_load=false
|
||||||
local save_interval=20
|
local save_interval=60
|
||||||
local save_timer=save_interval
|
local save_timer=save_interval
|
||||||
advtrains.mainloop_runcnt=0
|
advtrains.mainloop_runcnt=0
|
||||||
|
|
||||||
|
@ -505,7 +597,7 @@ minetest.register_globalstep(function(dtime_mt)
|
||||||
advtrains_itm_mainloop(dtime)
|
advtrains_itm_mainloop(dtime)
|
||||||
end
|
end
|
||||||
if atlatc then
|
if atlatc then
|
||||||
atlatc.mainloop_stepcode(dtime)
|
--atlatc.mainloop_stepcode(dtime)
|
||||||
atlatc.interrupt.mainloop(dtime)
|
atlatc.interrupt.mainloop(dtime)
|
||||||
end
|
end
|
||||||
if advtrains.lines then
|
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.
|
-- first time called in main loop (after the init phase) because luaautomation has to initialize first.
|
||||||
function advtrains.load()
|
function advtrains.load()
|
||||||
advtrains.avt_load() --loading advtrains. includes ndb at advtrains.ndb.load_data()
|
advtrains.avt_load() --loading advtrains. includes ndb at advtrains.ndb.load_data()
|
||||||
if atlatc then
|
--if atlatc then
|
||||||
atlatc.load() --includes interrupts
|
-- atlatc.load() --includes interrupts
|
||||||
end
|
--end == No longer loading here. Now part of avt_save() legacy loading.
|
||||||
if advtrains_itm_init then
|
if advtrains_itm_init then
|
||||||
advtrains_itm_init()
|
advtrains_itm_init()
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,11 +52,14 @@ local function ndbset(x,y,z,v)
|
||||||
ndb_nodes[y][x][z]=v
|
ndb_nodes[y][x][z]=v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- load/save
|
||||||
|
|
||||||
local path=minetest.get_worldpath()..DIR_DELIM.."advtrains_ndb2"
|
local path_pre_v4=minetest.get_worldpath()..DIR_DELIM.."advtrains_ndb2"
|
||||||
--load
|
--load pre_v4 format
|
||||||
--nodeids get loaded by advtrains init.lua and passed here
|
--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_nodeids = data and data.nodeids or {}
|
||||||
ndb_ver = data and data.ver or 0
|
ndb_ver = data and data.ver or 0
|
||||||
if ndb_ver < 1 then
|
if ndb_ver < 1 then
|
||||||
|
@ -68,10 +71,11 @@ function ndb.load_data(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local file, err = io.open(path, "rb")
|
local file, err = io.open(path_pre_v4, "rb")
|
||||||
if not file then
|
if not file then
|
||||||
atwarn("Couldn't load the node database: ", err or "Unknown Error")
|
atwarn("Couldn't load the node database: ", err or "Unknown Error")
|
||||||
else
|
else
|
||||||
|
-- Note: code duplication because of weird coordinate order in ndb2 format (z,y,x)
|
||||||
local cnt=0
|
local cnt=0
|
||||||
local hst_z=file:read(2)
|
local hst_z=file:read(2)
|
||||||
local hst_y=file:read(2)
|
local hst_y=file:read(2)
|
||||||
|
@ -88,58 +92,104 @@ function ndb.load_data(data)
|
||||||
hst_x=file:read(2)
|
hst_x=file:read(2)
|
||||||
cid=file:read(2)
|
cid=file:read(2)
|
||||||
end
|
end
|
||||||
atlog("nodedb: read", cnt, "nodes.")
|
atlog("nodedb (ndb2 format): read", cnt, "nodes.")
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
ndb_ver = 1
|
ndb_ver = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local windows_compat = false
|
-- the new ndb file format is backported from cellworld, and stores the cids also in the ndb file.
|
||||||
--save
|
-- These functions have the form of a serialize_lib atomic load/save callback and are called from avt_save/avt_load.
|
||||||
function ndb.save_data()
|
function ndb.load_callback(file)
|
||||||
local tmppath = path.."~"
|
-- read version
|
||||||
local file, err
|
local vers_byte = file:read(1)
|
||||||
if windows_compat then
|
local version = string.byte(vers_byte)
|
||||||
-- open ndb file directly
|
if version~=1 then
|
||||||
file, err = io.open(path, "wb")
|
file:close()
|
||||||
else
|
error("Doesn't support v4 nodedb file of version "..version)
|
||||||
-- open another file next to it, then replace atomically
|
|
||||||
file, err = io.open(tmppath, "wb")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not file then
|
-- read cid mappings
|
||||||
atwarn("Couldn't save the node database: ", err or "Unknown Error")
|
local nstr_byte = file:read(2)
|
||||||
else
|
local nstr = bytes_to_int(nstr_byte)
|
||||||
for y, ny in pairs(ndb_nodes) do
|
for i = 1,nstr do
|
||||||
for x, nx in pairs(ny) do
|
local stid_byte = file:read(2)
|
||||||
for z, cid in pairs(nx) do
|
local stid = bytes_to_int(stid_byte)
|
||||||
file:write(int_to_bytes(z))
|
local stna = file:read("*l")
|
||||||
file:write(int_to_bytes(y))
|
--atdebug("content id:", stid, "->", stna)
|
||||||
file:write(int_to_bytes(x))
|
ndb_nodeids[stid] = stna
|
||||||
file:write(int_to_bytes(cid))
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
file:close()
|
|
||||||
end
|
end
|
||||||
|
--atdebug("saved nodes count ", cnt)
|
||||||
if not windows_compat then
|
file:close()
|
||||||
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}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--function to get node. track database is not helpful here.
|
--function to get node. track database is not helpful here.
|
||||||
function ndb.get_node_or_nil(pos)
|
function ndb.get_node_or_nil(pos)
|
||||||
-- FIX for bug found on linuxworks server:
|
-- FIX for bug found on linuxworks server:
|
||||||
|
|
BIN
mods/advtrains/advtrains/textures/advtrains_hud_arrow.png
Normal file
After Width: | Height: | Size: 92 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_atc.png
Normal file
After Width: | Height: | Size: 714 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_b.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_bg.png
Normal file
After Width: | Height: | Size: 67 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_emg.png
Normal file
After Width: | Height: | Size: 718 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_forward.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_left_door.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_lzb.png
Normal file
After Width: | Height: | Size: 618 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_n.png
Normal file
After Width: | Height: | Size: 376 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_p.png
Normal file
After Width: | Height: | Size: 274 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_r.png
Normal file
After Width: | Height: | Size: 322 B |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_reverse.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_right_door.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
mods/advtrains/advtrains/textures/advtrains_hud_shunt.png
Normal file
After Width: | Height: | Size: 793 B |
|
@ -307,7 +307,7 @@ advtrains.ap.t_90plusx_crossing={
|
||||||
trackworker = "60r",
|
trackworker = "60r",
|
||||||
},
|
},
|
||||||
["60r"]={
|
["60r"]={
|
||||||
conns = { {c=0}, {c=8}, {c=7}, {c=13} },
|
conns = { {c=0}, {c=8}, {c=5}, {c=13} },
|
||||||
desc = "60/90 degree crossing (right)",
|
desc = "60/90 degree crossing (right)",
|
||||||
tpdouble = true,
|
tpdouble = true,
|
||||||
tpsingle = true,
|
tpsingle = true,
|
||||||
|
|
|
@ -9,7 +9,6 @@ advtrains.hhud[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local mletter={[1]="F", [-1]="R", [0]="N"}
|
local mletter={[1]="F", [-1]="R", [0]="N"}
|
||||||
local doorstr={[-1]="|<>| >|<", [0]=">|< >|<", [1]=">|< |<>|"}
|
|
||||||
|
|
||||||
function advtrains.on_control_change(pc, train, flip)
|
function advtrains.on_control_change(pc, train, flip)
|
||||||
local maxspeed = train.max_speed or 10
|
local maxspeed = train.max_speed or 10
|
||||||
|
@ -89,38 +88,55 @@ function advtrains.on_control_change(pc, train, flip)
|
||||||
end
|
end
|
||||||
function advtrains.update_driver_hud(pname, train, flip)
|
function advtrains.update_driver_hud(pname, train, flip)
|
||||||
local inside=train.text_inside or ""
|
local inside=train.text_inside or ""
|
||||||
advtrains.set_trainhud(pname, inside.."\n"..advtrains.hud_train_format(train, flip))
|
local ft, ht = advtrains.hud_train_format(train, flip)
|
||||||
|
advtrains.set_trainhud(pname, inside.."\n"..ft, ht)
|
||||||
end
|
end
|
||||||
function advtrains.clear_driver_hud(pname)
|
function advtrains.clear_driver_hud(pname)
|
||||||
advtrains.set_trainhud(pname, "")
|
advtrains.set_trainhud(pname, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function advtrains.set_trainhud(name, text)
|
function advtrains.set_trainhud(name, text, driver)
|
||||||
local hud = advtrains.hud[name]
|
local hud = advtrains.hud[name]
|
||||||
local player=minetest.get_player_by_name(name)
|
local player=minetest.get_player_by_name(name)
|
||||||
if not player then
|
if not player then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local driverhud = {
|
||||||
|
hud_elem_type = "image",
|
||||||
|
name = "ADVTRAINS_DRIVER",
|
||||||
|
position = {x=0.5, y=0.7},
|
||||||
|
offset = {x=0,y=5},
|
||||||
|
text = driver or "",
|
||||||
|
alignment = {x=0,y=1},
|
||||||
|
scale = {x=1,y=1},}
|
||||||
if not hud then
|
if not hud then
|
||||||
hud = {}
|
hud = {["driver"]={}}
|
||||||
advtrains.hud[name] = hud
|
advtrains.hud[name] = hud
|
||||||
hud.id = player:hud_add({
|
hud.id = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
name = "ADVTRAINS",
|
name = "ADVTRAINS",
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
position = {x=0.5, y=0.7},
|
position = {x=0.5, y=0.7},
|
||||||
offset = {x=0, y=0},
|
offset = {x=0, y=-5},
|
||||||
text = text,
|
text = text,
|
||||||
scale = {x=200, y=60},
|
scale = {x=200, y=60},
|
||||||
alignment = {x=0, y=0},
|
alignment = {x=0, y=-1},
|
||||||
})
|
})
|
||||||
hud.oldText=text
|
hud.oldText=text
|
||||||
return
|
hud.driver = player:hud_add(driverhud)
|
||||||
elseif hud.oldText ~= text then
|
else
|
||||||
player:hud_change(hud.id, "text", text)
|
if hud.oldText ~= text then
|
||||||
hud.oldText=text
|
player:hud_change(hud.id, "text", text)
|
||||||
|
hud.oldText=text
|
||||||
|
end
|
||||||
|
if hud.driver then
|
||||||
|
player:hud_change(hud.driver, "text", driver or "")
|
||||||
|
elseif driver then
|
||||||
|
hud.driver = player:hud_add(driverhud)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function advtrains.set_help_hud(name, text)
|
function advtrains.set_help_hud(name, text)
|
||||||
local hud = advtrains.hhud[name]
|
local hud = advtrains.hhud[name]
|
||||||
local player=minetest.get_player_by_name(name)
|
local player=minetest.get_player_by_name(name)
|
||||||
|
@ -160,67 +176,135 @@ Value Disp Control Meaning
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function advtrains.hud_train_format(train, flip)
|
function advtrains.hud_train_format(train, flip)
|
||||||
local fct=flip and -1 or 1
|
if not train then return "","" end
|
||||||
if not train then return "" end
|
local sformat = string.format -- this appears to be faster than (...):format
|
||||||
|
|
||||||
local max = train.max_speed or 10
|
local max = train.max_speed or 10
|
||||||
local res = train.speed_restriction or max
|
local res = train.speed_restriction
|
||||||
local vel = advtrains.abs_ceil(train.velocity)
|
local vel = advtrains.abs_ceil(train.velocity)
|
||||||
local vel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.velocity))
|
local vel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.velocity))
|
||||||
|
|
||||||
local levers = "B - o +"
|
local levers = {[0] = "emg","b","r","n","p"}
|
||||||
local tlev=train.lever
|
local lvrcolor = {[0] = "red", "orange", "orange", "cyan", "cyan"}
|
||||||
|
local tlev=train.lever or 1
|
||||||
if train.velocity==0 and not train.active_control then tlev=1 end
|
if train.velocity==0 and not train.active_control then tlev=1 end
|
||||||
if tlev == 0 then levers = ">BB< - o +" end
|
|
||||||
if tlev == 1 then levers = ">B< - o +" end
|
|
||||||
if tlev == 2 then levers = "B >-< o +" end
|
|
||||||
if tlev == 3 then levers = "B - >o< +" end
|
|
||||||
if tlev == 4 then levers = "B - o >+<" end
|
|
||||||
|
|
||||||
local topLine, firstLine
|
local st = {}
|
||||||
|
if train.debug then st = {train.debug} end
|
||||||
|
|
||||||
local secondLine
|
local ht = {"[combine:300x150:0,0=(advtrains_hud_bg.png^[resize\\:300x150)"}
|
||||||
|
ht[#ht+1] = "100,0=(advtrains_hud_" .. (flip and "reverse" or "forward") .. ".png^[resize\\:100x20^[makealpha\\:#000000)"
|
||||||
|
ht[#ht+1] = "200,0=(advtrains_hud_" .. (levers[tlev] or "bg") .. ".png^[resize\\:100x20^[multiply\\:" .. (lvrcolor[tlev] or "#000000") .. "^[makealpha\\:#000000)"
|
||||||
if train.tarvelocity or train.atc_command then
|
if train.tarvelocity or train.atc_command then
|
||||||
local b=" "
|
ht[#ht+1] = "100,20=(advtrains_hud_atc.png^[resize\\:100x20^[makealpha\\:#000000)"
|
||||||
local tvels=""
|
end
|
||||||
if train.tarvelocity then
|
if train.ctrl.lzb then
|
||||||
local tvel = advtrains.abs_ceil(train.tarvelocity)
|
ht[#ht+1] = "200,20=(advtrains_hud_lzb.png^[resize\\:100x20^[multiply\\:red^[makealpha\\:#000000)"
|
||||||
tvels = "|"..string.rep("+", tvel)..string.rep("_", max-tvel)
|
end
|
||||||
end
|
if train.is_shunt then
|
||||||
if train.atc_brake_target then
|
ht[#ht+1] = "100,40=(advtrains_hud_shunt.png^[resize\\:100x20^[makealpha\\:#000000)"
|
||||||
b="-B-"
|
end
|
||||||
end
|
if train.door_open == -1 then
|
||||||
local ad = ""
|
ht[#ht+1] = "100,60=(advtrains_hud_left_door.png^[resize\\:100x20^[makealpha\\:#000000)"
|
||||||
if train.atc_delay then
|
elseif train.door_open == 1 then
|
||||||
ad = " "..advtrains.abs_ceil(train.atc_delay).."s "
|
ht[#ht+1] = "200,60=(advtrains_hud_right_door.png^[resize\\:100x24^[makealpha\\:#000000)"
|
||||||
end
|
end
|
||||||
secondLine="ATC"..b..": "..tvels..ad..(train.atc_command or "")
|
-- speed indication(s)
|
||||||
else
|
local function sevenseg(digit, x, y, w, h, m)
|
||||||
secondLine = "Manual operation"
|
--[[
|
||||||
if train.ctrl.lzb then
|
-1-
|
||||||
secondLine = "-!- Safety override -!-"
|
2 3
|
||||||
|
-4-
|
||||||
|
5 6
|
||||||
|
-7-
|
||||||
|
]]
|
||||||
|
local segs = {
|
||||||
|
{h, 0, w, h},
|
||||||
|
{0, h, h, w},
|
||||||
|
{w+h, h, h, w},
|
||||||
|
{h, w+h, w, h},
|
||||||
|
{0, w+2*h, h, w},
|
||||||
|
{w+h, w+2*h, h, w},
|
||||||
|
{h, 2*(w+h), w, h}}
|
||||||
|
local trans = {
|
||||||
|
[0] = {true, true, true, false, true, true, true},
|
||||||
|
[1] = {false, false, true, false, false, true, false},
|
||||||
|
[2] = {true, false, true, true, true, false, true},
|
||||||
|
[3] = {true, false, true, true, false, true, true},
|
||||||
|
[4] = {false, true, true, true, false, true, false},
|
||||||
|
[5] = {true, true, false, true, false, true, true},
|
||||||
|
[6] = {true, true, false, true, true, true, true},
|
||||||
|
[7] = {true, false, true, false, false, true, false},
|
||||||
|
[8] = {true, true, true, true, true, true, true},
|
||||||
|
[9] = {true, true, true, true, false, true, true}}
|
||||||
|
local ent = trans[digit or 10]
|
||||||
|
if not ent then return end
|
||||||
|
for i = 1, 7, 1 do
|
||||||
|
if ent[i] then
|
||||||
|
local s = segs[i]
|
||||||
|
ht[#ht+1] = sformat("%d,%d=(advtrains_hud_bg.png^[resize\\:%dx%d^%s)",x+s[1], y+s[2], s[3], s[4], m)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local shtind = train.is_shunt and "S" or ">"
|
sevenseg(math.floor(vel/10), 5, 5, 20, 10, "[colorize\\:red\\:255")
|
||||||
|
sevenseg(vel%10, 55, 5, 20, 10, "[colorize\\:red\\:255")
|
||||||
topLine=" ["..mletter[fct].."] {"..levers.."} "..doorstr[(train.door_open or 0)].." "..(train.line and "L: "..train.line or "")
|
for i = 1, vel, 1 do
|
||||||
firstLine=attrans("Speed:").." |"..string.rep("+", vel)..string.rep("_", res-vel).."|"..string.rep("_", max-res)..shtind.." "..vel_kmh.." km/h"
|
ht[#ht+1] = sformat("%d,100=(advtrains_hud_bg.png^[resize\\:11x30^[colorize\\:white)", i*14-3)
|
||||||
if train.speed_restriction == 0 then
|
end
|
||||||
firstLine = "OVERRUN RED SIGNAL! Examine situation and reverse train to move again."
|
for i = max+1, 20, 1 do
|
||||||
|
ht[#ht+1] = sformat("%d,100=(advtrains_hud_bg.png^[resize\\:11x30^[colorize\\:darkslategray)", i*14-3)
|
||||||
|
end
|
||||||
|
if res and res > 0 then
|
||||||
|
ht[#ht+1] = sformat("%d,95=(advtrains_hud_bg.png^[resize\\:3x40^[colorize\\:red\\:255)", 8+res*14)
|
||||||
|
end
|
||||||
|
if train.tarvelocity then
|
||||||
|
ht[#ht+1] = sformat("%d,130=(advtrains_hud_arrow.png^[multiply\\:cyan^[transformFY^[makealpha\\:#000000)", 2+train.tarvelocity*14)
|
||||||
end
|
end
|
||||||
|
|
||||||
local lzb = train.lzb
|
local lzb = train.lzb
|
||||||
|
if lzb and lzb.oncoming then
|
||||||
local i = 1
|
local oc = lzb.oncoming
|
||||||
while i<=#lzb.oncoming do
|
for i = 1, #oc do
|
||||||
local k = lzb.oncoming[i]
|
local spd = oc[i].spd
|
||||||
secondLine = secondLine .. "\n".."LZB: speed limit ["..(k.spd or "E")..("] in %.1f m"):format(k.idx-train.index)
|
if not spd then
|
||||||
if k.spd == 0 then
|
ht[#ht+1] = "203,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:lime\\:255)"
|
||||||
|
elseif spd == 0 then
|
||||||
|
ht[#ht+1] = "283,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:red\\:255)"
|
||||||
|
elseif tonumber(spd) then
|
||||||
|
ht[#ht+1] = "243,43=(advtrains_hud_bg.png^[resize\\:14x14^[colorize\\:orange\\:255)"
|
||||||
|
ht[#ht+1] = sformat("%d,85=(advtrains_hud_arrow.png^[multiply\\:red^[makealpha\\:#000000)", 2+spd*14)
|
||||||
|
end
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
i=i+1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return (train.debug or "").."\n"..topLine.."\n"..firstLine.."\n"..secondLine
|
if res and res == 0 then
|
||||||
|
st[#st+1] = attrans("OVERRUN RED SIGNAL! Examine situation and reverse train to move again.")
|
||||||
|
end
|
||||||
|
|
||||||
|
if train.atc_command then
|
||||||
|
st[#st+1] = sformat("ATC: %s%s", train.atc_delay and advtrains.abs_ceil(train.atc_delay).."s " or "", train.atc_command or "")
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(st,"\n"), table.concat(ht,":")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local _, texture = advtrains.hud_train_format { -- dummy train object to demonstrate the train hud
|
||||||
|
max_speed = 15, speed_restriction = 15, velocity = 15, tarvelocity = 12,
|
||||||
|
active_control = true, lever = 3, ctrl = {lzb = true}, is_shunt = true,
|
||||||
|
door_open = 1, lzb = {oncoming = {{spd=6}}}
|
||||||
|
}
|
||||||
|
|
||||||
|
minetest.register_node("advtrains:hud_demo",{
|
||||||
|
description = "Train HUD demonstration",
|
||||||
|
tiles = {texture},
|
||||||
|
groups = {cracky = 3, not_in_creative_inventory = 1}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft {
|
||||||
|
output = "advtrains:hud_demo",
|
||||||
|
recipe = {
|
||||||
|
{"default:paper", "default:paper", "default:paper"},
|
||||||
|
{"default:paper", "advtrains:trackworker", "default:paper"},
|
||||||
|
{"default:paper", "default:paper", "default:paper"},
|
||||||
|
}
|
||||||
|
}
|
|
@ -269,6 +269,15 @@ function wagon:destroy()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function wagon:is_driver_stand(seat)
|
||||||
|
if self.seat_groups then
|
||||||
|
return (seat.driving_ctrl_access or self.seat_groups[seat.group].driving_ctrl_access)
|
||||||
|
else
|
||||||
|
return seat.driving_ctrl_access
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function wagon:on_step(dtime)
|
function wagon:on_step(dtime)
|
||||||
return advtrains.pcall(function()
|
return advtrains.pcall(function()
|
||||||
if not self:ensure_init() then return end
|
if not self:ensure_init() then return end
|
||||||
|
@ -301,11 +310,7 @@ function wagon:on_step(dtime)
|
||||||
local pname=data.seatp[seatno]
|
local pname=data.seatp[seatno]
|
||||||
local driver=pname and minetest.get_player_by_name(pname)
|
local driver=pname and minetest.get_player_by_name(pname)
|
||||||
local has_driverstand = pname and advtrains.check_driving_couple_protection(pname, data.owner, data.whitelist)
|
local has_driverstand = pname and advtrains.check_driving_couple_protection(pname, data.owner, data.whitelist)
|
||||||
if self.seat_groups then
|
has_driverstand = has_driverstand and self:is_driver_stand(seat)
|
||||||
has_driverstand = has_driverstand and (seat.driving_ctrl_access or self.seat_groups[seat.group].driving_ctrl_access)
|
|
||||||
else
|
|
||||||
has_driverstand = has_driverstand and (seat.driving_ctrl_access)
|
|
||||||
end
|
|
||||||
if has_driverstand and driver then
|
if has_driverstand and driver then
|
||||||
advtrains.update_driver_hud(driver:get_player_name(), self:train(), data.wagon_flipped)
|
advtrains.update_driver_hud(driver:get_player_name(), self:train(), data.wagon_flipped)
|
||||||
elseif driver then
|
elseif driver then
|
||||||
|
|
|
@ -431,7 +431,9 @@ end
|
||||||
|
|
||||||
function ildb.remove_tcb(pos)
|
function ildb.remove_tcb(pos)
|
||||||
local pts = advtrains.roundfloorpts(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
|
for connid=1,2 do
|
||||||
if not ildb.remove_from_interlocking({p=pos, s=connid}) then
|
if not ildb.remove_from_interlocking({p=pos, s=connid}) then
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -52,12 +52,12 @@ local function show_stoprailform(pos, player)
|
||||||
local form = "size[8,7]"
|
local form = "size[8,7]"
|
||||||
form = form.."field[0.5,0.5;7,1;stn;"..attrans("Station Code")..";"..minetest.formspec_escape(stdata.stn).."]"
|
form = form.."field[0.5,0.5;7,1;stn;"..attrans("Station Code")..";"..minetest.formspec_escape(stdata.stn).."]"
|
||||||
form = form.."field[0.5,1.5;7,1;stnname;"..attrans("Station Name")..";"..minetest.formspec_escape(stnname).."]"
|
form = form.."field[0.5,1.5;7,1;stnname;"..attrans("Station Name")..";"..minetest.formspec_escape(stnname).."]"
|
||||||
form = form.."field[0.5,2.5;2,1;ddelay;"..attrans("Door Delay")..";"..minetest.formspec_escape(stdata.ddelay).."]"
|
form = form.."field[0.5,2.5;1.5,1;ddelay;"..attrans("Door Delay")..";"..minetest.formspec_escape(stdata.ddelay).."]"
|
||||||
form = form.."field[3,2.5;3,1;speed;"..attrans("Departure Speed")..";"..minetest.formspec_escape(stdata.speed).."]"
|
form = form.."field[2,2.5;2,1;speed;"..attrans("Departure Speed")..";"..minetest.formspec_escape(stdata.speed).."]"
|
||||||
|
form = form.."checkbox[5,1.75;reverse;"..attrans("Reverse train")..";"..(stdata.reverse and "true" or "false").."]"
|
||||||
|
form = form.."checkbox[5,2.0;kick;"..attrans("Kick out passengers")..";"..(stdata.kick and "true" or "false").."]"
|
||||||
form = form.."label[0.5,3;Door side:]"
|
form = form.."label[0.5,3;Door side:]"
|
||||||
form = form.."dropdown[0.5,3;2;doors;Left,Right,Closed;"..door_dropdown[stdata.doors].."]"
|
form = form.."dropdown[0.5,3;2;doors;Left,Right,Closed;"..door_dropdown[stdata.doors].."]"
|
||||||
form = form.."dropdown[3,3;1.5;reverse;---,Reverse;"..(stdata.reverse and 2 or 1).."]"
|
|
||||||
|
|
||||||
form = form.."field[5,3.5;2,1;track;"..attrans("Track")..";"..minetest.formspec_escape(stdata.track).."]"
|
form = form.."field[5,3.5;2,1;track;"..attrans("Track")..";"..minetest.formspec_escape(stdata.track).."]"
|
||||||
form = form.."field[5,4.5;2,1;wait;"..attrans("Stop Time")..";"..stdata.wait.."]"
|
form = form.."field[5,4.5;2,1;wait;"..attrans("Stop Time")..";"..stdata.wait.."]"
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ local function show_stoprailform(pos, player)
|
||||||
|
|
||||||
minetest.show_formspec(pname, "at_lines_stop_"..pe, form)
|
minetest.show_formspec(pname, "at_lines_stop_"..pe, form)
|
||||||
end
|
end
|
||||||
|
local tmp_checkboxes = {}
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local pe = string.match(formname, "^at_lines_stop_(............)$")
|
local pe = string.match(formname, "^at_lines_stop_(............)$")
|
||||||
|
@ -79,6 +79,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
local stdata = advtrains.lines.stops[pe]
|
local stdata = advtrains.lines.stops[pe]
|
||||||
|
if not tmp_checkboxes[pe] then
|
||||||
|
tmp_checkboxes[pe] = {}
|
||||||
|
end
|
||||||
|
if fields.kick then -- handle checkboxes due to MT's weird handling
|
||||||
|
tmp_checkboxes[pe].kick = (fields.kick == "true")
|
||||||
|
end
|
||||||
|
if fields.reverse then
|
||||||
|
tmp_checkboxes[pe].reverse = (fields.reverse == "true")
|
||||||
|
end
|
||||||
if fields.save then
|
if fields.save then
|
||||||
if fields.stn and stdata.stn ~= fields.stn then
|
if fields.stn and stdata.stn ~= fields.stn then
|
||||||
if fields.stn ~= "" then
|
if fields.stn ~= "" then
|
||||||
|
@ -111,10 +120,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.doors then
|
if fields.doors then
|
||||||
stdata.doors = door_dropdown_rev[fields.doors] or "C"
|
stdata.doors = door_dropdown_rev[fields.doors] or "C"
|
||||||
end
|
end
|
||||||
if fields.reverse then
|
|
||||||
stdata.reverse = fields.reverse == "Reverse"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if fields.track then
|
if fields.track then
|
||||||
stdata.track = fields.track
|
stdata.track = fields.track
|
||||||
|
@ -133,7 +138,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.speed then
|
if fields.speed then
|
||||||
stdata.speed = to_int(fields.speed) or "M"
|
stdata.speed = to_int(fields.speed) or "M"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for k,v in pairs(tmp_checkboxes[pe]) do --handle checkboxes
|
||||||
|
stdata[k] = v or nil
|
||||||
|
end
|
||||||
|
tmp_checkboxes[pe] = nil
|
||||||
--TODO: signal
|
--TODO: signal
|
||||||
updatemeta(pos)
|
updatemeta(pos)
|
||||||
show_stoprailform(pos, player)
|
show_stoprailform(pos, player)
|
||||||
|
@ -192,7 +201,7 @@ local adefunc = function(def, preset, suffix, rotation)
|
||||||
local stnname = stn and stn.name or "Unknown Station"
|
local stnname = stn and stn.name or "Unknown Station"
|
||||||
|
|
||||||
-- Send ATC command and set text
|
-- Send ATC command and set text
|
||||||
advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors.." D"..stdata.wait.." OC "..(stdata.reverse and "R" or "").."D"..(stdata.ddelay or 1) .. "S" ..(stdata.speed or "M"), true)
|
advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.kick and "K" or "").." D"..stdata.wait.." OC "..(stdata.reverse and "R" or "").."D"..(stdata.ddelay or 1) .. "S" ..(stdata.speed or "M"), true)
|
||||||
train.text_inside = stnname
|
train.text_inside = stnname
|
||||||
if tonumber(stdata.wait) then
|
if tonumber(stdata.wait) then
|
||||||
minetest.after(tonumber(stdata.wait), function() train.text_inside = "" end)
|
minetest.after(tonumber(stdata.wait), function() train.text_inside = "" end)
|
||||||
|
@ -215,4 +224,4 @@ if minetest.get_modpath("advtrains_train_track") ~= nil then
|
||||||
formats={},
|
formats={},
|
||||||
get_additional_definiton = adefunc,
|
get_additional_definiton = adefunc,
|
||||||
}, advtrains.trackpresets.t_30deg_straightonly)
|
}, advtrains.trackpresets.t_30deg_straightonly)
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,21 @@ dofile(mp.."/chatcmds.lua")
|
||||||
|
|
||||||
local filename=minetest.get_worldpath().."/advtrains_luaautomation"
|
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")
|
local file, err = io.open(filename, "r")
|
||||||
if not file then
|
if not file then
|
||||||
minetest.log("warning", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error"))
|
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(),
|
pcnaming = atlatc.pcnaming.save(),
|
||||||
}
|
}
|
||||||
|
|
||||||
local datastr = minetest.serialize(save_tbl)
|
return 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()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
-- globalstep for step code
|
-- globalstep for step code
|
||||||
local timer, step_int=0, 2
|
local timer, step_int=0, 2
|
||||||
|
|
||||||
|
@ -107,3 +110,4 @@ function atlatc.mainloop_stepcode(dtime)
|
||||||
atlatc.run_stepcode()
|
atlatc.run_stepcode()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
|
@ -46,6 +46,11 @@ Example:
|
||||||
B0 W OL D10 OC D1 SM
|
B0 W OL D10 OC D1 SM
|
||||||
Subway train: stop in station and open doors, depart after 10 seconds.
|
Subway train: stop in station and open doors, depart after 10 seconds.
|
||||||
|
|
||||||
|
K
|
||||||
|
Kick all passengers out of the trains
|
||||||
|
This command kicks all passengers (non-driving players) off the train. This command works only
|
||||||
|
if the train is stopped and its doors are open.
|
||||||
|
|
||||||
# conditional statements:
|
# conditional statements:
|
||||||
|
|
||||||
I<condition><code>;
|
I<condition><code>;
|
||||||
|
|
215
mods/advtrains/serialize_lib/atomic.lua
Normal 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
|
||||||
|
|
||||||
|
|
74
mods/advtrains/serialize_lib/init.lua
Normal 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
|
||||||
|
|
||||||
|
|
1
mods/advtrains/serialize_lib/mod.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
name = serialize_lib
|
7
mods/advtrains/serialize_lib/readme.md
Normal 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.
|
268
mods/advtrains/serialize_lib/serialize.lua
Normal 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,
|
||||||
|
}
|
12
mods/advtrains/serialize_lib/settingtypes.txt
Normal 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
|
||||||
|
|
7
mods/bonemeal/locale/bonemeal.de.tr
Normal 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
|
Before Width: | Height: | Size: 862 KiB After Width: | Height: | Size: 1,018 KiB |
|
@ -54,10 +54,7 @@ minetest.register_node("christmas:eggnog", {
|
||||||
})
|
})
|
||||||
minetest.register_node("christmas:present", {
|
minetest.register_node("christmas:present", {
|
||||||
description = "Christmas present",
|
description = "Christmas present",
|
||||||
tiles = {
|
tiles = {"christmas_present.png"},
|
||||||
"christmas_present.png",
|
|
||||||
"christmas_present_top.png"
|
|
||||||
},
|
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
mesh = "christmas_present.obj",
|
mesh = "christmas_present.obj",
|
||||||
|
|
|
@ -33,6 +33,7 @@ minetest.register_node("claycrafter:glass_of_water", {
|
||||||
inventory_image = "claycrafter_glass_of_water_inv.png",
|
inventory_image = "claycrafter_glass_of_water_inv.png",
|
||||||
wield_image = "claycrafter_glass_of_water.png",
|
wield_image = "claycrafter_glass_of_water.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
use_texture_alpha = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# License for textures/media
|
# License for textures/media
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Panquesito7, David Leal (halfpacho@gmail.com)\
|
Copyright (C) 2019-2021 Panquesito7, David Leal (halfpacho@gmail.com)\
|
||||||
Copyright (C) Various other Minetest developers/contributors
|
Copyright (C) Various other Minetest developers/contributors
|
||||||
|
|
||||||
[David Leal](https://github.com/Panquesito7) ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)):
|
[David Leal](https://github.com/Panquesito7) ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)):
|
||||||
|
@ -42,7 +42,7 @@ Copyright (C) [davidthecreator](https://forum.minetest.net/memberlist.php?mode=v
|
||||||
|
|
||||||
## License for source code
|
## License for source code
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Panquesito7, David Leal (halfpacho@gmail.com)\
|
Copyright (C) 2019-2021 Panquesito7, David Leal (halfpacho@gmail.com)\
|
||||||
Copyright (C) Various other Minetest developers/contributors
|
Copyright (C) Various other Minetest developers/contributors
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
|
|
@ -119,7 +119,7 @@ It shall work with MT 5.0.0 and above, though.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Panquesito7, David Leal\
|
Copyright (C) 2019-2021 Panquesito7, David Leal\
|
||||||
Copyright (C) Various other Minetest developers/contributors
|
Copyright (C) Various other Minetest developers/contributors
|
||||||
|
|
||||||
See [`LICENSE.md`](https://github.com/minetest-mods/cloud_items/blob/master/LICENSE.md) for more information.
|
See [`LICENSE.md`](https://github.com/minetest-mods/cloud_items/blob/master/LICENSE.md) for more information.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
--[[
|
--[[
|
||||||
Adds powerful cloud tools for Minetest.
|
Adds powerful cloud tools for Minetest.
|
||||||
|
|
||||||
Copyright (C) 2019-2020 David Leal (halfpacho@gmail.com)
|
Copyright (C) 2019-2021 David Leal (halfpacho@gmail.com)
|
||||||
Copyright (C) Various other Minetest developers/contributors
|
Copyright (C) Various other Minetest developers/contributors
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
|
@ -21,7 +21,7 @@ USA
|
||||||
|
|
||||||
==========================================================================
|
==========================================================================
|
||||||
|
|
||||||
Dependencies: WorldEdit, default (included in Minetest Game)
|
Dependencies: WorldEdit, Vehicle Mash, default (included in Minetest Game)
|
||||||
Optional dependencies: 3D Armor, Tool Ranks, More Blocks, multitools, stairs (included in Minetest Game)
|
Optional dependencies: 3D Armor, Tool Ranks, More Blocks, multitools, stairs (included in Minetest Game)
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
@ -531,7 +531,10 @@ local ship_def = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Cloud ship (based on the Vehicle Mash boat)
|
-- Cloud ship (based on the Vehicle Mash boat)
|
||||||
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/ship.lua")(table.copy(ship_def))
|
local boat_enabled = minetest.settings:get_bool("cloud_items.enable_cloud_car")
|
||||||
|
if boat_enabled or boat_enabled == nil then
|
||||||
|
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/ship.lua")(table.copy(ship_def))
|
||||||
|
end
|
||||||
|
|
||||||
----------------
|
----------------
|
||||||
-- Cloud car --
|
-- Cloud car --
|
||||||
|
@ -573,7 +576,10 @@ local car_def = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Cloud car (similar from the CAR01 from Vehicle Mash)
|
-- Cloud car (similar from the CAR01 from Vehicle Mash)
|
||||||
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/car.lua")(table.copy(car_def))
|
local car_enabled = minetest.settings:get_bool("cloud_items.enable_cloud_ship")
|
||||||
|
if car_enabled or car_enabled == nil then
|
||||||
|
loadfile(minetest.get_modpath(minetest.get_current_modname()) .. "/car.lua")(table.copy(car_def))
|
||||||
|
end
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
-- Crafts --
|
-- Crafts --
|
||||||
|
|
4
mods/cloud_items/settingtypes.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Vehicle settings
|
||||||
|
|
||||||
|
cloud_items.enable_cloud_car (Enable/disable cloud car) bool true
|
||||||
|
cloud_items.enable_cloud_ship (Enable/disable cloud ship) bool true
|
|
@ -481,7 +481,7 @@ if minetest.get_modpath("moreores") then
|
||||||
{"", "", "group:stick"}
|
{"", "", "group:stick"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
--[[
|
||||||
farming.register_hoe(":moreores:hoe_silver", {
|
farming.register_hoe(":moreores:hoe_silver", {
|
||||||
description = S("%s Hoe"):format(S("Silver")),
|
description = S("%s Hoe"):format(S("Silver")),
|
||||||
inventory_image = "moreores_tool_silverhoe.png",
|
inventory_image = "moreores_tool_silverhoe.png",
|
||||||
|
@ -510,5 +510,5 @@ if minetest.get_modpath("moreores") then
|
||||||
minetest.override_item("moreores:hoe_mithril", {
|
minetest.override_item("moreores:hoe_mithril", {
|
||||||
original_description = desc,
|
original_description = desc,
|
||||||
description = toolranks.create_description(desc)})
|
description = toolranks.create_description(desc)})
|
||||||
end
|
end]]
|
||||||
end
|
end
|
||||||
|
|
|
@ -149,7 +149,7 @@ Created by OgelGames (CC BY-SA 4.0)
|
||||||
farming_cactus_juice.png
|
farming_cactus_juice.png
|
||||||
farming_salad.png
|
farming_salad.png
|
||||||
|
|
||||||
Created by Felfa
|
Created by Felfa (CC0)
|
||||||
farming_blackberry*.png
|
farming_blackberry*.png
|
||||||
farming_lettuce*.png
|
farming_lettuce*.png
|
||||||
farming_burger.png
|
farming_burger.png
|
||||||
|
|
|
@ -1,94 +1,94 @@
|
||||||
# textdomain:farming
|
# textdomain:farming
|
||||||
#%s Hoe=
|
%s Hoe=%s Hacke
|
||||||
Apple Donut=Apfeldonut
|
Apple Donut=Apfeldonut
|
||||||
#Apple Pie=
|
Apple Pie=Apfelkuchen
|
||||||
Baked Potato=Ofenkartoffel
|
Baked Potato=Ofenkartoffel
|
||||||
#Baking Tray=
|
Baking Tray=Kuchenblech
|
||||||
#Banana=
|
Banana=Banane
|
||||||
#Banana Leaves=
|
Banana Leaves=Bananenblatt
|
||||||
Bar of Dark Chocolate=Tafel Zartbitterschokolade
|
Bar of Dark Chocolate=Tafel Zartbitterschokolade
|
||||||
Barley=Gerste
|
Barley=Gerste
|
||||||
Barley Seed=Gerstenkörner
|
Barley Seed=Gerstenkörner
|
||||||
Bean Pole (place on soil before planting beans)=Bohnenstange (vor dem Pflanzen der Bohnen auf den\nAckerboden stellen)
|
Bean Pole (place on soil before planting beans)=Bohnenstange (vor dem Pflanzen der Bohnen auf den\nAckerboden stellen)
|
||||||
#Beetroot=
|
Beetroot=Rote Beete
|
||||||
#Beetroot Soup=
|
Beetroot Soup=Rote Beete Suppe
|
||||||
#Bibimbap=
|
Bibimbap=Bibimbap
|
||||||
Wild Blueberries=Wilde Blaubeeren
|
Wild Blueberries=Wilde Blaubeeren
|
||||||
Blueberry Muffin=Blaubeermuffin
|
Blueberry Muffin=Blaubeermuffin
|
||||||
#Blueberry Pie=
|
Blueberry Pie=Blaubeerkuchen
|
||||||
Bottle of Ethanol=Flasche Ethanol
|
Bottle of Ethanol=Flasche Ethanol
|
||||||
Bottle of Hemp Oil=Flasche mit Hanföl
|
Bottle of Hemp Oil=Flasche mit Hanföl
|
||||||
#Bowl of Chili=
|
Bowl of Chili=Chili Schale
|
||||||
Bread=Brot
|
Bread=Brot
|
||||||
Bronze Hoe=Bronzehacke
|
Bronze Hoe=Bronzehacke
|
||||||
#Cabbage=
|
Cabbage=Salat
|
||||||
#Cactus Juice=
|
Cactus Juice=Kaktussaft
|
||||||
Carrot=Möhre
|
Carrot=Möhre
|
||||||
#Carrot Juice=
|
Carrot Juice=Möhrensaft
|
||||||
#Chili Pepper=
|
Chili Pepper=Chili
|
||||||
#Chocolate Block=
|
Chocolate Block=Schokoladenstück
|
||||||
Chocolate Donut=Schokodonut
|
Chocolate Donut=Schokodonut
|
||||||
Cocoa Beans=Kakaobohne
|
Cocoa Beans=Kakaobohne
|
||||||
Coffee Beans=Kaffeebohnen
|
Coffee Beans=Kaffeebohnen
|
||||||
Cookie=Keks
|
Cookie=Keks
|
||||||
#Cooking Pot=
|
Cooking Pot=Kochtopf
|
||||||
Corn=Mais
|
Corn=Mais
|
||||||
Corn on the Cob=Maiskolben
|
Corn on the Cob=Maiskolben
|
||||||
#Cornstarch=
|
Cornstarch=Speisestärke
|
||||||
Cotton=Baumwolle
|
Cotton=Baumwolle
|
||||||
Cotton Seed=Baumwollsamen
|
Cotton Seed=Baumwollsamen
|
||||||
Cucumber=Gurke
|
Cucumber=Gurke
|
||||||
#Cucumber and Potato Salad=
|
Cucumber and Potato Salad=Gurken und Tomatensalat
|
||||||
Cup of Coffee=Tasse Kaffee
|
Cup of Coffee=Tasse Kaffee
|
||||||
#Cutting Board=
|
Cutting Board=Schneidebrett
|
||||||
Diamond Hoe=Diamanthacke
|
Diamond Hoe=Diamanthacke
|
||||||
Donut=Donut
|
Donut=Donut
|
||||||
Flour=Mehl
|
Flour=Mehl
|
||||||
#Garlic=
|
Garlic=Knoblauch
|
||||||
#Garlic Braid=
|
Garlic Braid=Knoblauchzopf
|
||||||
#Garlic Bread=
|
Garlic Bread=Knoblauchbrot
|
||||||
#Garlic clove=
|
Garlic clove=Knoblauchzehe
|
||||||
#Glass Mixing Bowl=
|
Glass Mixing Bowl=Glasschlüssel
|
||||||
Golden Carrot=Goldene Möhre
|
Golden Carrot=Goldene Möhre
|
||||||
Grapes=Weintrauben
|
Grapes=Weintrauben
|
||||||
Green Beans=Grüne Bohnen
|
Green Beans=Grüne Bohnen
|
||||||
#Ground Pepper=
|
Ground Pepper=Gemahlener Pfeffer
|
||||||
#Hemp Block=
|
Hemp Block=Hanfblock
|
||||||
Hemp Fibre=Hanffaser
|
Hemp Fibre=Hanffaser
|
||||||
Hemp Leaf=Hanfblatt
|
Hemp Leaf=Hanfblatt
|
||||||
Hemp Rope=Hanfseil
|
Hemp Rope=Hanfseil
|
||||||
Hemp Seed=Hanfsamen
|
Hemp Seed=Hanfsamen
|
||||||
Hoe=Hacke
|
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)
|
Jack 'O Lantern (punch to turn on and off)=Kürbislaterne (Punch zum Ein- und Ausschalten)
|
||||||
#Jaffa Cake=
|
Jaffa Cake=Jaffa-Torte
|
||||||
#Juicer=
|
Juicer=Entsafter
|
||||||
Melon=Melone
|
Melon=Melone
|
||||||
Melon Slice=Melonenscheibe
|
Melon Slice=Melonenscheibe
|
||||||
Mese Hoe=Mesehacke
|
Mese Hoe=Mesehacke
|
||||||
#Mint Leaf=
|
Mint Leaf=Minzblatt
|
||||||
#Mint Seeds=
|
Mint Seeds=Minzsamen
|
||||||
#Mint Tea=
|
Mint Tea=Minztee
|
||||||
#Mithril Scythe (Right-click to harvest and replant crops)=
|
Mithril Scythe (Right-click to harvest and replant crops)=Mithril-Sense (Rechts-Klick zum Ernten und Wiedereinpflanzen)
|
||||||
#Mortar and Pestle=
|
Mortar and Pestle=Mörser und Stößel
|
||||||
#Multigrain Bread=
|
Multigrain Bread=Mehrkornbrot
|
||||||
#Multigrain Flour=
|
Multigrain Flour=Mehrkornmehl
|
||||||
#Oat seed=
|
Oat seed=Hafersamen
|
||||||
#Oats=
|
Oats=Hafer
|
||||||
#Onion=
|
Onion=Zwiebel
|
||||||
#Onion Soup=
|
Onion Soup=Zwiebelsuppe
|
||||||
#Orange=
|
Orange=Apfelsine
|
||||||
#Pasta=
|
Pasta=Pasta
|
||||||
#Pea Pod=
|
Pea Pod=Erbsenschote
|
||||||
#Pea Soup=
|
Pea Soup=Erbsensuppe
|
||||||
#Peas=
|
Peas=Erbsen
|
||||||
#Pepper=
|
Pepper=Pfeffer
|
||||||
#Peppercorn=
|
Peppercorn=Pfefferkorn
|
||||||
#Pineapple=
|
Pineapple=Ananas
|
||||||
#Pineapple Juice=
|
Pineapple Juice=Ananassaft
|
||||||
#Pineapple Ring=
|
Pineapple Ring=Ananasscheibe
|
||||||
#Pineapple Top=
|
Pineapple Top=Ananasdeckel
|
||||||
#Porridge=
|
Porridge=Brei
|
||||||
Potato=Kartoffel
|
Potato=Kartoffel
|
||||||
Pumpkin=Kürbis
|
Pumpkin=Kürbis
|
||||||
Pumpkin Bread=Kürbisbrot
|
Pumpkin Bread=Kürbisbrot
|
||||||
|
@ -98,37 +98,37 @@ Raspberries=Himbeeren
|
||||||
Raspberry Smoothie=Himbeersmoothie
|
Raspberry Smoothie=Himbeersmoothie
|
||||||
Rhubarb=Rhabarber
|
Rhubarb=Rhabarber
|
||||||
Rhubarb Pie=Rhabarberkuchen
|
Rhubarb Pie=Rhabarberkuchen
|
||||||
#Rice=
|
Rice=Reis
|
||||||
#Rice Bread=
|
Rice Bread=Reiswaffel
|
||||||
#Rice Flour=
|
Rice Flour=Reismehl
|
||||||
#Rice grains=
|
Rice grains=Reissaat
|
||||||
#Rose Water=
|
Rose Water=Rosenwasser
|
||||||
#Rye=
|
Rye=Roggen
|
||||||
#Rye seed=
|
Rye seed=Roggensaat
|
||||||
#Salt=
|
Salt=Salz
|
||||||
#Saucepan=
|
Saucepan=Kasserolle
|
||||||
#Savanna Soil=
|
Savanna Soil=Savannaerde
|
||||||
#Scarecrow Bottom=
|
Scarecrow Bottom=Vogelscheuchengestell
|
||||||
Seed=Saatgut
|
Seed=Saatgut
|
||||||
#Skillet=
|
Skillet=Bratpfanne
|
||||||
#Sliced Bread=
|
Sliced Bread=Geschnittenes Brot
|
||||||
Soil=Ackerboden
|
Soil=Ackerboden
|
||||||
#Spaghetti=
|
Spaghetti=Spaghetti
|
||||||
Steel Hoe=Stahlhacke
|
Steel Hoe=Stahlhacke
|
||||||
Stone Hoe=Steinhacke
|
Stone Hoe=Steinhacke
|
||||||
Straw=Stroh
|
Straw=Stroh
|
||||||
#Strawberry=
|
Strawberry=Erdbeere
|
||||||
#String=
|
String=Faden
|
||||||
Sugar=Zucker
|
Sugar=Zucker
|
||||||
#Toast=
|
Toast=Toast
|
||||||
#Toast Sandwich=
|
Toast Sandwich=Toast Sandwich
|
||||||
Tomato=Tomate
|
Tomato=Tomate
|
||||||
Trellis (place on soil before planting grapes)=Spalier (vor dem Pflanzen der Weintrauben auf den\nAckerboden stellen)
|
Trellis (place on soil before planting grapes)=Spalier (vor dem Pflanzen der Weintrauben auf den\nAckerboden stellen)
|
||||||
#Turkish Delight=
|
Turkish Delight=Lokum
|
||||||
#Wet Savanna Soil=
|
Wet Savanna Soil=Feuchte Savannaerde
|
||||||
Wet Soil=Bewässerter Ackerboden
|
Wet Soil=Bewässerter Ackerboden
|
||||||
Wheat=Weizen
|
Wheat=Weizen
|
||||||
Wheat Seed=Weizenkörner
|
Wheat Seed=Weizenkörner
|
||||||
#Wild Cotton=
|
Wild Cotton=Wilde Baumwolle
|
||||||
#Wooden Bowl=
|
Wooden Bowl=Holzschale
|
||||||
Wooden Hoe=Holzhacke
|
Wooden Hoe=Holzhacke
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
name = farming
|
name = farming
|
||||||
|
depends = default
|
||||||
|
optional_depends = stairs, intllib, lucky_block, toolranks
|
||||||
|
description = Adds many plants and food to Minetest
|
||||||
|
|
|
@ -188,11 +188,13 @@ minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "mobs:bucket_milk",
|
output = "mobs:bucket_milk",
|
||||||
recipe = {
|
recipe = {
|
||||||
"mobs:glass_milk", "mobs:glass_milk",
|
"group:food_milk_glass", "group:food_milk_glass",
|
||||||
"mobs:glass_milk", "mobs:glass_milk",
|
"group:food_milk_glass", "group:food_milk_glass",
|
||||||
"bucket:bucket_empty"
|
"bucket:bucket_empty"
|
||||||
},
|
},
|
||||||
replacements = { {"mobs:glass_milk", "vessels:drinking_glass 4"} }
|
replacements = {
|
||||||
|
{"group:food_milk_glass", "vessels:drinking_glass 4"},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,12 @@ mobs:register_mob("mobs_animal:pumba", {
|
||||||
walk_end = 100,
|
walk_end = 100,
|
||||||
punch_start = 70,
|
punch_start = 70,
|
||||||
punch_end = 100,
|
punch_end = 100,
|
||||||
|
|
||||||
|
die_start = 1, -- we dont have a specific death animation so we will
|
||||||
|
die_end = 2, -- re-use 2 standing frames at a speed of 1 fps and
|
||||||
|
die_speed = 1, -- have mob rotate when dying.
|
||||||
|
die_loop = false,
|
||||||
|
die_rotate = true,
|
||||||
},
|
},
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20201206",
|
version = "20210108",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ local max_per_block = tonumber(settings:get("max_objects_per_block") or 99)
|
||||||
local mob_nospawn_range = tonumber(settings:get("mob_nospawn_range") or 12)
|
local mob_nospawn_range = tonumber(settings:get("mob_nospawn_range") or 12)
|
||||||
local active_limit = tonumber(settings:get("mob_active_limit") or 0)
|
local active_limit = tonumber(settings:get("mob_active_limit") or 0)
|
||||||
local mob_chance_multiplier = tonumber(settings:get("mob_chance_multiplier") or 1)
|
local mob_chance_multiplier = tonumber(settings:get("mob_chance_multiplier") or 1)
|
||||||
|
local peaceful_player_enabled = settings:get_bool("enable_peaceful_player")
|
||||||
local active_mobs = 0
|
local active_mobs = 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -571,7 +572,8 @@ function mob_class:attempt_flight_correction(override)
|
||||||
|
|
||||||
local flyable_nodes = minetest.find_nodes_in_area(
|
local flyable_nodes = minetest.find_nodes_in_area(
|
||||||
{x = pos.x - 1, y = pos.y - 1, z = pos.z - 1},
|
{x = pos.x - 1, y = pos.y - 1, z = pos.z - 1},
|
||||||
{x = pos.x + 1, y = pos.y + 1, z = pos.z + 1}, searchnodes)
|
{x = pos.x + 1, y = pos.y + 0, z = pos.z + 1}, searchnodes)
|
||||||
|
-- pos.y + 0 hopefully fixes floating swimmers
|
||||||
|
|
||||||
if #flyable_nodes < 1 then
|
if #flyable_nodes < 1 then
|
||||||
return false
|
return false
|
||||||
|
@ -908,6 +910,7 @@ function mob_class:check_for_death(cmi_cause)
|
||||||
local rot = self.animation.die_rotate and 5
|
local rot = self.animation.die_rotate and 5
|
||||||
|
|
||||||
self.attack = nil
|
self.attack = nil
|
||||||
|
self.following = nil
|
||||||
self.v_start = false
|
self.v_start = false
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.blinktimer = 0
|
self.blinktimer = 0
|
||||||
|
@ -915,7 +918,7 @@ function mob_class:check_for_death(cmi_cause)
|
||||||
self.state = "die"
|
self.state = "die"
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
pointable = false, collide_with_objects = false,
|
pointable = false, collide_with_objects = false,
|
||||||
automatic_rotate = rot,
|
automatic_rotate = rot, static_save = false
|
||||||
})
|
})
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
self:set_animation("die")
|
self:set_animation("die")
|
||||||
|
@ -1848,6 +1851,23 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- peaceful player privilege support
|
||||||
|
local function is_peaceful_player(player)
|
||||||
|
|
||||||
|
if peaceful_player_enabled then
|
||||||
|
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
|
if player_name
|
||||||
|
and minetest.check_player_privs(player_name, "peaceful_player") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- general attack function for all mobs
|
-- general attack function for all mobs
|
||||||
function mob_class:general_attack()
|
function mob_class:general_attack()
|
||||||
|
|
||||||
|
@ -1920,7 +1940,8 @@ function mob_class:general_attack()
|
||||||
-- choose closest player to attack that isnt self
|
-- choose closest player to attack that isnt self
|
||||||
if dist ~= 0
|
if dist ~= 0
|
||||||
and dist < min_dist
|
and dist < min_dist
|
||||||
and self:line_of_sight(sp, p, 2) == true then
|
and self:line_of_sight(sp, p, 2) == true
|
||||||
|
and not is_peaceful_player(player) then
|
||||||
min_dist = dist
|
min_dist = dist
|
||||||
min_player = player
|
min_player = player
|
||||||
end
|
end
|
||||||
|
@ -3054,6 +3075,7 @@ function mob_class:mob_staticdata()
|
||||||
if t ~= "function"
|
if t ~= "function"
|
||||||
and t ~= "nil"
|
and t ~= "nil"
|
||||||
and t ~= "userdata"
|
and t ~= "userdata"
|
||||||
|
and _ ~= "object"
|
||||||
and _ ~= "_cmi_components" then
|
and _ ~= "_cmi_components" then
|
||||||
tmp[_] = self[_]
|
tmp[_] = self[_]
|
||||||
end
|
end
|
||||||
|
@ -3306,6 +3328,8 @@ function mob_class:on_step(dtime, moveresult)
|
||||||
}}
|
}}
|
||||||
}]]
|
}]]
|
||||||
|
|
||||||
|
if self.state == "die" then return end ----------------
|
||||||
|
|
||||||
if use_cmi then
|
if use_cmi then
|
||||||
cmi.notify_step(self.object, dtime)
|
cmi.notify_step(self.object, dtime)
|
||||||
end
|
end
|
||||||
|
@ -4503,10 +4527,10 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net,
|
||||||
minetest.add_item(clicker:get_pos(), new_stack)
|
minetest.add_item(clicker:get_pos(), new_stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_mob(self, true)
|
|
||||||
|
|
||||||
self:mob_sound("default_place_node_hard")
|
self:mob_sound("default_place_node_hard")
|
||||||
|
|
||||||
|
remove_mob(self, true)
|
||||||
|
|
||||||
return new_stack
|
return new_stack
|
||||||
|
|
||||||
-- when chance above fails or set to 0, miss!
|
-- when chance above fails or set to 0, miss!
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
|
|
||||||
local path = minetest.get_modpath("mobs")
|
local path = minetest.get_modpath("mobs")
|
||||||
|
|
||||||
|
-- Peaceful player privilege
|
||||||
|
minetest.register_privilege("peaceful_player", {
|
||||||
|
description = "Prevents Mobs Redo mobs from attacking player",
|
||||||
|
give_to_singleplayer = false
|
||||||
|
})
|
||||||
|
|
||||||
-- Mob API
|
-- Mob API
|
||||||
dofile(path .. "/api.lua")
|
dofile(path .. "/api.lua")
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ Lucky Blocks: 9
|
||||||
|
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence)
|
||||||
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added.
|
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added.
|
||||||
- 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded.
|
- 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded.
|
||||||
- 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game,
|
- 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game,
|
||||||
|
|
|
@ -36,3 +36,6 @@ mob_active_limit (Mob Active Limit) float 0
|
||||||
|
|
||||||
# Enables area check when spawning mobs
|
# Enables area check when spawning mobs
|
||||||
mob_area_spawn (Mob Area Spawn) bool false
|
mob_area_spawn (Mob Area Spawn) bool false
|
||||||
|
|
||||||
|
# Enable peaceful player attack prevention
|
||||||
|
enable_peaceful_player (Mobs do not attack peaceful player without reason) bool false
|
||||||
|
|
|
@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Refactored recipe override mechanism to avoid re-coding recipes
|
||||||
|
when we only want to change the amount produced.
|
||||||
|
- [Realigned rail recipe to the changes made in Minetest Game.](https://github.com/minetest-mods/moreblocks/pull/169)
|
||||||
|
- All rail recipes (standard, power, break) were boosted by 50%.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- [Fixed strange placement behavior for non-default Stairs+ nodes.](https://github.com/minetest-mods/moreblocks/pull/168)
|
- [Fixed strange placement behavior for non-default Stairs+ nodes.](https://github.com/minetest-mods/moreblocks/pull/168)
|
||||||
|
|
|
@ -5,64 +5,78 @@ Copyright © 2011-2020 Hugo Locurcio and contributors.
|
||||||
Licensed under the zlib license. See LICENSE.md for more information.
|
Licensed under the zlib license. See LICENSE.md for more information.
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
-- Redefinitions of some default crafting recipes:
|
local modname = minetest.get_current_modname()
|
||||||
|
|
||||||
-- Signs: +1
|
-- Redefine some of the default crafting recipes to be more productive
|
||||||
minetest.clear_craft({
|
|
||||||
recipe = {
|
-- Auxiliary function: take a recipe as returned by get_all_craft_recipes
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
-- and turn it into a table that can be used to clear a craft or declare a new one
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
local reconstruct_internal_craft = function(recipe)
|
||||||
{'', 'group:stick', ''},
|
local recp = {
|
||||||
|
{ "", "", "" },
|
||||||
|
{ "", "", "" },
|
||||||
|
{ "", "", "" },
|
||||||
}
|
}
|
||||||
})
|
for idx, item in pairs(recipe.items) do
|
||||||
|
local row = math.ceil(idx / recipe.width)
|
||||||
|
local col = idx - (row-1)*recipe.width
|
||||||
|
recp[row][col] = item
|
||||||
|
end
|
||||||
|
return recp
|
||||||
|
end
|
||||||
|
|
||||||
minetest.clear_craft({
|
-- Change the amount produced by recipe by apply func to the old amount
|
||||||
recipe = {
|
local change_recipe_amount = function(product, recipe, func)
|
||||||
{'group:wood', 'group:wood', 'group:wood'},
|
local recp = reconstruct_internal_craft(recipe)
|
||||||
{'group:wood', 'group:wood', 'group:wood'},
|
|
||||||
{'', 'group:stick', ''},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
local oldamount = tonumber(recipe.output:match(" [0-9]+$") or "1")
|
||||||
output = 'default:sign_wall_steel 4',
|
|
||||||
recipe = {
|
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
|
||||||
{'', 'group:stick', ''},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
local newamount = func(oldamount)
|
||||||
output = 'default:sign_wall_wood 4',
|
|
||||||
recipe = {
|
|
||||||
{'group:wood', 'group:wood', 'group:wood'},
|
|
||||||
{'group:wood', 'group:wood', 'group:wood'},
|
|
||||||
{'', 'group:stick', ''},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
-- remove old crafting recipe
|
||||||
|
local redo = { recipe = recp }
|
||||||
|
minetest.clear_craft(redo)
|
||||||
|
|
||||||
minetest.clear_craft({
|
-- new output
|
||||||
recipe = {
|
redo.output = ("%s %d"):format(product, newamount)
|
||||||
{"default:papyrus", "default:papyrus", "default:papyrus"}
|
minetest.register_craft(redo)
|
||||||
}
|
|
||||||
})
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "default:paper 4",
|
|
||||||
recipe = {
|
|
||||||
{"default:papyrus", "default:papyrus", "default:papyrus"},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
minetest.log("action", ("[MOD]%s: recipe for %s production: %d => %d"):format(modname, product, oldamount, newamount))
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
local increase_craft_production = function(product, func)
|
||||||
output = "default:rail 24",
|
local recipes = minetest.get_all_craft_recipes(product)
|
||||||
recipe = {
|
for _, r in pairs(recipes) do
|
||||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
if r.type == "normal" or r.method == "normal" then
|
||||||
{"default:steel_ingot", "default:stick", "default:steel_ingot"},
|
change_recipe_amount(product, r, func)
|
||||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
end
|
||||||
}
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Increase the crafting production according to the rules from the table, which is in the form:
|
||||||
|
-- {
|
||||||
|
-- { detector, amount changing function }
|
||||||
|
-- { detector, amount changing function }
|
||||||
|
-- }
|
||||||
|
-- TODO: consider exporting this function to other mods
|
||||||
|
local increase_craft_production_table = function(map_table)
|
||||||
|
for product, _ in pairs(minetest.registered_items) do
|
||||||
|
for _, tab in pairs(map_table) do
|
||||||
|
local detector = tab[1]
|
||||||
|
local func = tab[2]
|
||||||
|
if detector(product) then
|
||||||
|
increase_craft_production(product, func)
|
||||||
|
-- only apply one boost
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
increase_craft_production_table({
|
||||||
|
{ function(n) return n:match('^default:sign_wall') end, function(old) return old + 1 end },
|
||||||
|
{ function(n) return n == 'default:paper' end, function(old) return old*4 end },
|
||||||
|
{ function(n) return n:match('^carts:.*rail$') or n:match('^default:.*rail$') end, function(old) return old + old/2 end },
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
|
@ -457,7 +457,8 @@ local del_display = function(pos)
|
||||||
|
|
||||||
for _, v in ipairs(objects) do
|
for _, v in ipairs(objects) do
|
||||||
|
|
||||||
if v:get_luaentity().name == "protector:display" then
|
if v and v:get_luaentity()
|
||||||
|
and v:get_luaentity().name == "protector:display" then
|
||||||
v:remove()
|
v:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,17 +78,11 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||||
|
|
||||||
Default: `signs_lib.after_place_node`
|
Default: `signs_lib.after_place_node`
|
||||||
|
|
||||||
* `on_rightclick = function(pos)`
|
* `on_rightclick = function(pos, node, player, itemstack, pointed_thing)`
|
||||||
|
|
||||||
See below under "Main functions".
|
See below under "Main functions".
|
||||||
|
|
||||||
Default: `signs_lib.construct_sign`
|
Default: `signs_lib.rightclick_sign`
|
||||||
|
|
||||||
* `on_construct = function(pos)`
|
|
||||||
|
|
||||||
See below under "Main functions".
|
|
||||||
|
|
||||||
Default: `signs_lib.construct_sign`
|
|
||||||
|
|
||||||
* `on_destruct = function(pos)`
|
* `on_destruct = function(pos)`
|
||||||
|
|
||||||
|
@ -96,12 +90,6 @@ In this text, common terms such as `pos`, `node`, or `placer`/`digger` will not
|
||||||
|
|
||||||
Default: `signs_lib.destruct_sign`
|
Default: `signs_lib.destruct_sign`
|
||||||
|
|
||||||
* `on_receive_fields = function(pos, formname, fields, sender)`
|
|
||||||
|
|
||||||
See below under "Main functions".
|
|
||||||
|
|
||||||
Default: `signs_lib.receive_fields`
|
|
||||||
|
|
||||||
* `on_punch = function(pos)`
|
* `on_punch = function(pos)`
|
||||||
|
|
||||||
See below under "Main functions".
|
See below under "Main functions".
|
||||||
|
@ -258,18 +246,14 @@ signs_lib.register_sign("basic_signs:sign_wall_glass", {
|
||||||
|
|
||||||
* `locked`: if set to **true**, the sign's meta will be tweaked to indicate its ownership by the `placer`.
|
* `locked`: if set to **true**, the sign's meta will be tweaked to indicate its ownership by the `placer`.
|
||||||
|
|
||||||
* `signs_lib.construct_sign(pos)`
|
* `signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)`
|
||||||
|
|
||||||
Sets up the sign's formspec and infotext overlay.
|
Open the default sign formspec, if the player has the `signslib_edit` privilege.
|
||||||
|
|
||||||
* `signs_lib.destruct_sign(pos)`
|
* `signs_lib.destruct_sign(pos)`
|
||||||
|
|
||||||
Deletes the sign's entity, if any, when the sign is dug.
|
Deletes the sign's entity, if any, when the sign is dug.
|
||||||
|
|
||||||
* `signs_lib.receive_fields(pos, formname, fields, sender)`
|
|
||||||
|
|
||||||
This handles the text input and wide font on/off switch, logging any actions the user takes. Bails-out silently if the user is not allowed to edit the sign. See the standard Minetest lua_api.txt for details.
|
|
||||||
|
|
||||||
* `signs_lib.update_sign(pos, fields)`
|
* `signs_lib.update_sign(pos, fields)`
|
||||||
|
|
||||||
If the sign's writable, this deletes any sign-related entities in the sign's node space, spawns a new one, and renders whatever text is in the sign's meta.
|
If the sign's writable, this deletes any sign-related entities in the sign's node space, spawns a new one, and renders whatever text is in the sign's meta.
|
||||||
|
@ -352,7 +336,7 @@ Supplying one or both of the following in the pole/post node's definition will c
|
||||||
If supplied, this function will be run when the mod is looking for a normal vertical pole/post. Useful if the target node's orientation and/or shape determine what sides a sign can attach to. For example, [Pipeworks](https://forum.minetest.net/viewtopic.php?pid=27794) uses this to figure out if a sign can be attached to a tube or pipe, depending on the tube's/pipe's number of junctions, and on its orientation and that of the placed sign.
|
If supplied, this function will be run when the mod is looking for a normal vertical pole/post. Useful if the target node's orientation and/or shape determine what sides a sign can attach to. For example, [Pipeworks](https://forum.minetest.net/viewtopic.php?pid=27794) uses this to figure out if a sign can be attached to a tube or pipe, depending on the tube's/pipe's number of junctions, and on its orientation and that of the placed sign.
|
||||||
|
|
||||||
* `def`: the placed sign's node defintion
|
* `def`: the placed sign's node defintion
|
||||||
* `pole_pos`: the target node's position
|
* `pole_pos`: the target node's position
|
||||||
* `pole_node`: the target node itself
|
* `pole_node`: the target node itself
|
||||||
* `pole_def`: its node definition
|
* `pole_def`: its node definition
|
||||||
|
|
||||||
|
|
|
@ -55,3 +55,9 @@ At present, only one command is defined:
|
||||||
This will read through the list of currently-loaded blocks known to contain one or more signs, delete all entities found in each sign's node space, and respawn and re-render each from scratch.
|
This will read through the list of currently-loaded blocks known to contain one or more signs, delete all entities found in each sign's node space, and respawn and re-render each from scratch.
|
||||||
|
|
||||||
The list of loaded, sign-bearing blocks is created/populated by an LBM (and trimmed by this command if any listed blocks are found to have been unloaded).
|
The list of loaded, sign-bearing blocks is created/populated by an LBM (and trimmed by this command if any listed blocks are found to have been unloaded).
|
||||||
|
|
||||||
|
## Privileges
|
||||||
|
|
||||||
|
* `signslib_edit`
|
||||||
|
|
||||||
|
Allows to rotate signs and to open (and consequently edit) any default sign formspec.
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
local S = signs_lib.gettext
|
local S = signs_lib.gettext
|
||||||
|
|
||||||
|
local function get_sign_formspec() end
|
||||||
|
|
||||||
signs_lib.lbm_restore_nodes = {}
|
signs_lib.lbm_restore_nodes = {}
|
||||||
signs_lib.old_fenceposts = {}
|
signs_lib.old_fenceposts = {}
|
||||||
signs_lib.old_fenceposts_replacement_signs = {}
|
signs_lib.old_fenceposts_replacement_signs = {}
|
||||||
|
@ -345,10 +347,10 @@ local function file_exists(name, return_handle, mode)
|
||||||
if (return_handle) then
|
if (return_handle) then
|
||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
io.close(f)
|
io.close(f)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -552,7 +554,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
||||||
end
|
end
|
||||||
table.insert(
|
table.insert(
|
||||||
texture,
|
texture,
|
||||||
(":%d,%d="):format(xpos + word.w, ypos) .. char_tex(font_name, " ")
|
(":%d,%d="):format(xpos + word.w, ypos) .. char_tex(font_name, " ")
|
||||||
)
|
)
|
||||||
xpos = xpos + word.w + cwidth_tab[" "]
|
xpos = xpos + word.w + cwidth_tab[" "]
|
||||||
|
@ -619,31 +621,12 @@ function signs_lib.split_lines_and_words(text)
|
||||||
return lines
|
return lines
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.construct_sign(pos)
|
function signs_lib.rightclick_sign(pos, node, player, itemstack, pointed_thing)
|
||||||
local form = "size[6,4]"..
|
|
||||||
"textarea[0,-0.3;6.5,3;text;;${text}]"..
|
|
||||||
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]"
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local def = minetest.registered_items[node.name]
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
|
|
||||||
if def.allow_widefont then
|
if not signs_lib.can_modify(pos, player) then return end
|
||||||
local state = "off"
|
|
||||||
if meta:get_int("widefont") == 1 then state = "on" end
|
|
||||||
form = form.."label[1,3.4;Use wide font]"..
|
|
||||||
"image_button[1.1,3.7;1,0.6;signs_lib_switch_"..
|
|
||||||
state..".png;"..
|
|
||||||
state..";;;false;signs_lib_switch_interm.png]"..
|
|
||||||
"button_exit[3,3.4;2,1;ok;"..S("Write").."]"
|
|
||||||
else
|
|
||||||
form = form.."button_exit[2,3.4;2,1;ok;"..S("Write").."]"
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("formspec", form)
|
player:get_meta():set_string("signslib:pos", minetest.pos_to_string(pos))
|
||||||
local i = meta:get_string("infotext")
|
minetest.show_formspec(player:get_player_name(), "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||||
if i == "" then -- it wasn't even set, so set it.
|
|
||||||
meta:set_string("infotext", "")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.destruct_sign(pos)
|
function signs_lib.destruct_sign(pos)
|
||||||
|
@ -663,6 +646,11 @@ end
|
||||||
function signs_lib.update_sign(pos, fields)
|
function signs_lib.update_sign(pos, fields)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
-- legacy udpate
|
||||||
|
if meta:get_string("formspec") ~= "" then
|
||||||
|
meta:set_string("formspec", "")
|
||||||
|
end
|
||||||
|
|
||||||
local text = fields and fields.text or meta:get_string("text")
|
local text = fields and fields.text or meta:get_string("text")
|
||||||
text = trim_input(text)
|
text = trim_input(text)
|
||||||
|
|
||||||
|
@ -675,54 +663,19 @@ function signs_lib.update_sign(pos, fields)
|
||||||
signs_lib.set_obj_text(pos, text)
|
signs_lib.set_obj_text(pos, text)
|
||||||
end
|
end
|
||||||
|
|
||||||
function signs_lib.receive_fields(pos, formname, fields, sender)
|
|
||||||
|
|
||||||
if not fields or not signs_lib.can_modify(pos, sender) then return end
|
|
||||||
|
|
||||||
if fields.text and fields.ok then
|
|
||||||
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
|
||||||
(sender:get_player_name() or ""),
|
|
||||||
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
|
||||||
minetest.pos_to_string(pos)
|
|
||||||
))
|
|
||||||
signs_lib.update_sign(pos, fields)
|
|
||||||
elseif fields.on or fields.off then
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local change
|
|
||||||
|
|
||||||
if fields.on and meta:get_int("widefont") == 1 then
|
|
||||||
meta:set_int("widefont", 0)
|
|
||||||
change = true
|
|
||||||
elseif fields.off and meta:get_int("widefont") == 0 then
|
|
||||||
meta:set_int("widefont", 1)
|
|
||||||
change = true
|
|
||||||
end
|
|
||||||
if change then
|
|
||||||
minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
|
|
||||||
(sender:get_player_name() or ""),
|
|
||||||
(fields.on and "off" or "on"),
|
|
||||||
minetest.pos_to_string(pos)
|
|
||||||
))
|
|
||||||
signs_lib.construct_sign(pos)
|
|
||||||
signs_lib.update_sign(pos, fields)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function signs_lib.can_modify(pos, player)
|
function signs_lib.can_modify(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
if minetest.is_protected(pos, playername) then
|
if minetest.is_protected(pos, playername) then
|
||||||
minetest.record_protection_violation(pos, playername)
|
minetest.record_protection_violation(pos, playername)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if owner == ""
|
if owner == ""
|
||||||
or playername == owner
|
or playername == owner
|
||||||
or (minetest.check_player_privs(playername, {sign_editor=true}))
|
or (minetest.check_player_privs(playername, {signslib_edit=true}))
|
||||||
or (playername == minetest.settings:get("name")) then
|
or (playername == minetest.settings:get("name")) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -887,10 +840,8 @@ function signs_lib.register_sign(name, raw_def)
|
||||||
def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
|
def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
|
||||||
|
|
||||||
if raw_def.entity_info then
|
if raw_def.entity_info then
|
||||||
def.on_rightclick = raw_def.on_rightclick or signs_lib.construct_sign
|
def.on_rightclick = raw_def.on_rightclick or signs_lib.rightclick_sign
|
||||||
def.on_construct = raw_def.on_construct or signs_lib.construct_sign
|
|
||||||
def.on_destruct = raw_def.on_destruct or signs_lib.destruct_sign
|
def.on_destruct = raw_def.on_destruct or signs_lib.destruct_sign
|
||||||
def.on_receive_fields = raw_def.on_receive_fields or signs_lib.receive_fields
|
|
||||||
def.on_punch = raw_def.on_punch or signs_lib.update_sign
|
def.on_punch = raw_def.on_punch or signs_lib.update_sign
|
||||||
def.number_of_lines = raw_def.number_of_lines or signs_lib.standard_lines
|
def.number_of_lines = raw_def.number_of_lines or signs_lib.standard_lines
|
||||||
def.horiz_scaling = raw_def.horiz_scaling or signs_lib.standard_hscale
|
def.horiz_scaling = raw_def.horiz_scaling or signs_lib.standard_hscale
|
||||||
|
@ -1184,3 +1135,74 @@ minetest.register_chatcommand("regen_signs", {
|
||||||
minetest.chat_send_player(player_name, "Finished.")
|
minetest.chat_send_player(player_name, "Finished.")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_privilege("signslib_edit", {})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- local functions
|
||||||
|
--
|
||||||
|
|
||||||
|
function get_sign_formspec(pos, nodename)
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local txt = meta:get_string("text")
|
||||||
|
|
||||||
|
local formspec = {
|
||||||
|
"size[6,4]",
|
||||||
|
"textarea[0,-0.3;6.5,3;text;;" .. txt .. "]",
|
||||||
|
"background[-0.5,-0.5;7,5;signs_lib_sign_bg.jpg]",
|
||||||
|
"button_exit[2,3.4;2,1;ok;" .. S("Write") .. "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
if minetest.registered_nodes[nodename].allow_widefont then
|
||||||
|
local state = "off"
|
||||||
|
if meta:get_int("widefont") == 1 then state = "on" end
|
||||||
|
formspec[5] = "label[0.5,3.4;Use wide font]"
|
||||||
|
formspec[6] = "image_button[0.6,3.7;1,0.6;signs_lib_switch_" .. state .. ".png;"
|
||||||
|
.. state .. ";;;false;signs_lib_switch_interm.png]"
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(formspec, "")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
|
if formname ~= "signs_lib:sign" then return end
|
||||||
|
|
||||||
|
local pos_string = player:get_meta():get_string("signslib:pos")
|
||||||
|
local pos = minetest.string_to_pos(pos_string)
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
|
if fields.text and fields.ok then
|
||||||
|
minetest.log("action", S("@1 wrote \"@2\" to sign at @3",
|
||||||
|
(playername or ""),
|
||||||
|
fields.text:gsub('\\', '\\\\'):gsub("\n", "\\n"),
|
||||||
|
pos_string
|
||||||
|
))
|
||||||
|
signs_lib.update_sign(pos, fields)
|
||||||
|
elseif fields.on or fields.off then
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local change
|
||||||
|
|
||||||
|
if fields.on and meta:get_int("widefont") == 1 then
|
||||||
|
meta:set_int("widefont", 0)
|
||||||
|
change = true
|
||||||
|
elseif fields.off and meta:get_int("widefont") == 0 then
|
||||||
|
meta:set_int("widefont", 1)
|
||||||
|
change = true
|
||||||
|
end
|
||||||
|
if change then
|
||||||
|
minetest.log("action", S("@1 flipped the wide-font switch to \"@2\" at @3",
|
||||||
|
(playername or ""),
|
||||||
|
(fields.on and "off" or "on"),
|
||||||
|
minetest.pos_to_string(pos)
|
||||||
|
))
|
||||||
|
minetest.show_formspec(playername, "signs_lib:sign", get_sign_formspec(pos, node.name))
|
||||||
|
signs_lib.update_sign(pos, fields)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
|
@ -9,6 +9,7 @@ This Minetest mod offers changeable player skins with a graphical interface for
|
||||||
- Skin change menu for sfinv (in minetest_game) and [unified_inventory](https://forum.minetest.net/viewtopic.php?t=12767)
|
- Skin change menu for sfinv (in minetest_game) and [unified_inventory](https://forum.minetest.net/viewtopic.php?t=12767)
|
||||||
- Skins change menu and command line using chat command /skinsdb (set | show | list | list private | list public | ui)
|
- Skins change menu and command line using chat command /skinsdb (set | show | list | list private | list public | ui)
|
||||||
- Supported by [smart_inventory](https://forum.minetest.net/viewtopic.php?t=16597) for the skin selection
|
- Supported by [smart_inventory](https://forum.minetest.net/viewtopic.php?t=16597) for the skin selection
|
||||||
|
- Supported by [i3](https://github.com/minetest-mods/i3) inventory mod
|
||||||
- Skin previews supported in selection
|
- Skin previews supported in selection
|
||||||
- Additional information for each skin
|
- Additional information for each skin
|
||||||
- Support for different skins lists: public and a per-player list are currently implemented
|
- Support for different skins lists: public and a per-player list are currently implemented
|
||||||
|
|
3
mods/skinsdb/meta/character_1938.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
MUD
|
||||||
|
Mihin Dissanayake
|
||||||
|
CC BY-SA 3.0
|
3
mods/skinsdb/meta/character_1939.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
MUD
|
||||||
|
Mihin Dissanayake
|
||||||
|
CC BY-SA 3.0
|
BIN
mods/skinsdb/textures/character_1938.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
mods/skinsdb/textures/character_1939.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
stamina = {players = {}}
|
stamina = {players = {}}
|
||||||
|
|
||||||
STAMINA_TICK = 800 -- time in seconds after that 1 stamina point is taken
|
STAMINA_TICK = tonumber(minetest.settings:get("stamina_tick")) or 800
|
||||||
|
-- time in seconds after that 1 stamina point is taken
|
||||||
STAMINA_TICK_MIN = 4 -- stamina ticks won't reduce stamina below this level
|
STAMINA_TICK_MIN = 4 -- stamina ticks won't reduce stamina below this level
|
||||||
STAMINA_HEALTH_TICK = 4 -- time in seconds after player gets healed/damaged
|
STAMINA_HEALTH_TICK = 4 -- time in seconds after player gets healed/damaged
|
||||||
STAMINA_MOVE_TICK = 0.5 -- time in seconds after the movement is checked
|
STAMINA_MOVE_TICK = 0.5 -- time in seconds after the movement is checked
|
||||||
|
@ -45,10 +46,12 @@ local function get_int_attribute(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local stamina_enabled = minetest.settings:get_bool("enable_stamina") ~= false
|
||||||
|
|
||||||
local function stamina_update_level(player, level)
|
local function stamina_update_level(player, level)
|
||||||
|
|
||||||
-- pipeworks fake player check
|
-- pipeworks fake player check
|
||||||
if not player.get_attribute then
|
if not player.get_attribute or not stamina_enabled then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,8 +132,8 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- Sprint settings and function
|
-- Sprint settings and function
|
||||||
local enable_sprint = minetest.setting_getbool("sprint") ~= false
|
local enable_sprint = minetest.settings:get_bool("sprint") ~= false
|
||||||
local enable_sprint_particles = minetest.setting_getbool("sprint_particles") ~= false
|
local enable_sprint_particles = minetest.settings:get_bool("sprint_particles") ~= false
|
||||||
local monoids = minetest.get_modpath("player_monoids")
|
local monoids = minetest.get_modpath("player_monoids")
|
||||||
local pova_mod = minetest.get_modpath("pova")
|
local pova_mod = minetest.get_modpath("pova")
|
||||||
|
|
||||||
|
@ -202,11 +205,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- Time based stamina functions
|
-- Time based stamina functions
|
||||||
local stamina_timer = 0
|
local stamina_timer, health_timer, action_timer, poison_timer, drunk_timer = 0,0,0,0,0
|
||||||
local health_timer = 0
|
|
||||||
local action_timer = 0
|
|
||||||
local poison_timer = 0
|
|
||||||
local drunk_timer = 0
|
|
||||||
|
|
||||||
local function stamina_globaltimer(dtime)
|
local function stamina_globaltimer(dtime)
|
||||||
|
|
||||||
|
@ -228,11 +227,13 @@ local function stamina_globaltimer(dtime)
|
||||||
if stamina.players[name]
|
if stamina.players[name]
|
||||||
and stamina.players[name].drunk then
|
and stamina.players[name].drunk then
|
||||||
|
|
||||||
-- play burp sound every 20 seconds when drunk
|
-- play burp sound every 20 seconds when drunk
|
||||||
local num = stamina.players[name].drunk
|
local num = stamina.players[name].drunk
|
||||||
if num and num > 0 and math.floor(num / 20) == num / 20 then
|
|
||||||
minetest.sound_play("stamina_burp", {to_player = name, gain = 0.7}, true)
|
if num and num > 0 and math.floor(num / 20) == num / 20 then
|
||||||
end
|
minetest.sound_play("stamina_burp",
|
||||||
|
{to_player = name, gain = 0.7}, true)
|
||||||
|
end
|
||||||
|
|
||||||
stamina.players[name].drunk = stamina.players[name].drunk - 1
|
stamina.players[name].drunk = stamina.players[name].drunk - 1
|
||||||
|
|
||||||
|
@ -285,7 +286,7 @@ end
|
||||||
and stamina.players[name].poisoned then
|
and stamina.players[name].poisoned then
|
||||||
|
|
||||||
player:hud_change(stamina.players[name].hud_id,
|
player:hud_change(stamina.players[name].hud_id,
|
||||||
"text", "stamina_hud_fg.png")
|
"text", "stamina_hud_fg.png")
|
||||||
|
|
||||||
stamina.players[name].poisoned = nil
|
stamina.players[name].poisoned = nil
|
||||||
end
|
end
|
||||||
|
@ -355,7 +356,7 @@ end
|
||||||
maxsize = 1.0,
|
maxsize = 1.0,
|
||||||
vertical = false,
|
vertical = false,
|
||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
texture = "default_dirt.png",
|
texture = "default_dirt.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -476,8 +477,7 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
|
||||||
elseif hp_change < 0 then
|
elseif hp_change < 0 then
|
||||||
|
|
||||||
-- assume hp_change < 0
|
-- assume hp_change < 0
|
||||||
user:hud_change(stamina.players[name].hud_id, "text",
|
user:hud_change(stamina.players[name].hud_id, "text", "stamina_hud_poison.png")
|
||||||
"stamina_hud_poison.png")
|
|
||||||
|
|
||||||
stamina.players[name].poisoned = -hp_change
|
stamina.players[name].poisoned = -hp_change
|
||||||
end
|
end
|
||||||
|
@ -511,12 +511,14 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
|
||||||
maxexptime = 1,
|
maxexptime = 1,
|
||||||
minsize = 1,
|
minsize = 1,
|
||||||
maxsize = 2,
|
maxsize = 2,
|
||||||
texture = texture,
|
texture = texture
|
||||||
})
|
})
|
||||||
|
|
||||||
-- if player drinks bucket of milk then stop poison and being drunk
|
-- if player drinks milk then stop poison and being drunk
|
||||||
if itemstack:get_name() == "mobs:bucket_milk"
|
local item_name = itemstack:get_name() or ""
|
||||||
or itemstack:get_name() == "mobs:glass_milk" then
|
if item_name == "mobs:bucket_milk"
|
||||||
|
or item_name == "mobs:glass_milk"
|
||||||
|
or item_name == "farming:soy_milk" then
|
||||||
|
|
||||||
stamina.players[name].poisoned = 0
|
stamina.players[name].poisoned = 0
|
||||||
stamina.players[name].drunk = 0
|
stamina.players[name].drunk = 0
|
||||||
|
@ -554,11 +556,11 @@ function stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thin
|
||||||
stamina.players[name].units = 0
|
stamina.players[name].units = 0
|
||||||
|
|
||||||
user:hud_change(stamina.players[name].hud_id, "text",
|
user:hud_change(stamina.players[name].hud_id, "text",
|
||||||
"stamina_hud_poison.png")
|
"stamina_hud_poison.png")
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
minetest.get_color_escape_sequence("#1eff00")
|
minetest.get_color_escape_sequence("#1eff00")
|
||||||
.. "You suddenly feel tipsy!")
|
.. "You suddenly feel tipsy!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -567,8 +569,8 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- stamina is disabled if damage is disabled
|
-- stamina is disabled if damage is disabled
|
||||||
if minetest.setting_getbool("enable_damage")
|
if minetest.settings:get_bool("enable_damage")
|
||||||
and minetest.setting_get("enable_stamina") ~= false then
|
and minetest.settings:get_bool("enable_stamina") ~= false then
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
|
||||||
|
@ -613,8 +615,7 @@ and minetest.setting_get("enable_stamina") ~= false then
|
||||||
|
|
||||||
if stamina.players[name].poisoned
|
if stamina.players[name].poisoned
|
||||||
or stamina.players[name].drunk then
|
or stamina.players[name].drunk then
|
||||||
player:hud_change(stamina.players[name].hud_id,
|
player:hud_change(stamina.players[name].hud_id, "text", "stamina_hud_fg.png")
|
||||||
"text", "stamina_hud_fg.png")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
stamina.players[name].exhaustion = 0
|
stamina.players[name].exhaustion = 0
|
||||||
|
|
7
mods/stamina/settingtypes.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
sprint (Enable sprint) bool true
|
||||||
|
|
||||||
|
sprint_particles (Enable sprint particles) bool true
|
||||||
|
|
||||||
|
enable_stamina (Enable stamina/hunger) bool true
|
||||||
|
|
||||||
|
stamina_tick (Time in seconds after which 1 saturation point is taken) float 800
|
|
@ -898,8 +898,26 @@ local color_button_size = ";0.75,0.75;"
|
||||||
local color_square_size = ";0.69,0.69;"
|
local color_square_size = ";0.69,0.69;"
|
||||||
|
|
||||||
function unifieddyes.make_readable_color(color)
|
function unifieddyes.make_readable_color(color)
|
||||||
local s = string.gsub(color, "_", " ")
|
-- is this a low saturation color?
|
||||||
s = string.gsub(s, "s50", "(low saturation)")
|
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
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -925,7 +943,7 @@ function unifieddyes.make_colored_square(hexcolor, colorname, showall, creative,
|
||||||
end
|
end
|
||||||
|
|
||||||
local tooltip = "tooltip["..colorname..";"..
|
local tooltip = "tooltip["..colorname..";"..
|
||||||
unifieddyes.make_readable_color(colorname)..
|
S(unifieddyes.make_readable_color(colorname))..
|
||||||
"\n(dye:"..colorname..")]"
|
"\n(dye:"..colorname..")]"
|
||||||
|
|
||||||
if dye == painting_with then
|
if dye == painting_with then
|
||||||
|
@ -1103,7 +1121,7 @@ function unifieddyes.show_airbrush_form(player)
|
||||||
t[#t+1] = "label[10.7,"
|
t[#t+1] = "label[10.7,"
|
||||||
t[#t+1] = (vps*5.07+vs)
|
t[#t+1] = (vps*5.07+vs)
|
||||||
t[#t+1] = ";"
|
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] = "]label[10.7,"
|
||||||
t[#t+1] = (vps*5.24+vs)
|
t[#t+1] = (vps*5.24+vs)
|
||||||
t[#t+1] = ";("
|
t[#t+1] = ";("
|
||||||
|
|
|
@ -74,3 +74,18 @@ Magenta Dye (low saturation)=Magenta Farbstoff (geringe Saettigung) lila
|
||||||
Red-violet Dye (low saturation)=Rotvioletter Farbstoff (geringe Saettigung)
|
Red-violet Dye (low saturation)=Rotvioletter Farbstoff (geringe Saettigung)
|
||||||
|
|
||||||
[UnifiedDyes] Loaded!=[UnifiedDyes] geladen!
|
[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)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Credit where credit is due
|
# Credit where credit is due
|
||||||
|
|
||||||
|
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
|
- 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>
|
- <https://forum.minetest.net/viewtopic.php?f=13&t=7407>
|
||||||
- License:
|
- License:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Vehicle Mash [![Build status](https://github.com/minetest-mods/vehicle_mash/workflows/build/badge.svg)](https://github.com/minetest-mods/vehicle_mash/actions) [![ContentDB](https://content.minetest.net/packages/Panquesito7/vehicle_mash/shields/downloads/)](https://content.minetest.net/packages/Panquesito7/vehicle_mash/)
|
# Vehicle Mash [![Build status](https://github.com/minetest-mods/vehicle_mash/workflows/build/badge.svg)](https://github.com/minetest-mods/vehicle_mash/actions) [![ContentDB](https://content.minetest.net/packages/Panquesito7/vehicle_mash/shields/downloads/)](https://content.minetest.net/packages/Panquesito7/vehicle_mash/)
|
||||||
|
|
||||||
- Current version: 2.2.2
|
- Current version: 2.2.2
|
||||||
- By [blert2112](https://github.com/blert2112), and improvements by [Panquesito7](https://github.com/Panquesito7).
|
- By [blert2112](https://github.com/blert2112), and handed over to [Panquesito7](https://github.com/Panquesito7).
|
||||||
|
|
||||||
![Screenshot](https://raw.githubusercontent.com/minetest-mods/vehicle_mash/master/screenshot.png)
|
![Screenshot](https://raw.githubusercontent.com/minetest-mods/vehicle_mash/master/screenshot.png)
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@ For further information or help, see:\
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
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)
|
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.
|
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.
|
||||||
|
|
||||||
|
|
2
setup-mt
|
@ -126,7 +126,7 @@ echo "mg_name = "$mt_mg_name"" >> /home/minetest/.minetest/minetest.conf
|
||||||
echo "protector_hurt = "$mt_protector_hurt"" >> /home/minetest/.minetest/minetest.conf
|
echo "protector_hurt = "$mt_protector_hurt"" >> /home/minetest/.minetest/minetest.conf
|
||||||
echo "protector_flip = "$mt_protector_flip"" >> /home/minetest/.minetest/minetest.conf
|
echo "protector_flip = "$mt_protector_flip"" >> /home/minetest/.minetest/minetest.conf
|
||||||
echo "protector_pvp = "$mt_protector_pvp"" >> /home/minetest/.minetest/minetest.conf
|
echo "protector_pvp = "$mt_protector_pvp"" >> /home/minetest/.minetest/minetest.conf
|
||||||
|
echo "tubelib_machine_aging_value = "$mt_tubelib_machine_aging_value"" >> /home/minetest/.minetest/minetest.conf
|
||||||
|
|
||||||
echo "Fix privileges on /home/minetest"
|
echo "Fix privileges on /home/minetest"
|
||||||
chown minetest:minetest /home/minetest/ -cR
|
chown minetest:minetest /home/minetest/ -cR
|
||||||
|
|