Merge pull request 'develop' (#35) from develop into master
Reviewed-on: #35
|
@ -1,4 +1,4 @@
|
|||
mt_version="5.3.0"
|
||||
mt_version="5.4.0"
|
||||
first_install=y
|
||||
ufw_enable=y
|
||||
ufw_ssh_port_for_accept=22
|
||||
|
|
|
@ -131,11 +131,21 @@ git clone --depth 1 --branch master https://github.com/Dragonop/claycrafter
|
|||
git clone --depth 1 --branch master https://notabug.org/NetherEran/hot_air_balloons.git
|
||||
git clone --branch master https://cheapiesystems.com/git/prefab_redo
|
||||
git clone --branch master https://cheapiesystems.com/git/mail
|
||||
|
||||
git clone --branch master https://gitlab.com/VanessaE/home_workshop_modpack.git
|
||||
git clone --branch master https://git.bananach.space/basic_trains.git
|
||||
|
||||
#Clean git stuff
|
||||
rm -rf $(find . -name .git*)
|
||||
|
||||
#Make some fixes
|
||||
#1
|
||||
if [[ $(grep -R "run_at_every_load = false" homedecor_modpack/homedecor_kitchen/init.lua | wc -l) = 1 ]]
|
||||
then
|
||||
echo "Applying fix for unknown kitchen_cabinet blocks: https://git.my-web.xyz/milan/minetest-mm/issues/34"
|
||||
echo "This fix can be removed after some time"
|
||||
sed -i 's/run_at_every_load = false,/run_at_every_load = true,/' homedecor_modpack/homedecor_kitchen/init.lua
|
||||
fi
|
||||
|
||||
#update skins-db
|
||||
cd skinsdb/updater
|
||||
python3 update_skins.py
|
||||
|
|
30
mods-list
|
@ -1,4 +1,9 @@
|
|||
load_mod_interact = false
|
||||
load_mod_christmas = false
|
||||
load_mod_advtrains_luaautomation = false
|
||||
load_mod_advtrains_interlocking = false
|
||||
load_mod_advtrains_line_automation = false
|
||||
load_mod_advtrains_signals_ks = false
|
||||
load_mod_workbench = true
|
||||
load_mod_wool = true
|
||||
load_mod_wine = true
|
||||
|
@ -35,7 +40,6 @@ load_mod_homedecor_bedroom = true
|
|||
load_mod_homedecor_laundry = true
|
||||
load_mod_blox = true
|
||||
load_mod_homedecor_3d_extras = true
|
||||
load_mod_computer = true
|
||||
load_mod_mymillwork = true
|
||||
load_mod_drinks = true
|
||||
load_mod_angledstairs = true
|
||||
|
@ -43,7 +47,6 @@ load_mod_nature_classic = true
|
|||
load_mod_homedecor_clocks = true
|
||||
load_mod_signs_road = true
|
||||
load_mod_homedecor_cobweb = true
|
||||
load_mod_christmas = true
|
||||
load_mod_along_shore = true
|
||||
load_mod_artdeco = true
|
||||
load_mod_carts = true
|
||||
|
@ -254,19 +257,18 @@ load_mod_abriflame = true
|
|||
load_mod_lpanes = true
|
||||
load_mod_abriglass = true
|
||||
load_mod_advtrains_train_track = true
|
||||
load_mod_advtrains = true
|
||||
load_mod_advtrains_itrainmap = true
|
||||
load_mod_claycrafter = true
|
||||
load_mod_serialize_lib = true
|
||||
load_mod_hot_air_balloons = true
|
||||
load_mod_mobs_bat = true
|
||||
load_mod_home_workshop_machines = true
|
||||
load_mod_home_workshop_common = true
|
||||
load_mod_home_workshop_misc = true
|
||||
load_mod_computers = true
|
||||
load_mod_advtrains_assets = true
|
||||
load_mod_advtrains_train_subway = true
|
||||
load_mod_advtrains_train_japan = true
|
||||
load_mod_advtrains_train_industrial = true
|
||||
load_mod_advtrains_luaautomation = true
|
||||
load_mod_advtrains_interlocking = true
|
||||
load_mod_advtrains = true
|
||||
load_mod_advtrains_train_steam = true
|
||||
load_mod_advtrains_line_automation = true
|
||||
load_mod_advtrains_itrainmap = true
|
||||
load_mod_assets = true
|
||||
load_mod_advtrains_signals_ks = true
|
||||
load_mod_claycrafter = true
|
||||
load_mod_serialize_lib = true
|
||||
load_mod_mobs_sky = true
|
||||
load_mod_hot_air_balloons = true
|
||||
load_mod_mobs_bat = true
|
||||
|
|
|
@ -55,12 +55,14 @@ armor = {
|
|||
crystal = "ethereal:crystal_ingot",
|
||||
},
|
||||
fire_nodes = {
|
||||
{"nether:lava_source", 5, 8},
|
||||
{"default:lava_source", 5, 8},
|
||||
{"default:lava_flowing", 5, 8},
|
||||
{"fire:basic_flame", 3, 4},
|
||||
{"fire:permanent_flame", 3, 4},
|
||||
{"ethereal:crystal_spike", 2, 1},
|
||||
{"ethereal:fire_flower", 2, 1},
|
||||
{"nether:lava_crust", 2, 1},
|
||||
{"default:torch", 1, 1},
|
||||
{"default:torch_ceiling", 1, 1},
|
||||
{"default:torch_wall", 1, 1},
|
||||
|
@ -200,6 +202,10 @@ armor.update_player_visuals = function(self, player)
|
|||
self:run_callbacks("on_update", player)
|
||||
end
|
||||
|
||||
|
||||
-- armor is not visible on player model if enabled
|
||||
local transparent_armor = minetest.settings:get_bool("armor_transparent", false)
|
||||
|
||||
armor.set_player_armor = function(self, player)
|
||||
local name, armor_inv = self:get_valid_player(player, "[set_player_armor]")
|
||||
if not name then
|
||||
|
@ -258,7 +264,9 @@ armor.set_player_armor = function(self, player)
|
|||
tex = tex:gsub(".png$", "")
|
||||
local prev = def.preview or tex.."_preview"
|
||||
prev = prev:gsub(".png$", "")
|
||||
if not transparent_armor then
|
||||
texture = texture.."^"..tex..".png"
|
||||
end
|
||||
preview = preview.."^"..prev..".png"
|
||||
state = state + stack:get_wear()
|
||||
count = count + 1
|
||||
|
@ -521,12 +529,14 @@ armor.remove_all = function(self, player)
|
|||
self:save_armor_inventory(player)
|
||||
end
|
||||
|
||||
local skin_mod
|
||||
|
||||
armor.get_player_skin = function(self, name)
|
||||
if (self.skin_mod == "skins" or self.skin_mod == "simple_skins") and skins.skins[name] then
|
||||
if (skin_mod == "skins" or skin_mod == "simple_skins") and skins.skins[name] then
|
||||
return skins.skins[name]..".png"
|
||||
elseif self.skin_mod == "u_skins" and u_skins.u_skins[name] then
|
||||
elseif skin_mod == "u_skins" and u_skins.u_skins[name] then
|
||||
return u_skins.u_skins[name]..".png"
|
||||
elseif self.skin_mod == "wardrobe" and wardrobe.playerSkins and wardrobe.playerSkins[name] then
|
||||
elseif skin_mod == "wardrobe" and wardrobe.playerSkins and wardrobe.playerSkins[name] then
|
||||
return wardrobe.playerSkins[name]
|
||||
end
|
||||
return armor.default_skin..".png"
|
||||
|
@ -638,17 +648,19 @@ end
|
|||
armor.get_valid_player = function(self, player, msg)
|
||||
msg = msg or ""
|
||||
if not player then
|
||||
minetest.log("warning", S("3d_armor: Player reference is nil @1", msg))
|
||||
minetest.log("warning", ("3d_armor%s: Player reference is nil"):format(msg))
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
if not name then
|
||||
minetest.log("warning", S("3d_armor: Player name is nil @1", msg))
|
||||
minetest.log("warning", ("3d_armor%s: Player name is nil"):format(msg))
|
||||
return
|
||||
end
|
||||
local inv = minetest.get_inventory({type="detached", name=name.."_armor"})
|
||||
if not inv then
|
||||
minetest.log("warning", S("3d_armor: Detached armor inventory is nil @1", msg))
|
||||
-- This check may fail when called inside `on_joinplayer`
|
||||
-- in that case, the armor will be initialized/updated later on
|
||||
minetest.log("warning", ("3d_armor%s: Detached armor inventory is nil"):format(msg))
|
||||
return
|
||||
end
|
||||
return name, inv
|
||||
|
@ -663,3 +675,10 @@ armor.drop_armor = function(pos, stack)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Allows skin mod to be set manually.
|
||||
--
|
||||
-- Useful for skin mod forks that do not use the same name.
|
||||
armor.set_skin_mod = function(mod)
|
||||
skin_mod = mod
|
||||
end
|
||||
|
|
|
@ -96,7 +96,7 @@ for _, mod in pairs(skin_mods) do
|
|||
armor:add_preview(fn)
|
||||
end
|
||||
end
|
||||
armor.skin_mod = mod
|
||||
armor.set_skin_mod(mod)
|
||||
end
|
||||
end
|
||||
if not minetest.get_modpath("moreores") then
|
||||
|
@ -331,6 +331,7 @@ minetest.register_on_joinplayer(function(player)
|
|||
local player_name = player:get_player_name()
|
||||
|
||||
minetest.after(0, function()
|
||||
-- TODO: Added in 7566ecc - What's the prupose?
|
||||
local pplayer = minetest.get_player_by_name(player_name)
|
||||
if pplayer and init_player_armor(pplayer) == false then
|
||||
pending_players[pplayer] = 0
|
||||
|
|
Before Width: | Height: | Size: 8.9 KiB |
7
mods/3d_armor/3d_armor_sfinv/locale/3d_armor_sfinv.es.tr
Normal file
|
@ -0,0 +1,7 @@
|
|||
# textdomain: 3d_armor_sfinv
|
||||
|
||||
|
||||
### init.lua ###
|
||||
|
||||
3d_armor_sfinv: Mod loaded but unused.=3d_armor_sfinv : Mod cargado pero no activado.
|
||||
Armor=Armadura
|
|
@ -153,6 +153,7 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
|||
drawtype = "mesh",
|
||||
mesh = "3d_armor_stand.obj",
|
||||
tiles = {"3d_armor_stand.png"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = false,
|
||||
|
@ -221,6 +222,7 @@ minetest.register_node("3d_armor_stand:locked_armor_stand", {
|
|||
drawtype = "mesh",
|
||||
mesh = "3d_armor_stand.obj",
|
||||
tiles = {"3d_armor_stand_locked.png"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = false,
|
||||
|
|
|
@ -4,11 +4,12 @@ local F = minetest.formspec_escape
|
|||
local has_technic = minetest.get_modpath("technic") ~= nil
|
||||
|
||||
if not minetest.global_exists("unified_inventory") then
|
||||
minetest.log("warning", S("3d_armor_ui: Mod loaded but unused."))
|
||||
minetest.log("warning", "3d_armor_ui: Mod loaded but unused.")
|
||||
return
|
||||
end
|
||||
|
||||
if unified_inventory.sfinv_compat_layer then
|
||||
local ui = unified_inventory
|
||||
if ui.sfinv_compat_layer then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -27,25 +28,32 @@ unified_inventory.register_button("armor", {
|
|||
|
||||
unified_inventory.register_page("armor", {
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local fy = perplayer_formspec.formspec_y
|
||||
local fy = perplayer_formspec.form_header_y + 0.5
|
||||
local gridx = perplayer_formspec.std_inv_x
|
||||
local gridy = 0.6
|
||||
|
||||
local name = player:get_player_name()
|
||||
if armor.def[name].init_time == 0 then
|
||||
return {formspec="label[0,0;"..F(S("Armor not initialized!")).."]"}
|
||||
end
|
||||
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"..
|
||||
"label[0,0;"..F(S("Armor")).."]"..
|
||||
"list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"..
|
||||
"image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
||||
"label[5.0,"..(fy + 0.0)..";"..F(S("Level"))..": "..armor.def[name].level.."]"..
|
||||
"label[5.0,"..(fy + 0.5)..";"..F(S("Heal"))..": "..armor.def[name].heal.."]"..
|
||||
local formspec = perplayer_formspec.standard_inv_bg..
|
||||
perplayer_formspec.standard_inv..
|
||||
ui.make_inv_img_grid(gridx, gridy, 2, 3)..
|
||||
string.format("label[%f,%f;%s]",
|
||||
perplayer_formspec.form_header_x, perplayer_formspec.form_header_y, F(S("Armor")))..
|
||||
string.format("list[detached:%s_armor;armor;%f,%f;2,3;]",
|
||||
name, gridx + ui.list_img_offset, gridy + ui.list_img_offset) ..
|
||||
"image[3.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
||||
"label[6.0,"..(fy + 0.0)..";"..F(S("Level"))..": "..armor.def[name].level.."]"..
|
||||
"label[6.0,"..(fy + 0.5)..";"..F(S("Heal"))..": "..armor.def[name].heal.."]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[detached:"..name.."_armor;armor]"
|
||||
if armor.config.fire_protect then
|
||||
formspec = formspec.."label[5.0,"..(fy + 1.0)..";"..
|
||||
formspec = formspec.."label[6.0,"..(fy + 1.0)..";"..
|
||||
F(S("Fire"))..": "..armor.def[name].fire.."]"
|
||||
end
|
||||
if has_technic then
|
||||
formspec = formspec.."label[5.0,"..(fy + 1.5)..";"..
|
||||
formspec = formspec.."label[6.0,"..(fy + 1.5)..";"..
|
||||
F(S("Radiation"))..": "..armor.def[name].groups["radiation"].."]"
|
||||
end
|
||||
return {formspec=formspec}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
### init.lua ###
|
||||
|
||||
3d Armor=Armure 3d
|
||||
3d_armor_ui: Mod loaded but unused.=3d_armor_ui : Mod chargé mais inutilisé.
|
||||
Armor=Armure
|
||||
Armor not initialized!=Armure non initialisée !
|
||||
Fire=Feu
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
### init.lua ###
|
||||
|
||||
3d Armor=
|
||||
3d_armor_ui: Mod loaded but unused.=
|
||||
Armor=
|
||||
Armor not initialized!=
|
||||
Fire=
|
||||
|
|
|
@ -2,3 +2,4 @@ name = 3d_armor_ui
|
|||
depends = 3d_armor
|
||||
optional_depends = unified_inventory
|
||||
description = Adds 3d_armor page to the unified inventory.
|
||||
min_minetest_version = 5.4.0
|
||||
|
|
|
@ -58,6 +58,9 @@ armor_punch_damage (Enable damage effects) bool true
|
|||
# Enable migration of old armor inventories.
|
||||
armor_migrate_old_inventory (Migrate old armor inventories) bool true
|
||||
|
||||
# Don't show armor on character model.
|
||||
armor_transparent (Transparent armor) bool false
|
||||
|
||||
|
||||
[shields]
|
||||
|
||||
|
|
|
@ -69,12 +69,12 @@ end
|
|||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
wieldview.wielded_item[name] = ""
|
||||
minetest.after(0, function()
|
||||
local pplayer = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
minetest.after(0, function(pname)
|
||||
local pplayer = minetest.get_player_by_name(pname)
|
||||
if pplayer then
|
||||
wieldview:update_wielded_item(pplayer)
|
||||
end
|
||||
end)
|
||||
end, name)
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
|
|
@ -640,10 +640,34 @@ function worldedit.clear_objects(pos1, pos2)
|
|||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local function should_delete(obj)
|
||||
-- Avoid players and WorldEdit entities
|
||||
if obj:is_player() then
|
||||
return false
|
||||
end
|
||||
local entity = obj:get_luaentity()
|
||||
return not entity or not entity.name:find("^worldedit:")
|
||||
end
|
||||
|
||||
-- Offset positions to include full nodes (positions are in the center of nodes)
|
||||
local pos1x, pos1y, pos1z = pos1.x - 0.5, pos1.y - 0.5, pos1.z - 0.5
|
||||
local pos2x, pos2y, pos2z = pos2.x + 0.5, pos2.y + 0.5, pos2.z + 0.5
|
||||
|
||||
local count = 0
|
||||
if minetest.get_objects_in_area then
|
||||
local objects = minetest.get_objects_in_area({x=pos1x, y=pos1y, z=pos1z},
|
||||
{x=pos2x, y=pos2y, z=pos2z})
|
||||
|
||||
for _, obj in pairs(objects) do
|
||||
if should_delete(obj) then
|
||||
obj:remove()
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Fallback implementation via get_objects_inside_radius
|
||||
-- Center of region
|
||||
local center = {
|
||||
x = pos1x + ((pos2x - pos1x) / 2),
|
||||
|
@ -655,12 +679,8 @@ function worldedit.clear_objects(pos1, pos2)
|
|||
(center.x - pos1x) ^ 2 +
|
||||
(center.y - pos1y) ^ 2 +
|
||||
(center.z - pos1z) ^ 2)
|
||||
local count = 0
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(center, radius)) do
|
||||
local entity = obj:get_luaentity()
|
||||
-- Avoid players and WorldEdit entities
|
||||
if not obj:is_player() and (not entity or
|
||||
not entity.name:find("^worldedit:")) then
|
||||
if should_delete(obj) then
|
||||
local pos = obj:get_pos()
|
||||
if pos.x >= pos1x and pos.x <= pos2x and
|
||||
pos.y >= pos1y and pos.y <= pos2y and
|
||||
|
|
|
@ -11,6 +11,7 @@ local gui_count2 = {} --mapping of player names to a quantity (arbitrary strings
|
|||
local gui_count3 = {} --mapping of player names to a quantity (arbitrary strings may also appear as values)
|
||||
local gui_angle = {} --mapping of player names to an angle (one of 90, 180, 270, representing the angle in degrees clockwise)
|
||||
local gui_filename = {} --mapping of player names to file names
|
||||
local gui_param2 = {} --mapping of player names to param2 values
|
||||
|
||||
--set default values
|
||||
setmetatable(gui_nodename1, {__index = function() return "Cobblestone" end})
|
||||
|
@ -25,6 +26,7 @@ setmetatable(gui_count2, {__index = function() return "6" end})
|
|||
setmetatable(gui_count3, {__index = function() return "4" end})
|
||||
setmetatable(gui_angle, {__index = function() return 90 end})
|
||||
setmetatable(gui_filename, {__index = function() return "building" end})
|
||||
setmetatable(gui_param2, {__index = function() return "0" end})
|
||||
|
||||
local axis_indices = {["X axis"]=1, ["Y axis"]=2, ["Z axis"]=3, ["Look direction"]=4}
|
||||
local axis_values = {"x", "y", "z", "?"}
|
||||
|
@ -904,3 +906,31 @@ worldedit.register_gui_function("worldedit_gui_clearobjects", {
|
|||
execute_worldedit_command("clearobjects", name, "")
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_function("worldedit_gui_param2", {
|
||||
name = "Set Param2",
|
||||
privs = we_privs("param2"),
|
||||
get_formspec = function(name)
|
||||
local value = gui_param2[name] or "0"
|
||||
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_param2") ..
|
||||
"textarea[0.5,1;5,2;;;Some values may break the node!]"..
|
||||
string.format("field[0.5,2.5;2,0.8;worldedit_gui_param2_value;New Param2;%s]", minetest.formspec_escape(value)) ..
|
||||
"field_close_on_enter[worldedit_gui_param2_value;false]" ..
|
||||
"button_exit[3.5,2.5;3,0.8;worldedit_gui_param2_submit;Set Param2]"
|
||||
end,
|
||||
})
|
||||
|
||||
worldedit.register_gui_handler("worldedit_gui_param2", function(name, fields)
|
||||
local cg = {
|
||||
worldedit_gui_param2_value = gui_param2,
|
||||
}
|
||||
local ret = handle_changes(name, "worldedit_gui_param2", fields, cg)
|
||||
if fields.worldedit_gui_param2_submit then
|
||||
copy_changes(name, fields, cg)
|
||||
worldedit.show_page(name, "worldedit_gui_param2")
|
||||
|
||||
execute_worldedit_command("param2", name, gui_param2[name])
|
||||
return true
|
||||
end
|
||||
return ret
|
||||
end)
|
||||
|
|
|
@ -174,12 +174,16 @@ function atc.get_atc_controller_formspec(pos, meta)
|
|||
local formspec="size[8,6]"
|
||||
-- "dropdown[0,0;3;mode;static,mesecon,digiline;"..mode.."]"
|
||||
if mode<3 then
|
||||
formspec=formspec.."field[0.5,1.5;7,1;command;"..attrans("Command")..";"..minetest.formspec_escape(command).."]"
|
||||
formspec=formspec
|
||||
.."style[command;font=mono]"
|
||||
.."field[0.8,1.5;7,1;command;"..attrans("Command")..";"..minetest.formspec_escape(command).."]"
|
||||
if tonumber(mode)==2 then
|
||||
formspec=formspec.."field[0.5,3;7,1;command_on;"..attrans("Command (on)")..";"..minetest.formspec_escape(command_on).."]"
|
||||
formspec=formspec
|
||||
.."style[command_on;font=mono]"
|
||||
.."field[0.8,3;7,1;command_on;"..attrans("Command (on)")..";"..minetest.formspec_escape(command_on).."]"
|
||||
end
|
||||
else
|
||||
formspec=formspec.."field[0.5,1.5;7,1;channel;"..attrans("Digiline channel")..";"..minetest.formspec_escape(channel).."]"
|
||||
formspec=formspec.."field[0.8,1.5;7,1;channel;"..attrans("Digiline channel")..";"..minetest.formspec_escape(channel).."]"
|
||||
end
|
||||
return formspec.."button_exit[0.5,4.5;7,1;save;"..attrans("Save").."]"
|
||||
end
|
||||
|
|
|
@ -1,14 +1,290 @@
|
|||
--couple.lua
|
||||
--defines couple entities.
|
||||
--Handles coupling and discoupling of trains, and defines the coupling entities
|
||||
--Rework June 2021 - some functions from trainlogic.lua have been moved here
|
||||
|
||||
--advtrains:discouple
|
||||
--set into existing trains to split them when punched.
|
||||
--they are attached to the wagons.
|
||||
--[[fields
|
||||
wagon
|
||||
-- COUPLING --
|
||||
-- During coupling rework, the behavior of coupling was changed to make automation easier. It is now as follows:
|
||||
-- Coupling is only ever initiated when a train is standing somewhere (not moving) and another train drives onto one of its ends
|
||||
-- with a speed greater than 0
|
||||
-- "stationary" train is the one standing there - in old code called "train2"
|
||||
-- "initiating" train is the one that approached it and bumped into it - typically an engine - in old code called "train1"
|
||||
-- When the initiating train has autocouple set, trains are immediately coupled
|
||||
-- When not, a couple entity is spawned and coupling commences on click
|
||||
-- Coupling MUST preserve the train ID of the initiating train, so it is done like this:
|
||||
-- initiating train is reversed
|
||||
-- stationary train is reversed if required, so that it points towards the initiating train
|
||||
-- do_connect_trains(initiating, stationary)
|
||||
-- As a result, the coupled train is reversed in direction. Alternative way of doing things (might be considered later):
|
||||
-- stationary train is reversed if required, so that it points away from the initiating train
|
||||
-- index of initiating train is set so that it matches the front pos of stationary train
|
||||
-- wagons of stationary train are inserted at the beginning of initiating train
|
||||
-- remove stationary train
|
||||
|
||||
wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near
|
||||
]]
|
||||
-- train.couple_* contain references to ObjectRefs of couple objects, which contain all relevant information
|
||||
-- These objectRefs will delete themselves once the couples no longer match (see below)
|
||||
local function create_couple_entity(pos, train1, t1_is_front, train2, t2_is_front)
|
||||
local id1 = train1.id
|
||||
local id2 = train2.id
|
||||
|
||||
-- delete previous couple entities
|
||||
if t1_is_front then
|
||||
if train1.cpl_front then train1.cpl_front:remove() end
|
||||
else
|
||||
if train1.cpl_back then train1.cpl_back:remove() end
|
||||
end
|
||||
if t2_is_front then
|
||||
if train2.cpl_front then train2.cpl_front:remove() end
|
||||
else
|
||||
if train2.cpl_back then train2.cpl_back:remove() end
|
||||
end
|
||||
|
||||
local obj=minetest.add_entity(pos, "advtrains:couple")
|
||||
if not obj then error("Failed creating couple object!") return end
|
||||
local le=obj:get_luaentity()
|
||||
le.train_id_1=id1
|
||||
le.t1_is_front=t1_is_front
|
||||
le.train_id_2=id2
|
||||
le.t2_is_front=t2_is_front
|
||||
--atdebug("created couple between",train1.id,train2.id,t2_is_front)
|
||||
|
||||
if t1_is_front then
|
||||
train1.cpl_front = obj
|
||||
else
|
||||
train2.cpl_back = obj
|
||||
end
|
||||
if t2_is_front then
|
||||
train2.cpl_front = obj
|
||||
else
|
||||
train2.cpl_back = obj
|
||||
end
|
||||
end
|
||||
|
||||
-- Old static couple checking. Never used for autocouple, only used for standing trains if train did not approach
|
||||
local CPL_CHK_DST = -1
|
||||
local CPL_ZONE = 2
|
||||
function advtrains.train_check_couples(train)
|
||||
--atdebug("rechecking couples")
|
||||
if train.cpl_front then
|
||||
if not train.cpl_front:get_yaw() then
|
||||
-- objectref is no longer valid. reset.
|
||||
train.cpl_front = nil
|
||||
end
|
||||
end
|
||||
if not train.cpl_front then
|
||||
-- recheck front couple
|
||||
local front_trains, pos = advtrains.occ.get_occupations(train, atround(train.index) + CPL_CHK_DST)
|
||||
if advtrains.is_node_loaded(pos) then -- if the position is loaded...
|
||||
for tid, idx in pairs(front_trains) do
|
||||
local other_train = advtrains.trains[tid]
|
||||
if not advtrains.train_ensure_init(tid, other_train) then
|
||||
atwarn("Train",tid,"is not initialized! Couldn't check couples!")
|
||||
return
|
||||
end
|
||||
--atdebug(train.id,"front: ",idx,"on",tid,atround(other_train.index),atround(other_train.end_index))
|
||||
if other_train.velocity == 0 then
|
||||
if idx>=other_train.index and idx<=other_train.index + CPL_ZONE then
|
||||
create_couple_entity(pos, train, true, other_train, true)
|
||||
break
|
||||
end
|
||||
if idx<=other_train.end_index and idx>=other_train.end_index - CPL_ZONE then
|
||||
create_couple_entity(pos, train, true, other_train, false)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if train.cpl_back then
|
||||
if not train.cpl_back:get_yaw() then
|
||||
-- objectref is no longer valid. reset.
|
||||
train.cpl_back = nil
|
||||
end
|
||||
end
|
||||
if not train.cpl_back then
|
||||
-- recheck back couple
|
||||
local back_trains, pos = advtrains.occ.get_occupations(train, atround(train.end_index) - CPL_CHK_DST)
|
||||
if advtrains.is_node_loaded(pos) then -- if the position is loaded...
|
||||
for tid, idx in pairs(back_trains) do
|
||||
local other_train = advtrains.trains[tid]
|
||||
if not advtrains.train_ensure_init(tid, other_train) then
|
||||
atwarn("Train",tid,"is not initialized! Couldn't check couples!")
|
||||
return
|
||||
end
|
||||
--atdebug(train.id,"back: ",idx,"on",tid,atround(other_train.index),atround(other_train.end_index))
|
||||
if other_train.velocity == 0 then
|
||||
if idx>=other_train.index and idx<=other_train.index + CPL_ZONE then
|
||||
create_couple_entity(pos, train, false, other_train, true)
|
||||
break
|
||||
end
|
||||
if idx<=other_train.end_index and idx>=other_train.end_index - CPL_ZONE then
|
||||
create_couple_entity(pos, train, false, other_train, false)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Deletes couple entities from the train
|
||||
function advtrains.couple_invalidate(train)
|
||||
if train.cpl_back then
|
||||
train.cpl_back:remove()
|
||||
train.cpl_back = nil
|
||||
end
|
||||
if train.cpl_front then
|
||||
train.cpl_front:remove()
|
||||
train.cpl_front = nil
|
||||
end
|
||||
train.couples_up_to_date = nil
|
||||
end
|
||||
|
||||
-- Called from train_step_b() when the current train (init_train) just stopped at one of the end indices of another train (stat_train)
|
||||
-- Depending on autocouple, either couples immediately or spawns a couple entity
|
||||
function advtrains.couple_initiate_with(init_train, stat_train, stat_is_front)
|
||||
--atdebug("Initiating couplign between init=",init_train.id,"stat=",stat_train.id,"backside=",stat_is_backside)
|
||||
if init_train.autocouple then
|
||||
advtrains.couple_trains(init_train, true, stat_train, stat_is_front)
|
||||
else
|
||||
local pos = advtrains.path_get_interpolated(init_train, init_train.index)
|
||||
create_couple_entity(pos, init_train, true, stat_train, stat_is_front)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- check if the player has permission for the first/last wagon of the train
|
||||
local function check_twagon_owner(train, b_first, pname)
|
||||
local wtp = b_first and 1 or #train.trainparts
|
||||
local wid = train.trainparts[wtp]
|
||||
local wdata = advtrains.wagons[wid]
|
||||
if wdata then
|
||||
return advtrains.check_driving_couple_protection(pname, wdata.owner, wdata.whitelist)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Perform coupling, but check if the player is authorized to couple
|
||||
function advtrains.safe_couple_trains(train1, t1_is_front, train2, t2_is_front, pname)
|
||||
|
||||
if pname and not minetest.check_player_privs(pname, "train_operator") then
|
||||
minetest.chat_send_player(pname, "Missing train_operator privilege")
|
||||
return false
|
||||
end
|
||||
|
||||
local wck_t1, wck_t2
|
||||
if pname then
|
||||
wck_t1 = check_twagon_owner(train1, t1_is_front, pname)
|
||||
wck_t2 = check_twagon_owner(train2, t2_is_front, pname)
|
||||
end
|
||||
if (wck_t1 or wck_t2) or not pname then
|
||||
advtrains.couple_trains(train1, t1_is_front, train2, t2_is_front)
|
||||
end
|
||||
end
|
||||
|
||||
-- Actually performs the train coupling. Always retains train ID of train1
|
||||
function advtrains.couple_trains(train1, t1_is_front, train2, t2_is_front)
|
||||
--atdebug("Couple trains init=",init_train.id,"stat=",stat_train.id,"statreverse=",stat_must_reverse)
|
||||
-- see comment on top of file
|
||||
if t1_is_front then
|
||||
advtrains.invert_train(train1.id)
|
||||
end
|
||||
if not t2_is_front then
|
||||
advtrains.invert_train(train2.id)
|
||||
end
|
||||
|
||||
advtrains.do_connect_trains(train1, train2)
|
||||
end
|
||||
|
||||
-- Adds the wagons of first to second and deletes second_id afterwards
|
||||
-- Assumes that second_id stands right behind first_id and both trains point to the same direction
|
||||
function advtrains.do_connect_trains(first, second)
|
||||
|
||||
if not advtrains.train_ensure_init(first.id, first) then
|
||||
atwarn("Coupling: first train",first.id,"is not initialized! Operation aborted!")
|
||||
return
|
||||
end
|
||||
if not advtrains.train_ensure_init(second.id, second) then
|
||||
atwarn("Coupling: second train",second.id,"is not initialized! Operation aborted!")
|
||||
return
|
||||
end
|
||||
|
||||
local first_wagoncnt=#first.trainparts
|
||||
local second_wagoncnt=#second.trainparts
|
||||
|
||||
for _,v in ipairs(second.trainparts) do
|
||||
table.insert(first.trainparts, v)
|
||||
end
|
||||
|
||||
advtrains.remove_train(second.id)
|
||||
|
||||
first.velocity = 0
|
||||
|
||||
advtrains.update_trainpart_properties(first.id)
|
||||
advtrains.couple_invalidate(first)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- DECOUPLING --
|
||||
function advtrains.split_train_at_fc(train, count_empty, length_limit)
|
||||
-- splits train at first different current FC by convention,
|
||||
-- locomotives have empty FC so are ignored
|
||||
-- count_empty is used to split off locomotives
|
||||
-- length_limit limits the length of the first train to length_limit wagons
|
||||
local train_id = train.id
|
||||
local fc = false
|
||||
local ind = 0
|
||||
for i = 1, #train.trainparts do
|
||||
local w_id = train.trainparts[i]
|
||||
local data = advtrains.wagons[w_id]
|
||||
if length_limit and i > length_limit then
|
||||
ind = i
|
||||
break
|
||||
end
|
||||
if data then
|
||||
local wfc = advtrains.get_cur_fc(data)
|
||||
if wfc ~= "" or count_empty then
|
||||
if fc then
|
||||
if fc ~= wfc then
|
||||
ind = i
|
||||
break
|
||||
end
|
||||
else
|
||||
fc = wfc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if ind > 0 then
|
||||
return advtrains.split_train_at_index(train, ind), fc
|
||||
end
|
||||
if fc then
|
||||
return nil, fc
|
||||
end
|
||||
end
|
||||
|
||||
function advtrains.train_step_fc(train)
|
||||
for i=1,#train.trainparts do
|
||||
local w_id = train.trainparts[i]
|
||||
local data = advtrains.wagons[w_id]
|
||||
if data then
|
||||
advtrains.step_fc(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- split_train_at_index() is in trainlogic.lua because it needs access to two local functions
|
||||
|
||||
function advtrains.split_train_at_wagon(wagon_id)
|
||||
--get train
|
||||
local data = advtrains.wagons[wagon_id]
|
||||
advtrains.split_train_at_index(advtrains.trains[data.train_id], data.pos_in_trainparts)
|
||||
end
|
||||
|
||||
|
||||
-- COUPLE ENTITIES --
|
||||
|
||||
local couple_max_dist=3
|
||||
|
||||
|
@ -36,8 +312,6 @@ minetest.register_entity("advtrains:discouple", {
|
|||
if pname and pname~="" and self.wagon then
|
||||
if advtrains.safe_decouple_wagon(self.wagon.id, pname) then
|
||||
self.object:remove()
|
||||
else
|
||||
minetest.add_entity(self.object:getpos(), "advtrains:lockmarker")
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
@ -60,10 +334,6 @@ minetest.register_entity("advtrains:discouple", {
|
|||
|
||||
-- advtrains:couple
|
||||
-- Couple entity
|
||||
local function lockmarker(obj)
|
||||
minetest.add_entity(obj:get_pos(), "advtrains:lockmarker")
|
||||
obj:remove()
|
||||
end
|
||||
|
||||
minetest.register_entity("advtrains:couple", {
|
||||
visual="sprite",
|
||||
|
@ -77,7 +347,7 @@ minetest.register_entity("advtrains:couple", {
|
|||
on_activate=function(self, staticdata)
|
||||
if staticdata=="COUPLE" then
|
||||
--couple entities have no right to exist further...
|
||||
atprint("Couple loaded from staticdata, destroying")
|
||||
--atdebug("Couple loaded from staticdata, destroying")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
@ -90,42 +360,34 @@ minetest.register_entity("advtrains:couple", {
|
|||
local pname=clicker
|
||||
if type(clicker)~="string" then pname=clicker:get_player_name() end
|
||||
|
||||
if advtrains.safe_couple_trains(self.train_id_1, self.train_id_2, self.t1_is_front, self.t2_is_front, pname) then
|
||||
local train1=advtrains.trains[self.train_id_1]
|
||||
local train2=advtrains.trains[self.train_id_2]
|
||||
|
||||
advtrains.safe_couple_trains(train1, self.t1_is_front, train2, self.t2_is_front, pname)
|
||||
self.object:remove()
|
||||
else
|
||||
lockmarker(self.object)
|
||||
end
|
||||
end,
|
||||
on_step=function(self, dtime)
|
||||
if advtrains.wagon_outside_range(self.object:getpos()) then
|
||||
--atdebug("Couple Removing outside range")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
if not self.train_id_1 or not self.train_id_2 then atprint("Couple: train ids not set!") self.object:remove() return end
|
||||
if not self.train_id_1 or not self.train_id_2 then
|
||||
--atdebug("Couple Removing ids missing")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local train1=advtrains.trains[self.train_id_1]
|
||||
local train2=advtrains.trains[self.train_id_2]
|
||||
if not train1 or not train2 then
|
||||
atprint("Couple: trains missing, destroying")
|
||||
--atdebug("Couple Removing trains missing")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
--shh, silence here, this is an on-step callback!
|
||||
if not advtrains.train_ensure_init(self.train_id_1, train1) then
|
||||
--atwarn("Train",self.train_id_1,"is not initialized! Operation aborted!")
|
||||
return
|
||||
end
|
||||
if not advtrains.train_ensure_init(self.train_id_2, train2) then
|
||||
--atwarn("Train",self.train_id_2,"is not initialized! Operation aborted!")
|
||||
return
|
||||
end
|
||||
|
||||
if train1.velocity>0 or train2.velocity>0 then
|
||||
if not self.position_set then --ensures that train stands a single time before check fires. Using flag below
|
||||
return
|
||||
end
|
||||
atprint("Couple: train is moving, destroying")
|
||||
if self.position_set and train1.velocity>0 or train2.velocity>0 then
|
||||
--atdebug("Couple: train is moving, destroying")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
@ -149,34 +411,5 @@ minetest.register_entity("advtrains:couple", {
|
|||
end
|
||||
self.position_set=true
|
||||
end
|
||||
atprintbm("couple step", t)
|
||||
advtrains.atprint_context_tid=nil
|
||||
end,
|
||||
})
|
||||
minetest.register_entity("advtrains:lockmarker", {
|
||||
visual="sprite",
|
||||
textures = {"advtrains_cpl_lock.png"},
|
||||
collisionbox = {-0.3,-0.3,-0.3, 0.3,0.3,0.3},
|
||||
visual_size = {x=0.7, y=0.7},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
|
||||
is_lockmarker=true,
|
||||
static_save = false,
|
||||
on_activate=function(self, staticdata)
|
||||
if staticdata=="COUPLE" then
|
||||
--couple entities have no right to exist further...
|
||||
atprint("Couple loaded from staticdata, destroying")
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.object:set_armor_groups({immmortal=1})
|
||||
self.life=5
|
||||
end,
|
||||
get_staticdata=function(self) return "COUPLE" end,
|
||||
on_step=function(self, dtime)
|
||||
self.life=(self.life or 5)-dtime
|
||||
if self.life<0 then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
default
|
||||
serialize_lib
|
||||
mesecons?
|
||||
digtron?
|
|
@ -569,11 +569,13 @@ advtrains.mainloop_runcnt=0
|
|||
advtrains.global_slowdown = 1
|
||||
|
||||
local t = 0
|
||||
local within_mainstep = false
|
||||
minetest.register_globalstep(function(dtime_mt)
|
||||
if no_action then
|
||||
-- the advtrains globalstep is skipped by command. Return immediately
|
||||
return
|
||||
end
|
||||
within_mainstep = true
|
||||
|
||||
advtrains.mainloop_runcnt=advtrains.mainloop_runcnt+1
|
||||
--atprint("Running the main loop, runcnt",advtrains.mainloop_runcnt)
|
||||
|
@ -586,6 +588,7 @@ minetest.register_globalstep(function(dtime_mt)
|
|||
if GENERATE_ATRICIFIAL_LAG then
|
||||
dtime = HOW_MANY_LAG
|
||||
if os.clock()<t then
|
||||
within_mainstep = false
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -626,6 +629,9 @@ minetest.register_globalstep(function(dtime_mt)
|
|||
save_timer = advtrains.SAVE_INTERVAL
|
||||
atprintbm("saving", t)
|
||||
end
|
||||
|
||||
within_mainstep = false
|
||||
|
||||
end)
|
||||
|
||||
--if something goes wrong in these functions, there is no help. no pcall here.
|
||||
|
@ -678,7 +684,13 @@ function advtrains.save(remove_players_from_wagons)
|
|||
--TODO very simple yet hacky workaround for the "green signals" bug
|
||||
advtrains.invalidate_all_paths()
|
||||
end
|
||||
minetest.register_on_shutdown(advtrains.save)
|
||||
minetest.register_on_shutdown(function()
|
||||
if within_mainstep then
|
||||
atwarn("Crash during advtrains main step - skipping the shutdown save operation to not save inconsistent data!")
|
||||
else
|
||||
advtrains.save()
|
||||
end
|
||||
end)
|
||||
|
||||
-- This chat command provides a solution to the problem known on the LinuxWorks server
|
||||
-- There are many players that joined a single time, got on a train and then left forever
|
||||
|
@ -706,6 +718,20 @@ minetest.register_chatcommand("at_reroute",
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("at_whereis",
|
||||
{
|
||||
params = "<train id>",
|
||||
description = "Returns the position of the train with the given id",
|
||||
privs = {train_operator = true},
|
||||
func = function(name,param)
|
||||
local train = advtrains.trains[param]
|
||||
if not train or not train.last_pos then
|
||||
return false, "Train "..param.." does not exist or is invalid"
|
||||
else
|
||||
return true, "Train "..param.." is at "..minetest.pos_to_string(train.last_pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("at_disable_step",
|
||||
{
|
||||
params = "<yes/no>",
|
||||
|
|
|
@ -66,6 +66,7 @@ Subway Passenger Wagon=U-Bahn-Waggon
|
|||
The wagon's inventory is not empty!=Das Inventar dieses Waggons ist nicht leer!
|
||||
This track can not be changed!=Diese Schiene kann nicht geändert werden!
|
||||
This track can not be rotated!=Diese Schiene kann nicht gedreht werden!
|
||||
This track can not be removed!=Diese Schiene kann nicht entfernt werden!
|
||||
Position is occupied by a train.=Ein Zug steht an dieser Position.
|
||||
There's a Track Circuit Break here.=Hier ist eine Gleisabschnittsgrenze (TCB).
|
||||
There's a Signal Influence Point here.=Hier ist ein Signal-Beeinflussungspunkt.
|
||||
|
|
|
@ -16,7 +16,7 @@ function advtrains.register_platform(modprefix, preset)
|
|||
description = attrans("@1 Platform (low)", desc),
|
||||
tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex},
|
||||
groups = {cracky = 1, not_blocking_trains = 1, platform=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sounds = ndef.sounds,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
|
@ -33,7 +33,7 @@ function advtrains.register_platform(modprefix, preset)
|
|||
description = attrans("@1 Platform (high)", desc),
|
||||
tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex},
|
||||
groups = {cracky = 1, not_blocking_trains = 1, platform=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sounds = ndef.sounds,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
|
@ -58,7 +58,7 @@ function advtrains.register_platform(modprefix, preset)
|
|||
minetest.register_node(modprefix..":platform_45_"..nodename, {
|
||||
description = attrans("@1 Platform (45 degree)", desc),
|
||||
groups = {cracky = 1, not_blocking_trains = 1, platform=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sounds = ndef.sounds,
|
||||
drawtype = "mesh",
|
||||
mesh = "advtrains_platform_diag.b3d",
|
||||
selection_box = diagonalbox,
|
||||
|
@ -80,7 +80,7 @@ function advtrains.register_platform(modprefix, preset)
|
|||
minetest.register_node(modprefix..":platform_45_low_"..nodename, {
|
||||
description = attrans("@1 Platform (low, 45 degree)", desc),
|
||||
groups = {cracky = 1, not_blocking_trains = 1, platform=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sounds = ndef.sounds,
|
||||
drawtype = "mesh",
|
||||
mesh = "advtrains_platform_diag_low.b3d",
|
||||
selection_box = diagonalbox_low,
|
||||
|
|
7
mods/advtrains/advtrains/mod.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
name=advtrains
|
||||
title=Advanced Trains Core
|
||||
description=Core system for realistic trains in Minetest
|
||||
author=orwell96
|
||||
|
||||
depends=serialize_lib
|
||||
optional_depends=mesecons,mesecons_switch,digtron
|
|
@ -116,6 +116,8 @@ function ndb.load_callback(file)
|
|||
local stid_byte = file:read(2)
|
||||
local stid = bytes_to_int(stid_byte)
|
||||
local stna = file:read("*l")
|
||||
-- possibly windows fix: strip trailing \r's from line
|
||||
stna = string.gsub(stna, "\r$", "")
|
||||
--atdebug("content id:", stid, "->", stna)
|
||||
ndb_nodeids[stid] = stna
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
-- p_mesecon_iface.lua
|
||||
-- Mesecons interface by overriding the switch
|
||||
|
||||
if not mesecon then return end
|
||||
if minetest.get_modpath("mesecons_switch") == nil then return end
|
||||
|
||||
minetest.override_item("mesecons_switch:mesecon_switch_off", {
|
||||
groups = {
|
||||
|
|
|
@ -417,3 +417,42 @@ function advtrains.path_lookup(train, pos)
|
|||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Projects the path of "train" onto the path of "onto_train_id", and returns the index on onto_train's path
|
||||
-- that corresponds to "index" on "train"'s path, as well as whether both trains face each other
|
||||
-- index may be fractional
|
||||
-- returns: res_index, trains_facing
|
||||
-- returns nil when path can not be projected, either because trains are on different tracks or
|
||||
-- node at "index" happens to be on a turnout and it's the wrong direction
|
||||
-- Note - duplicate with similar functionality is in train_step_b() - that code combines train detection with projecting
|
||||
function advtrains.path_project(train, index, onto_train_id)
|
||||
local base_idx = atfloor(index)
|
||||
local frac_part = index - base_idx
|
||||
local base_pos = advtrains.path_get(train, base_idx)
|
||||
local base_cn = train.path_cn[base_idx]
|
||||
local otrn = advtrains.trains[onto_train_id]
|
||||
-- query occupation
|
||||
local occ = advtrains.occ.get_trains_over(base_pos)
|
||||
-- is wanted train id contained?
|
||||
local ob_idx = occ[onto_train_id]
|
||||
if not ob_idx then
|
||||
return nil
|
||||
end
|
||||
|
||||
-- retrieve other train's cn and cp
|
||||
local ocn = otrn.path_cn[ob_idx]
|
||||
local ocp = otrn.path_cp[ob_idx]
|
||||
|
||||
if base_cn == ocn then
|
||||
-- same direction
|
||||
return ob_idx + frac_part, false
|
||||
elseif base_cn == ocp then
|
||||
-- facing trains - subtract index frac
|
||||
return ob_idx - frac_part, true
|
||||
else
|
||||
-- same path item but no common connections - deny
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -56,3 +56,8 @@ advtrains_dtime_limit (DTime Limit for slow-down) float 0.2 0 5
|
|||
# Time interval in seconds in which advtrains stores its save data to disk
|
||||
# Nevertheless, advtrains saves all data when shutting down the server.
|
||||
advtrains_save_interval (Save Interval) int 60 20 3600
|
||||
|
||||
# Enable forgiving collision mode
|
||||
# If enabled, trains only collide with nodes with "normal" drawtype.
|
||||
advtrains_forgiving_collision (Forgiving Collision mode) bool false
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ local function can_dig_func(pos)
|
|||
end
|
||||
return true
|
||||
end
|
||||
local function after_dig_func(pos)
|
||||
if advtrains.interlocking then
|
||||
return advtrains.interlocking.signal_after_dig(pos)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function aspect(b)
|
||||
return {
|
||||
|
@ -67,8 +73,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
rules=advtrains.meseconrules,
|
||||
["action_"..f.as] = function (pos, node)
|
||||
advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}, true)
|
||||
if advtrains.interlocking then
|
||||
advtrains.interlocking.signal_on_aspect_changed(pos)
|
||||
end
|
||||
end
|
||||
}},
|
||||
on_rightclick=function(pos, node, player)
|
||||
local pname = player:get_player_name()
|
||||
|
@ -79,8 +87,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
advtrains.interlocking.show_ip_form(pos, pname)
|
||||
elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
|
||||
advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}, true)
|
||||
if advtrains.interlocking then
|
||||
advtrains.interlocking.signal_on_aspect_changed(pos)
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- new signal API
|
||||
advtrains = {
|
||||
|
@ -97,6 +107,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
supported_aspects = suppasp,
|
||||
},
|
||||
can_dig = can_dig_func,
|
||||
after_dig_node = after_dig_func,
|
||||
})
|
||||
advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil)
|
||||
|
||||
|
@ -127,8 +138,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
rules=advtrains.meseconrules,
|
||||
["action_"..f.as] = function (pos, node)
|
||||
advtrains.setstate(pos, f.als, node)
|
||||
if advtrains.interlocking then
|
||||
advtrains.interlocking.signal_on_aspect_changed(pos)
|
||||
end
|
||||
end
|
||||
}},
|
||||
on_rightclick=function(pos, node, player)
|
||||
local pname = player:get_player_name()
|
||||
|
@ -139,8 +152,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
advtrains.interlocking.show_ip_form(pos, pname)
|
||||
elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
|
||||
advtrains.setstate(pos, f.als, node)
|
||||
if advtrains.interlocking then
|
||||
advtrains.interlocking.signal_on_aspect_changed(pos)
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- new signal API
|
||||
advtrains = {
|
||||
|
@ -163,6 +178,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
end,
|
||||
},
|
||||
can_dig = can_dig_func,
|
||||
after_dig_node = after_dig_func,
|
||||
})
|
||||
advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil)
|
||||
end
|
||||
|
@ -198,6 +214,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
rules = mrules_wallsignal,
|
||||
["action_"..f.as] = function (pos, node)
|
||||
advtrains.setstate(pos, f.als, node)
|
||||
if advtrains.interlocking then
|
||||
advtrains.interlocking.signal_on_aspect_changed(pos)
|
||||
end
|
||||
end
|
||||
}},
|
||||
on_rightclick=function(pos, node, player)
|
||||
|
@ -209,6 +228,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
advtrains.interlocking.show_ip_form(pos, pname)
|
||||
elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
|
||||
advtrains.setstate(pos, f.als, node)
|
||||
if advtrains.interlocking then
|
||||
advtrains.interlocking.signal_on_aspect_changed(pos)
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- new signal API
|
||||
|
@ -232,6 +254,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||
end,
|
||||
},
|
||||
can_dig = can_dig_func,
|
||||
after_dig_node = after_dig_func,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -286,6 +286,7 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname, def)
|
|||
return itemstack, false
|
||||
end
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then
|
||||
local s
|
||||
if def.suitable_substrate then
|
||||
s = def.suitable_substrate(upos)
|
||||
else
|
||||
|
|
|
@ -442,6 +442,15 @@ Depending on the number of connections:
|
|||
- conn3 <> conn4
|
||||
]]
|
||||
|
||||
-- Notify the user if digging the rail is not allowed
|
||||
local function can_dig_callback(pos, player)
|
||||
local ok, reason = advtrains.can_dig_or_modify_track(pos)
|
||||
if not ok and player then
|
||||
minetest.chat_send_player(player:get_player_name(), attrans("This track can not be removed!") .. " " .. reason)
|
||||
end
|
||||
return ok
|
||||
end
|
||||
|
||||
function advtrains.register_tracks(tracktype, def, preset)
|
||||
advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault)
|
||||
if preset.regtp then
|
||||
|
@ -478,7 +487,7 @@ function advtrains.register_tracks(tracktype, def, preset)
|
|||
not_blocking_trains=1,
|
||||
},
|
||||
|
||||
can_dig = advtrains.can_dig_or_modify_track,
|
||||
can_dig = can_dig_callback,
|
||||
after_dig_node=function(pos)
|
||||
advtrains.ndb.update(pos)
|
||||
end,
|
||||
|
@ -515,7 +524,7 @@ function advtrains.register_tracks(tracktype, def, preset)
|
|||
end
|
||||
ndef.on_rightclick = function(pos, node, player)
|
||||
if advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
|
||||
advtrains.setstate(pos, newstate, node)
|
||||
advtrains.setstate(pos, nil, node)
|
||||
advtrains.log("Switch", player:get_player_name(), pos)
|
||||
end
|
||||
end
|
||||
|
@ -613,7 +622,7 @@ function advtrains.can_dig_or_modify_track(pos)
|
|||
return false, attrans("There's a Track Circuit Break here.")
|
||||
end
|
||||
-- signal ip?
|
||||
if advtrains.interlocking.db.is_ip_at(pos) then
|
||||
if advtrains.interlocking.db.is_ip_at(pos, true) then -- is_ip_at with purge parameter
|
||||
return false, attrans("There's a Signal Influence Point here.")
|
||||
end
|
||||
end
|
||||
|
@ -658,7 +667,7 @@ function sl.create_slopeplacer_on_place(def, preset)
|
|||
local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2)
|
||||
|
||||
--rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5.
|
||||
dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)}
|
||||
local dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)}
|
||||
--translate to direction to look up inside the preset table
|
||||
local param2, rot45=({
|
||||
[-1]={
|
||||
|
|
|
@ -139,11 +139,15 @@ minetest.register_on_joinplayer(function(player)
|
|||
advtrains.hhud[player:get_player_name()] = nil
|
||||
--independent of this, cause all wagons of the train which are loaded to reattach their players
|
||||
--needed because already loaded wagons won't call reattach_all()
|
||||
local pname = player:get_player_name()
|
||||
local id=advtrains.player_to_train_mapping[pname]
|
||||
if id then
|
||||
for _,wagon in pairs(minetest.luaentities) do
|
||||
if wagon.is_wagon and wagon.initialized and wagon.train_id==id then
|
||||
wagon:reattach_all()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
@ -160,6 +164,8 @@ minetest.register_on_dieplayer(function(player)
|
|||
wagon:get_off_plr(pname)
|
||||
end
|
||||
end
|
||||
-- just in case no wagon felt responsible for this player: clear train mapping
|
||||
advtrains.player_to_train_mapping[pname] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -389,7 +395,7 @@ function advtrains.train_step_b(id, train, dtime)
|
|||
local back_off_track=train.end_index<train.path_trk_b
|
||||
train.off_track = front_off_track or back_off_track
|
||||
|
||||
if back_off_track and (not v_cap or v_cap > 1) then
|
||||
if back_off_track and (not sit_v_cap or sit_v_cap > 1) then
|
||||
--atprint("in train_step_b: applying back_off_track")
|
||||
sit_v_cap = 1
|
||||
elseif front_off_track then
|
||||
|
@ -588,6 +594,70 @@ function advtrains.train_step_b(id, train, dtime)
|
|||
--atprint("in train_step_b: Zero barrier hit, clipping to newidx_tv=",new_index_curr_tv, "zb_idx=",lzb_next_zero_barrier)
|
||||
new_index_curr_tv = lzb_next_zero_barrier
|
||||
end
|
||||
|
||||
-- New same-track collision system - check for any other trains within the range we're going to move
|
||||
-- do the checks if we either are moving or about to start moving
|
||||
if new_index_curr_tv > train.index or accelerating then -- only if train is actually advancing
|
||||
-- Note: duplicate code from path_project() because of subtle differences: no frac processing and scanning all occupations
|
||||
--[[train.debug = ""
|
||||
local atdebug = function(t, ...)
|
||||
local text=advtrains.print_concat_table({t, ...})
|
||||
train.debug = train.debug..text.."\n"
|
||||
end]]
|
||||
local base_idx = atfloor(new_index_curr_tv + 1)
|
||||
local base_pos = advtrains.path_get(train, base_idx)
|
||||
local base_cn = train.path_cn[base_idx]
|
||||
--atdebug(id,"Begin Checking for on-track collisions new_idx=",new_index_curr_tv,"base_idx=",base_idx,"base_pos=",base_pos,"base_cn=",base_cn)
|
||||
-- query occupation
|
||||
local occ = advtrains.occ.get_trains_over(base_pos)
|
||||
-- iterate other trains
|
||||
for otid, ob_idx in pairs(occ) do
|
||||
if otid ~= id then
|
||||
--atdebug(id,"Found other train",otid," with matching index ",ob_idx)
|
||||
-- Phase 1 - determine if trains are facing and which is the relefant stpo index
|
||||
local otrn = advtrains.trains[otid]
|
||||
|
||||
-- retrieve other train's cn and cp
|
||||
local ocn = otrn.path_cn[ob_idx]
|
||||
local ocp = otrn.path_cp[ob_idx]
|
||||
|
||||
local target_is_inside, ref_index, facing
|
||||
|
||||
if base_cn == ocn then
|
||||
-- same direction
|
||||
ref_index = otrn.end_index
|
||||
same_dir = true
|
||||
target_is_inside = (ob_idx >= ref_index)
|
||||
--atdebug("Same direction: ref_index",ref_index,"inside=",target_is_inside)
|
||||
elseif base_cn == ocp then
|
||||
-- facing trains - subtract index frac
|
||||
ref_index = otrn.index
|
||||
same_dir = false
|
||||
target_is_inside = (ob_idx <= ref_index)
|
||||
--atdebug("Facing direction: ref_index",ref_index,"inside=",target_is_inside)
|
||||
end
|
||||
|
||||
-- Phase 2 - project ref_index back onto our path and check again (necessary because there might be a turnout on the way and we are driving into the flank
|
||||
if target_is_inside then
|
||||
local our_index = advtrains.path_project(otrn, ref_index, id)
|
||||
--atdebug("Backprojected our_index",our_index)
|
||||
if our_index and our_index <= new_index_curr_tv then
|
||||
-- ON_TRACK COLLISION IS HAPPENING
|
||||
-- the actual collision is handled in train_step_c, so set appropriate signal variables
|
||||
train.ontrack_collision_info = {
|
||||
otid = otid,
|
||||
same_dir = same_dir,
|
||||
}
|
||||
-- clip newindex
|
||||
--atdebug("-- Collision detected!")
|
||||
new_index_curr_tv = our_index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ## Movement happens here ##
|
||||
train.index = new_index_curr_tv
|
||||
|
||||
recalc_end_index(train)
|
||||
|
@ -634,20 +704,41 @@ function advtrains.train_step_c(id, train, dtime)
|
|||
train.check_trainpartload=2
|
||||
end
|
||||
|
||||
--- 8. check for collisions with other trains and damage players ---
|
||||
|
||||
local train_moves=(train.velocity~=0)
|
||||
local very_short_train = train.trainlen < 3
|
||||
|
||||
--- Check whether this train can be coupled to another, and set couple entities accordingly
|
||||
if not train.was_standing and not train_moves then
|
||||
advtrains.train_check_couples(train)
|
||||
--- On-track collision handling - detected in train_step_b, but handled here so all other train movements have already happened.
|
||||
if train.ontrack_collision_info then
|
||||
train.velocity = 0
|
||||
train.acceleration = 0
|
||||
advtrains.atc.train_reset_command(train)
|
||||
|
||||
local otrn = advtrains.trains[train.ontrack_collision_info.otid]
|
||||
|
||||
if otrn.velocity == 0 then -- other train must be standing, else don't initiate coupling
|
||||
advtrains.couple_initiate_with(train, otrn, not train.ontrack_collision_info.same_dir)
|
||||
end
|
||||
train.was_standing = not train_moves
|
||||
|
||||
train.ontrack_collision_info = nil
|
||||
train.couples_up_to_date = true
|
||||
end
|
||||
|
||||
-- handle couples if on_track collision handling did not fire
|
||||
if train_moves then
|
||||
train.couples_up_to_date = nil
|
||||
elseif not train.couples_up_to_date then
|
||||
if not very_short_train then -- old coupling system is buggy for short trains
|
||||
advtrains.train_check_couples(train) -- no guarantee for train order here
|
||||
end
|
||||
train.couples_up_to_date = true
|
||||
end
|
||||
|
||||
--- 8. check for collisions with other trains and damage players ---
|
||||
if train_moves then
|
||||
-- Note: this code handles collisions with trains that are not on the same path as the current train
|
||||
-- The same-track collisions and coupling handling is found in couple.lua and handled from train_step_b() and code 2 blocks above.
|
||||
local collided = false
|
||||
local coll_grace=1
|
||||
local coll_grace=2
|
||||
local collindex = advtrains.path_get_index_by_offset(train, train.index, -coll_grace)
|
||||
local collpos = advtrains.path_get(train, atround(collindex))
|
||||
if collpos then
|
||||
|
@ -658,14 +749,15 @@ function advtrains.train_step_c(id, train, dtime)
|
|||
local testpos=vector.add(rcollpos, {x=x, y=0, z=z})
|
||||
--- 8a Check collision ---
|
||||
if not collided then
|
||||
|
||||
if not very_short_train then -- position collision system is buggy for short trains
|
||||
local col_tr = advtrains.occ.check_collision(testpos, id)
|
||||
if col_tr then
|
||||
advtrains.train_check_couples(train)
|
||||
train.velocity = 0
|
||||
train.acceleration = 0
|
||||
advtrains.atc.train_reset_command(train)
|
||||
collided = true
|
||||
end
|
||||
end
|
||||
|
||||
--- 8b damage players ---
|
||||
if is_loaded_area and train.velocity > 3 and (setting_overrun_mode=="drop" or setting_overrun_mode=="normal") then
|
||||
|
@ -698,7 +790,7 @@ function advtrains.train_step_c(id, train, dtime)
|
|||
local objs = minetest.get_objects_inside_radius(rcollpos, 2)
|
||||
for _,obj in ipairs(objs) do
|
||||
if not obj:is_player() and obj:get_armor_groups().fleshy and obj:get_armor_groups().fleshy > 0
|
||||
and obj:get_luaentity() and obj:get_luaentity().name~="signs:text" then
|
||||
and obj:get_luaentity() and obj:get_luaentity().name~="signs_lib:text" then
|
||||
obj:punch(obj, 1, { full_punch_interval = 1.0, damage_groups = {fleshy = 1000}, }, nil)
|
||||
end
|
||||
end
|
||||
|
@ -894,7 +986,7 @@ function advtrains.remove_train(id)
|
|||
|
||||
run_callbacks_remove(id, train)
|
||||
|
||||
advtrains.path_invalidate(train)
|
||||
advtrains.path_invalidate(train, true)
|
||||
advtrains.couple_invalidate(train)
|
||||
|
||||
local tp = train.trainparts
|
||||
|
@ -1014,53 +1106,6 @@ function advtrains.spawn_wagons(train_id)
|
|||
end
|
||||
end
|
||||
|
||||
function advtrains.split_train_at_fc(train, count_empty, length_limit)
|
||||
-- splits train at first different current FC by convention,
|
||||
-- locomotives have empty FC so are ignored
|
||||
-- count_empty is used to split off locomotives
|
||||
-- length_limit limits the length of the first train to length_limit wagons
|
||||
local train_id = train.id
|
||||
local fc = false
|
||||
local ind = 0
|
||||
for i = 1, #train.trainparts do
|
||||
local w_id = train.trainparts[i]
|
||||
local data = advtrains.wagons[w_id]
|
||||
if length_limit and i > length_limit then
|
||||
ind = i
|
||||
break
|
||||
end
|
||||
if data then
|
||||
local wfc = advtrains.get_cur_fc(data)
|
||||
if wfc ~= "" or count_empty then
|
||||
if fc then
|
||||
if fc ~= wfc then
|
||||
ind = i
|
||||
break
|
||||
end
|
||||
else
|
||||
fc = wfc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if ind > 0 then
|
||||
return advtrains.split_train_at_index(train, ind), fc
|
||||
end
|
||||
if fc then
|
||||
return nil, fc
|
||||
end
|
||||
end
|
||||
|
||||
function advtrains.train_step_fc(train)
|
||||
for i=1,#train.trainparts do
|
||||
local w_id = train.trainparts[i]
|
||||
local data = advtrains.wagons[w_id]
|
||||
if data then
|
||||
advtrains.step_fc(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function advtrains.split_train_at_index(train, index)
|
||||
-- this function splits a train at index, creating a new train from the back part of the train.
|
||||
|
||||
|
@ -1077,6 +1122,12 @@ function advtrains.split_train_at_index(train, index)
|
|||
return
|
||||
end
|
||||
|
||||
-- make sure that the train is fully on track before splitting. May cause problems otherwise
|
||||
if train.index > train.path_trk_f or train.end_index < train.path_trk_b then
|
||||
atwarn("Train",train_id,": cannot split train because it is off track!")
|
||||
return
|
||||
end
|
||||
|
||||
local p_index=advtrains.path_get_index_by_offset(train, train.index, - data.pos_in_train + wagon.wagon_span)
|
||||
local pos, connid, frac = advtrains.path_getrestore(train, p_index)
|
||||
local tp = {}
|
||||
|
@ -1095,171 +1146,21 @@ function advtrains.split_train_at_index(train, index)
|
|||
local newtrain=advtrains.trains[newtrain_id]
|
||||
|
||||
newtrain.velocity=train.velocity
|
||||
-- copy various properties from the old to the new train
|
||||
newtrain.door_open = train.door_open
|
||||
newtrain.text_outside = train.text_outside
|
||||
newtrain.text_inside = train.text_inside
|
||||
newtrain.line = train.line
|
||||
newtrain.routingcode = train.routingcode
|
||||
newtrain.speed_restriction = train.speed_restriction
|
||||
newtrain.is_shunt = train.is_shunt
|
||||
newtrain.points_split = advtrains.merge_tables(train.points_split)
|
||||
newtrain.autocouple = train.autocouple
|
||||
|
||||
return newtrain_id -- return new train ID, so new train can be manipulated
|
||||
|
||||
end
|
||||
|
||||
function advtrains.split_train_at_wagon(wagon_id)
|
||||
--get train
|
||||
local data = advtrains.wagons[wagon_id]
|
||||
advtrains.split_train_at_index(advtrains.trains[data.train_id], data.pos_in_trainparts)
|
||||
end
|
||||
|
||||
-- coupling
|
||||
local CPL_CHK_DST = -1
|
||||
local CPL_ZONE = 2
|
||||
|
||||
-- train.couple_* contain references to ObjectRefs of couple objects, which contain all relevant information
|
||||
-- These objectRefs will delete themselves once the couples no longer match
|
||||
local function createcouple(pos, train1, t1_is_front, train2, t2_is_front)
|
||||
local id1 = train1.id
|
||||
local id2 = train2.id
|
||||
if train1.autocouple or train2.autocouple then
|
||||
-- couple trains
|
||||
train1.autocouple = nil
|
||||
train2.autocouple = nil
|
||||
minetest.after(0, advtrains.safe_couple_trains, id1, id2, t1_is_front, t2_is_front, false, false, train1.velocity, train2.velocity)
|
||||
return
|
||||
end
|
||||
|
||||
local obj=minetest.add_entity(pos, "advtrains:couple")
|
||||
if not obj then error("Failed creating couple object!") return end
|
||||
local le=obj:get_luaentity()
|
||||
le.train_id_1=id1
|
||||
le.train_id_2=id2
|
||||
le.t1_is_front=t1_is_front
|
||||
le.t2_is_front=t2_is_front
|
||||
--atdebug("created couple between",train1.id,t1_is_front,train2.id,t2_is_front)
|
||||
if t1_is_front then
|
||||
train1.cpl_front = obj
|
||||
else
|
||||
train1.cpl_back = obj
|
||||
end
|
||||
if t2_is_front then
|
||||
train2.cpl_front = obj
|
||||
else
|
||||
train2.cpl_back = obj
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function advtrains.train_check_couples(train)
|
||||
--atdebug("rechecking couples")
|
||||
if train.cpl_front then
|
||||
if not train.cpl_front:get_yaw() then
|
||||
-- objectref is no longer valid. reset.
|
||||
train.cpl_front = nil
|
||||
end
|
||||
end
|
||||
if not train.cpl_front then
|
||||
-- recheck front couple
|
||||
local front_trains, pos = advtrains.occ.get_occupations(train, atround(train.index) + CPL_CHK_DST)
|
||||
if advtrains.is_node_loaded(pos) then -- if the position is loaded...
|
||||
for tid, idx in pairs(front_trains) do
|
||||
local other_train = advtrains.trains[tid]
|
||||
if not advtrains.train_ensure_init(tid, other_train) then
|
||||
atwarn("Train",tid,"is not initialized! Couldn't check couples!")
|
||||
return
|
||||
end
|
||||
--atdebug(train.id,"front: ",idx,"on",tid,atround(other_train.index),atround(other_train.end_index))
|
||||
if other_train.velocity == 0 then
|
||||
if idx>=other_train.index and idx<=other_train.index + CPL_ZONE then
|
||||
createcouple(pos, train, true, other_train, true)
|
||||
break
|
||||
end
|
||||
if idx<=other_train.end_index and idx>=other_train.end_index - CPL_ZONE then
|
||||
createcouple(pos, train, true, other_train, false)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if train.cpl_back then
|
||||
if not train.cpl_back:get_yaw() then
|
||||
-- objectref is no longer valid. reset.
|
||||
train.cpl_back = nil
|
||||
end
|
||||
end
|
||||
if not train.cpl_back then
|
||||
-- recheck back couple
|
||||
local back_trains, pos = advtrains.occ.get_occupations(train, atround(train.end_index) - CPL_CHK_DST)
|
||||
if advtrains.is_node_loaded(pos) then -- if the position is loaded...
|
||||
for tid, idx in pairs(back_trains) do
|
||||
local other_train = advtrains.trains[tid]
|
||||
if not advtrains.train_ensure_init(tid, other_train) then
|
||||
atwarn("Train",tid,"is not initialized! Couldn't check couples!")
|
||||
return
|
||||
end
|
||||
if other_train.velocity == 0 then
|
||||
if idx>=other_train.index and idx<=other_train.index + CPL_ZONE then
|
||||
createcouple(pos, train, false, other_train, true)
|
||||
break
|
||||
end
|
||||
if idx<=other_train.end_index and idx>=other_train.end_index - CPL_ZONE then
|
||||
createcouple(pos, train, false, other_train, false)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function advtrains.couple_invalidate(train)
|
||||
if train.cpl_back then
|
||||
train.cpl_back:remove()
|
||||
train.cpl_back = nil
|
||||
end
|
||||
if train.cpl_front then
|
||||
train.cpl_front:remove()
|
||||
train.cpl_front = nil
|
||||
end
|
||||
train.was_standing = nil
|
||||
end
|
||||
|
||||
-- relevant code for this comment is in couple.lua
|
||||
|
||||
--there are 4 cases:
|
||||
--1/2. F<->R F<->R regular, put second train behind first
|
||||
--->frontpos of first train will match backpos of second
|
||||
--3. F<->R R<->F flip one of these trains, take the other as new train
|
||||
--->backpos's will match
|
||||
--4. R<->F F<->R flip one of these trains and take it as new parent
|
||||
--->frontpos's will match
|
||||
|
||||
|
||||
function advtrains.do_connect_trains(first_id, second_id, vel)
|
||||
local first, second=advtrains.trains[first_id], advtrains.trains[second_id]
|
||||
|
||||
if not advtrains.train_ensure_init(first_id, first) then
|
||||
atwarn("Train",first_id,"is not initialized! Operation aborted!")
|
||||
return
|
||||
end
|
||||
if not advtrains.train_ensure_init(second_id, second) then
|
||||
atwarn("Train",second_id,"is not initialized! Operation aborted!")
|
||||
return
|
||||
end
|
||||
|
||||
local first_wagoncnt=#first.trainparts
|
||||
local second_wagoncnt=#second.trainparts
|
||||
|
||||
for _,v in ipairs(second.trainparts) do
|
||||
table.insert(first.trainparts, v)
|
||||
end
|
||||
|
||||
advtrains.remove_train(second_id)
|
||||
if vel < 0 then
|
||||
advtrains.invert_train(first_id)
|
||||
vel = -vel
|
||||
end
|
||||
first.velocity= vel or 0
|
||||
|
||||
advtrains.update_trainpart_properties(first_id)
|
||||
advtrains.couple_invalidate(first)
|
||||
return true
|
||||
end
|
||||
|
||||
function advtrains.invert_train(train_id)
|
||||
local train=advtrains.trains[train_id]
|
||||
|
||||
|
@ -1346,6 +1247,23 @@ function advtrains.invalidate_path(id)
|
|||
end
|
||||
|
||||
--not blocking trains group
|
||||
|
||||
if minetest.settings:get_bool("advtrains_forgiving_collision") then
|
||||
function advtrains.train_collides(node)
|
||||
if node and minetest.registered_nodes[node.name] then
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
-- if the node is drawtype normal (that is a full cube) then it does collide
|
||||
if ndef.drawtype == "normal" then
|
||||
-- except if it is not_blocking_trains
|
||||
if ndef.groups.not_blocking_trains and ndef.groups.not_blocking_trains ~= 0 then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
else
|
||||
function advtrains.train_collides(node)
|
||||
if node and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].walkable then
|
||||
if not minetest.registered_nodes[node.name].groups.not_blocking_trains then
|
||||
|
@ -1378,7 +1296,6 @@ local nonblocknodes={
|
|||
"signs:sign_post",
|
||||
"signs:sign_hanging",
|
||||
|
||||
|
||||
}
|
||||
minetest.after(0, function()
|
||||
for _,name in ipairs(nonblocknodes) do
|
||||
|
@ -1387,3 +1304,4 @@ minetest.after(0, function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -934,6 +934,7 @@ function wagon:show_bordcom(pname)
|
|||
if not self:train() then return end
|
||||
local train = self:train()
|
||||
local data = advtrains.wagons[self.id]
|
||||
local linhei
|
||||
|
||||
local form = "size[11,9]label[0.5,0;AdvTrains Boardcom v0.1]"
|
||||
form=form.."textarea[0.5,1.5;7,1;text_outside;"..attrans("Text displayed outside on train")..";"..(minetest.formspec_escape(train.text_outside or "")).."]"
|
||||
|
@ -1239,70 +1240,6 @@ function wagon:reattach_all()
|
|||
end
|
||||
end
|
||||
|
||||
local function check_twagon_owner(train, b_first, pname)
|
||||
local wtp = b_first and 1 or #train.trainparts
|
||||
local wid = train.trainparts[wtp]
|
||||
local wdata = advtrains.wagons[wid]
|
||||
if wdata then
|
||||
return advtrains.check_driving_couple_protection(pname, wdata.owner, wdata.whitelist)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function advtrains.safe_couple_trains(id1, id2, t1f, t2f, pname, try_run,v1,v2)
|
||||
|
||||
if pname and not minetest.check_player_privs(pname, "train_operator") then
|
||||
minetest.chat_send_player(pname, "Missing train_operator privilege")
|
||||
return false
|
||||
end
|
||||
|
||||
local train1=advtrains.trains[id1]
|
||||
local train2=advtrains.trains[id2]
|
||||
|
||||
if not advtrains.train_ensure_init(id1, train1)
|
||||
or not advtrains.train_ensure_init(id2, train2) then
|
||||
return false
|
||||
end
|
||||
local wck_t1, wck_t2
|
||||
if pname then
|
||||
wck_t1 = check_twagon_owner(train1, t1f, pname)
|
||||
wck_t2 = check_twagon_owner(train2, t2f, pname)
|
||||
end
|
||||
if (wck_t1 or wck_t2) or not pname then
|
||||
if not v1 then
|
||||
v1 = 0
|
||||
end
|
||||
if not v2 then
|
||||
v2 = 0
|
||||
end
|
||||
if try_run then
|
||||
return true
|
||||
end
|
||||
if t1f then
|
||||
if t2f then
|
||||
v1 = -v1
|
||||
advtrains.invert_train(id1)
|
||||
advtrains.do_connect_trains(id1, id2, v1+v2)
|
||||
else
|
||||
advtrains.do_connect_trains(id2, id1, v1+v2)
|
||||
end
|
||||
else
|
||||
if t2f then
|
||||
advtrains.do_connect_trains(id1, id2, v1+v2)
|
||||
else
|
||||
v2 = -v2
|
||||
advtrains.invert_train(id2)
|
||||
advtrains.do_connect_trains(id1, id2, v1+v2)
|
||||
end
|
||||
end
|
||||
return true
|
||||
else
|
||||
minetest.chat_send_player(pname, "You must be authorized for at least one wagon.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function advtrains.safe_decouple_wagon(w_id, pname, try_run)
|
||||
if not minetest.check_player_privs(pname, "train_operator") then
|
||||
minetest.chat_send_player(pname, "Missing train_operator privilege")
|
||||
|
|
|
@ -562,9 +562,23 @@ function ildb.set_sigd_for_signal(pos, sigd)
|
|||
end
|
||||
|
||||
-- checks if there's any influence point set to this position
|
||||
function ildb.is_ip_at(pos)
|
||||
-- if purge is true, checks whether the associated signal still exists
|
||||
-- and deletes the ip if not.
|
||||
function ildb.is_ip_at(pos, purge)
|
||||
local pts = advtrains.roundfloorpts(pos)
|
||||
if influence_points[pts] then
|
||||
if purge then
|
||||
-- is there still a signal assigned to it?
|
||||
for connid, sigpos in pairs(influence_points[pts]) do
|
||||
local asp = advtrains.interlocking.signal_get_aspect(sigpos)
|
||||
if not asp then
|
||||
atlog("Clearing orphaned signal influence point", pts, "/", connid)
|
||||
ildb.clear_ip_signal(pts, connid)
|
||||
end
|
||||
end
|
||||
-- if there's no side left after purging, return false
|
||||
if not influence_points[pts] then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
|
|
@ -41,7 +41,6 @@ minetest.register_node("advtrains_interlocking:ds_danger", {
|
|||
advtrains_signal = 2,
|
||||
save_in_at_nodedb = 1,
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
advtrains = {
|
||||
set_aspect = setaspect,
|
||||
supported_aspects = suppasp,
|
||||
|
@ -51,6 +50,7 @@ minetest.register_node("advtrains_interlocking:ds_danger", {
|
|||
},
|
||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||
can_dig = advtrains.interlocking.signal_can_dig,
|
||||
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||
})
|
||||
minetest.register_node("advtrains_interlocking:ds_free", {
|
||||
description = "Demo signal at Free",
|
||||
|
@ -60,7 +60,6 @@ minetest.register_node("advtrains_interlocking:ds_free", {
|
|||
advtrains_signal = 2,
|
||||
save_in_at_nodedb = 1,
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
advtrains = {
|
||||
set_aspect = setaspect,
|
||||
supported_aspects = suppasp,
|
||||
|
@ -72,6 +71,7 @@ minetest.register_node("advtrains_interlocking:ds_free", {
|
|||
},
|
||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||
can_dig = advtrains.interlocking.signal_can_dig,
|
||||
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||
})
|
||||
minetest.register_node("advtrains_interlocking:ds_slow", {
|
||||
description = "Demo signal at Slow",
|
||||
|
@ -81,7 +81,6 @@ minetest.register_node("advtrains_interlocking:ds_slow", {
|
|||
advtrains_signal = 2,
|
||||
save_in_at_nodedb = 1,
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
advtrains = {
|
||||
set_aspect = setaspect,
|
||||
supported_aspects = suppasp,
|
||||
|
@ -93,5 +92,6 @@ minetest.register_node("advtrains_interlocking:ds_slow", {
|
|||
},
|
||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||
can_dig = advtrains.interlocking.signal_can_dig,
|
||||
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||
})
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
advtrains
|
||||
advtrains_train_track?
|
7
mods/advtrains/advtrains_interlocking/mod.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
name=advtrains_interlocking
|
||||
title=Advanced Trains Interlocking System
|
||||
description=Interlocking system for Advanced Trains
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains
|
||||
optional_depends=advtrains_train_track
|
|
@ -25,8 +25,8 @@ function atil.show_route_edit_form(pname, sigd, routeid)
|
|||
if not route then return end
|
||||
|
||||
local form = "size[9,10]label[0.5,0.2;Route overview]"
|
||||
form = form.."field[0.8,1.2;5.2,1;name;Route name;"..minetest.formspec_escape(route.name).."]"
|
||||
form = form.."button[5.5,0.9;1,1;setname;Set]"
|
||||
form = form.."field[0.8,1.2;6.5,1;name;Route name;"..minetest.formspec_escape(route.name).."]"
|
||||
form = form.."button[7.0,0.9;1.5,1;setname;Set]"
|
||||
|
||||
-- construct textlist for route information
|
||||
local tab = {}
|
||||
|
@ -80,15 +80,16 @@ function atil.show_route_edit_form(pname, sigd, routeid)
|
|||
itab("Route ends on dead-end")
|
||||
end
|
||||
|
||||
form = form.."textlist[0.5,2;7,4;rtelog;"..table.concat(tab, ",").."]"
|
||||
form = form.."textlist[0.5,2;7.75,3.9;rtelog;"..table.concat(tab, ",").."]"
|
||||
|
||||
form = form.."button[0.5,6;2,1;back;<<< Back to signal]"
|
||||
form = form.."button[3.5,6;2,1;aspect;Signal Aspect]"
|
||||
form = form.."button[5.5,6;2,1;delete;Delete Route]"
|
||||
form = form.."button[0.5,6;3,1;back;<<< Back to signal]"
|
||||
form = form.."button[4.5,6;2,1;aspect;Signal Aspect]"
|
||||
form = form.."button[6.5,6;2,1;delete;Delete Route]"
|
||||
|
||||
--atdebug(route.ars)
|
||||
form = form.."textarea[1,7.3;5.2,3;ars;ARS Rule List;"..atil.ars_to_text(route.ars).."]"
|
||||
form = form.."button[6,7.7;1,1;savears;Save]"
|
||||
form = form.."style[ars;font=mono]"
|
||||
form = form.."textarea[0.8,7.3;5,3;ars;ARS Rule List;"..atil.ars_to_text(route.ars).."]"
|
||||
form = form.."button[5.5,7.23;3,1;savears;Save ARS List]"
|
||||
|
||||
minetest.show_formspec(pname, "at_il_routeedit_"..minetest.pos_to_string(sigd.p).."_"..sigd.s.."_"..routeid, form)
|
||||
|
||||
|
|
30
mods/advtrains/advtrains_interlocking/tcb_ts_ui.lua
Normal file → Executable file
|
@ -120,13 +120,41 @@ minetest.register_node("advtrains_interlocking:tcb_node", {
|
|||
|
||||
|
||||
-- Crafting
|
||||
|
||||
-- set some fallbacks
|
||||
local tcb_core = "default:mese_crystal"
|
||||
local tcb_secondary = "default:mese_crystal_fragment"
|
||||
|
||||
--alternative recipe items
|
||||
--core
|
||||
if minetest.get_modpath("basic_materials") then
|
||||
tcb_core = "basic_materials:ic"
|
||||
elseif minetest.get_modpath("technic") then
|
||||
tcb_core = "technic:control_logic_unit"
|
||||
end
|
||||
--print("TCB Core: "..tcb_core)
|
||||
--secondary
|
||||
if minetest.get_modpath("mesecons") then
|
||||
tcb_secondary = 'mesecons:wire_00000000_off'
|
||||
end
|
||||
--print("TCB Secondary: "..tcb_secondary)
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'advtrains_interlocking:tcb_node 4',
|
||||
recipe = {
|
||||
{'mesecons:wire_00000000_off', 'basic_materials:ic', 'mesecons:wire_00000000_off'},
|
||||
{tcb_secondary,tcb_core,tcb_secondary},
|
||||
{'advtrains:dtrack_placer','','advtrains:dtrack_placer'}
|
||||
},
|
||||
--actually use track in the tcb recipe
|
||||
replacements = {
|
||||
{"advtrains:dtrack_placer","advtrains:dtrack_placer"},
|
||||
{"advtrains:dtrack_placer","advtrains:dtrack_placer"},
|
||||
}
|
||||
})
|
||||
|
||||
--nil the temp crafting variables
|
||||
tcb_core= nil
|
||||
tcb_secondary = nil
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, player, pointed_thing)
|
||||
local pname = player:get_player_name()
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
advtrains
|
6
mods/advtrains/advtrains_itrainmap/mod.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
name=advtrains_itrainmap
|
||||
title=Advanced Trains Interactive Train Map (currently broken)
|
||||
description=Map formspec showing tracks and trains
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains
|
|
@ -1,2 +0,0 @@
|
|||
advtrains_interlocking
|
||||
advtrains_train_track?
|
7
mods/advtrains/advtrains_line_automation/mod.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
name=advtrains_line_automation
|
||||
title=Advanced Trains Line Automation
|
||||
description=Tools for automatic train lines
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains_interlocking
|
||||
optional_depends=advtrains_train_track
|
|
@ -50,19 +50,18 @@ local function show_stoprailform(pos, player)
|
|||
end
|
||||
|
||||
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,1.5;7,1;stnname;"..attrans("Station Name")..";"..minetest.formspec_escape(stnname).."]"
|
||||
form = form.."field[0.5,2.5;1.5,1;ddelay;"..attrans("Door Delay")..";"..minetest.formspec_escape(stdata.ddelay).."]"
|
||||
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.."dropdown[0.5,3;2;doors;Left,Right,Closed;"..door_dropdown[stdata.doors].."]"
|
||||
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.."textarea[0.5,4;4,2;ars;Trains stopping here (ARS rules);"..advtrains.interlocking.ars_to_text(stdata.ars).."]"
|
||||
|
||||
form = form.."style[stn,ars;font=mono]"
|
||||
form = form.."field[0.8,0.8;2,1;stn;"..attrans("Station Code")..";"..minetest.formspec_escape(stdata.stn).."]"
|
||||
form = form.."field[2.8,0.8;5,1;stnname;"..attrans("Station Name")..";"..minetest.formspec_escape(stnname).."]"
|
||||
form = form.."field[0.80,2.0;1.75,1;ddelay;"..attrans("Door Delay")..";"..minetest.formspec_escape(stdata.ddelay).."]"
|
||||
form = form.."field[2.55,2.0;1.75,1;speed;"..attrans("Dep. Speed")..";"..minetest.formspec_escape(stdata.speed).."]"
|
||||
form = form.."field[4.30,2.0;1.75,1;track;"..attrans("Track")..";"..minetest.formspec_escape(stdata.track).."]"
|
||||
form = form.."field[6.05,2.0;1.75,1;wait;"..attrans("Stop Time")..";"..stdata.wait.."]"
|
||||
form = form.."label[0.5,2.6;"..attrans("Door Side").."]"
|
||||
form = form.."dropdown[0.51,3.0;2;doors;Left,Right,Closed;"..door_dropdown[stdata.doors].."]"
|
||||
form = form.."checkbox[3.00,2.7;reverse;"..attrans("Reverse train")..";"..(stdata.reverse and "true" or "false").."]"
|
||||
form = form.."checkbox[3.00,3.1;kick;"..attrans("Kick out passengers")..";"..(stdata.kick and "true" or "false").."]"
|
||||
form = form.."textarea[0.8,4.2;7,2;ars;Trains stopping here (ARS rules);"..advtrains.interlocking.ars_to_text(stdata.ars).."]"
|
||||
form = form.."button[0.5,6;7,1;save;"..attrans("Save").."]"
|
||||
|
||||
minetest.show_formspec(pname, "at_lines_stop_"..pe, form)
|
||||
|
@ -89,24 +88,21 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
tmp_checkboxes[pe].reverse = (fields.reverse == "true")
|
||||
end
|
||||
if fields.save then
|
||||
if fields.stn and stdata.stn ~= fields.stn then
|
||||
if fields.stn ~= "" then
|
||||
if fields.stn and stdata.stn ~= fields.stn and fields.stn ~= "" then
|
||||
local stn = advtrains.lines.stations[fields.stn]
|
||||
if stn then
|
||||
if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then
|
||||
stdata.stn = fields.stn
|
||||
else
|
||||
minetest.chat_send_player(pname, "Station code '"..fields.stn.."' does already exist and is owned by "..stn.owner)
|
||||
show_stoprailform(pos,player)
|
||||
return
|
||||
end
|
||||
else
|
||||
advtrains.lines.stations[fields.stn] = {name = fields.stnname, owner = pname}
|
||||
stdata.stn = fields.stn
|
||||
end
|
||||
end
|
||||
updatemeta(pos)
|
||||
show_stoprailform(pos, player)
|
||||
return
|
||||
end
|
||||
local stn = advtrains.lines.stations[stdata.stn]
|
||||
if stn and fields.stnname and fields.stnname ~= stn.name then
|
||||
if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then
|
||||
|
|
|
@ -93,6 +93,9 @@ Removes any pending interrupts of this node.
|
|||
Make this active component send a digiline message on the specified channel.
|
||||
Not available in init code.
|
||||
|
||||
- `atc_send_to_train(<train_id>, <atc_command>)`
|
||||
Sends the specified ATC command to the train specified by its train id. This happens regardless of where the train is in the world, and can be used to remote-control trains. Returns true on success. If the train ID does not exist, returns false and does nothing. See [atc_command.txt](../atc_command.txt) for the ATC command syntax.
|
||||
|
||||
#### Interlocking Route Management Functions
|
||||
If `advtrains_interlocking` is enabled, the following aditional functions can be used:
|
||||
|
||||
|
@ -230,6 +233,9 @@ In addition to the above environment functions, the following functions are avai
|
|||
- `atc_set_text_inside(text)`
|
||||
Set text shown to train passengers. Pass nil to show no text. `text` must be a string.
|
||||
|
||||
- `atc_set_text_inside(text) / atc_set_text_outside(text)`
|
||||
Getters for inside/outside text, return nil when no train is there.
|
||||
|
||||
- `get_line()`
|
||||
Returns the "Line" property of the train (a string).
|
||||
This can be used to distinguish between trains of different lines and route them appropriately.
|
||||
|
|
|
@ -41,9 +41,14 @@ function ac.getform(pos, meta_p)
|
|||
sel=#envs_asvalues
|
||||
end
|
||||
end
|
||||
local form = "size[10,10]dropdown[0,0;3;env;"..table.concat(envs_asvalues, ",")..";"..sel.."]"
|
||||
.."button[4,0;2,1;save;Save]button[7,0;2,1;cle;Clear local env] textarea[0.2,1;10,10;code;Code;"..minetest.formspec_escape(code).."]"
|
||||
.."label[0,9.8;"..err.."]"
|
||||
local form = "size["..atlatc.CODE_FORM_SIZE.."]"
|
||||
.."style[code;font=mono]"
|
||||
.."label[0,-0.1;Environment]"
|
||||
.."dropdown[0,0.3;3;env;"..table.concat(envs_asvalues, ",")..";"..sel.."]"
|
||||
.."button[5,0.2;2,1;save;Save]"
|
||||
.."button[7,0.2;3,1;cle;Clear Local Env.]"
|
||||
.."textarea[0.3,1.5;"..atlatc.CODE_FORM_SIZE..";code;Code;"..minetest.formspec_escape(code).."]"
|
||||
.."label[0,9.7;"..err.."]"
|
||||
return form
|
||||
end
|
||||
|
||||
|
|
|
@ -151,6 +151,14 @@ function r.fire_event(pos, evtdata, appr_internal)
|
|||
advtrains.trains[train_id].text_inside=text
|
||||
return true
|
||||
end,
|
||||
atc_get_text_outside = function()
|
||||
if not train_id then return false end
|
||||
return advtrains.trains[train_id].text_outside
|
||||
end,
|
||||
atc_get_text_inside = function(text)
|
||||
if not train_id then return false end
|
||||
return advtrains.trains[train_id].text_inside
|
||||
end,
|
||||
atc_set_lzb_tsr = function(speed)
|
||||
if not appr_internal then
|
||||
error("atc_set_lzb_tsr() can only be used during 'approach' events!")
|
||||
|
@ -193,7 +201,10 @@ advtrains.register_tracks("default", {
|
|||
--set arrowconn (for ATC)
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
|
||||
atlatc.active.nodes[ph].arrowconn=conns[1].c
|
||||
local nodeent = atlatc.active.nodes[ph]
|
||||
if nodeent then
|
||||
nodeent.arrowconn=conns[1].c
|
||||
end
|
||||
end,
|
||||
|
||||
advtrains = {
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
--chatcmds.lua
|
||||
--Registers commands to modify the init and step code for LuaAutomation
|
||||
|
||||
--position helper.
|
||||
--punching a node will result in that position being saved and inserted into a text field on the top of init form.
|
||||
local punchpos={}
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, player, pointed_thing)
|
||||
local pname=player:get_player_name()
|
||||
punchpos[pname]=pos
|
||||
end)
|
||||
|
||||
local function get_init_form(env, pname)
|
||||
local err = env.init_err or ""
|
||||
local code = env.init_code or ""
|
||||
local ppos=punchpos[pname]
|
||||
local pp=""
|
||||
if ppos then
|
||||
pp="POS"..minetest.pos_to_string(ppos)
|
||||
end
|
||||
local form = "size[10,10]button[0,0;2,1;run;Run InitCode]button[2,0;2,1;cls;Clear S]"
|
||||
.."button[4,0;2,1;save;Save] button[6,0;2,1;del;Delete Env.] field[8.1,0.5;2,1;punchpos;Last punched position;"..pp.."]"
|
||||
.."textarea[0.2,1;10,10;code;Environment initialization code;"..minetest.formspec_escape(code).."]"
|
||||
.."label[0,9.8;"..err.."]"
|
||||
|
||||
local form = "size["..atlatc.CODE_FORM_SIZE.."]"
|
||||
.."style[code;font=mono]"
|
||||
.."button[0.0,0.2;2.5,1;run;Run Init Code]"
|
||||
.."button[2.5,0.2;2.5,1;cls;Clear S]"
|
||||
.."button[5.0,0.2;2.5,1;save;Save]"
|
||||
.."button[7.5,0.2;2.5,1;del;Delete Env.]"
|
||||
.."textarea[0.3,1.5;"..atlatc.CODE_FORM_SIZE..";code;Environment initialization code;"..minetest.formspec_escape(code).."]"
|
||||
.."label[0.0,9.7;"..err.."]"
|
||||
return form
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
advtrains
|
||||
advtrains_interlocking?
|
||||
advtrains_line_automation?
|
||||
mesecons_switch?
|
|
@ -153,6 +153,17 @@ local static_env = {
|
|||
local pos=atlatc.pcnaming.resolve_pos(parpos)
|
||||
atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg})
|
||||
end,
|
||||
-- sends an atc command to train regardless of where it is in the world
|
||||
atc_send_to_train = function(train_id, command)
|
||||
assertt(command, "string")
|
||||
local train = advtrains.trains[train_id]
|
||||
if train then
|
||||
advtrains.atc.train_set_command(train, command, true)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
-- If interlocking is present, enable route setting functions
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
-- Lua automation features for advtrains
|
||||
-- Uses global table 'atlatc' (AdvTrains_LuaATC)
|
||||
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
if intllib then
|
||||
atltrans = intllib.Getter()
|
||||
else
|
||||
--TODO: re-add localization (if merging localization, discard this hunk please)
|
||||
atltrans = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
|
||||
end
|
||||
|
||||
--Privilege
|
||||
--Only trusted players should be enabled to build stuff which can break the server.
|
||||
|
@ -16,6 +12,9 @@ atlatc = { envs = {}}
|
|||
|
||||
minetest.register_privilege("atlatc", { description = "Player can place and modify LUA ATC components. Grant with care! Allows to execute bad LUA code.", give_to_singleplayer = false, default= false })
|
||||
|
||||
--Size of code input forms in X,Y notation. Must be at least 10x10
|
||||
atlatc.CODE_FORM_SIZE = "15,12"
|
||||
|
||||
--assertt helper. error if a variable is not of a type
|
||||
function assertt(var, typ)
|
||||
if type(var)~=typ then
|
||||
|
|
7
mods/advtrains/advtrains_luaautomation/mod.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
name=advtrains_luaautomation
|
||||
title=Advanced Trains LuaATC
|
||||
description=Lua control interface to Advanced Trains
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains
|
||||
optional_depends=advtrains_interlocking,advtrains_line_automation,mesecons_switch
|
|
@ -1,2 +0,0 @@
|
|||
advtrains
|
||||
advtrains_interlocking
|
16
mods/advtrains/advtrains_signals_ks/init.lua
Normal file → Executable file
|
@ -105,7 +105,6 @@ for _, rtab in ipairs({
|
|||
},
|
||||
drop = "advtrains_signals_ks:hs_danger_0",
|
||||
inventory_image = "advtrains_signals_ks_hs_inv.png",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
advtrains = {
|
||||
set_aspect = setaspectf(rot),
|
||||
supported_aspects = suppasp,
|
||||
|
@ -115,6 +114,7 @@ for _, rtab in ipairs({
|
|||
},
|
||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||
can_dig = advtrains.interlocking.signal_can_dig,
|
||||
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||
})
|
||||
-- rotatable by trackworker
|
||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:hs", typ, "_"..rot, prts.n)
|
||||
|
@ -150,7 +150,6 @@ for _, rtab in ipairs({
|
|||
},
|
||||
drop = "advtrains_signals_ks:ra_danger_0",
|
||||
inventory_image = "advtrains_signals_ks_ra_inv.png",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
advtrains = {
|
||||
set_aspect = setaspectf_ra(rot),
|
||||
supported_aspects = suppasp_ra,
|
||||
|
@ -160,6 +159,7 @@ for _, rtab in ipairs({
|
|||
},
|
||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||
can_dig = advtrains.interlocking.signal_can_dig,
|
||||
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||
})
|
||||
-- rotatable by trackworker
|
||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:ra", typ, "_"..rot, prts.n)
|
||||
|
@ -201,7 +201,6 @@ for _, rtab in ipairs({
|
|||
},
|
||||
drop = "advtrains_signals_ks:sign_8_0",
|
||||
inventory_image = "advtrains_signals_ks_sign_8.png",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
advtrains = {
|
||||
-- This is a static signal! No set_aspect
|
||||
get_aspect = function(pos, node)
|
||||
|
@ -210,6 +209,7 @@ for _, rtab in ipairs({
|
|||
},
|
||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||
can_dig = advtrains.interlocking.signal_can_dig,
|
||||
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||
})
|
||||
-- rotatable by trackworker
|
||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:sign", typ, "_"..rot, prts.n)
|
||||
|
@ -236,7 +236,6 @@ for _, rtab in ipairs({
|
|||
not_in_creative_inventory = (rtab.ici) and 0 or 1,
|
||||
},
|
||||
drop = "advtrains_signals_ks:mast_mast_0",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:mast","mast", "_"..rot)
|
||||
end
|
||||
|
@ -270,11 +269,18 @@ minetest.register_craft({
|
|||
},
|
||||
})
|
||||
|
||||
local sign_material = "default:sign_wall_steel" --fallback
|
||||
if minetest.get_modpath("basic_materials") then
|
||||
sign_material = "basic_materials:plastic_sheet"
|
||||
end
|
||||
--print("Sign Material: "..sign_material)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "advtrains_signals_ks:sign_8_0 2",
|
||||
recipe = {
|
||||
{'basic_materials:plastic_sheet', 'dye:black'},
|
||||
{sign_material, 'dye:black'},
|
||||
{'default:stick', ''},
|
||||
{'default:stick', ''},
|
||||
},
|
||||
})
|
||||
sign_material = nil
|
||||
|
|
6
mods/advtrains/advtrains_signals_ks/mod.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
name=advtrains_signals_ks
|
||||
title=Advtrains Interlocking Signal Set - German 'Ks' signals
|
||||
description=Default signal set for the Advanced Trains Interlocking system
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains_interlocking
|
|
@ -1,3 +0,0 @@
|
|||
advtrains
|
||||
advtrains_train_track
|
||||
intllib?
|
|
@ -1,3 +0,0 @@
|
|||
advtrains
|
||||
advtrains_train_track
|
||||
intllib?
|
|
@ -1,3 +0,0 @@
|
|||
advtrains
|
||||
advtrains_train_track
|
||||
intllib?
|
|
@ -1,3 +0,0 @@
|
|||
advtrains
|
||||
advtrains_train_track
|
||||
intllib?
|
|
@ -1,4 +0,0 @@
|
|||
default
|
||||
advtrains
|
||||
mesecons?
|
||||
digtron?
|
16
mods/advtrains/advtrains_train_track/init.lua
Normal file → Executable file
|
@ -228,7 +228,7 @@ local function train_load(pos, train_id, unload)
|
|||
for k, v in ipairs(train.trainparts) do
|
||||
|
||||
local i=minetest.get_inventory({type="detached", name="advtrains_wgn_"..v})
|
||||
if i then
|
||||
if i and i:get_list("box") then
|
||||
if not unload then
|
||||
for _, item in ipairs(inv:get_list("main")) do
|
||||
if i:get_list("box") and i:room_for_item("box", item) then
|
||||
|
@ -298,15 +298,27 @@ advtrains.register_tracks("default", {
|
|||
end
|
||||
}, advtrains.trackpresets.t_30deg_straightonly)
|
||||
|
||||
-- mod-dependent crafts
|
||||
local loader_core = "default:mese_crystal" --fallback
|
||||
if minetest.get_modpath("basic_materials") then
|
||||
loader_core = "basic_materials:ic"
|
||||
elseif minetest.get_modpath("technic") then
|
||||
loader_core = "technic:control_logic_unit"
|
||||
end
|
||||
--print("Loader Core: "..loader_core)
|
||||
|
||||
minetest.register_craft({
|
||||
type="shapeless",
|
||||
output = 'advtrains:dtrack_load_placer',
|
||||
recipe = {
|
||||
"advtrains:dtrack_placer",
|
||||
"basic_materials:ic",
|
||||
loader_core,
|
||||
"default:chest"
|
||||
},
|
||||
})
|
||||
loader_core = nil --nil the crafting variable
|
||||
|
||||
--craft between load/unload tracks
|
||||
minetest.register_craft({
|
||||
type="shapeless",
|
||||
output = 'advtrains:dtrack_unload_placer',
|
||||
|
|
7
mods/advtrains/advtrains_train_track/mod.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
name=advtrains_train_track
|
||||
title=Advtrains Default Tracks
|
||||
description=Default track set for Advanced Trains
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains
|
||||
optional_depends=mesecons,digtron
|
4
mods/advtrains/assets/mod.conf
Normal file
|
@ -0,0 +1,4 @@
|
|||
name=advtrains_assets
|
||||
title=(Not a mod) Advtrains blender models and raw textures
|
||||
description=Directory containing the model and texture files for future reference. Not included in release.
|
||||
author=orwell96
|
4
mods/advtrains/modpack.conf
Normal file
|
@ -0,0 +1,4 @@
|
|||
name=advtrains
|
||||
title=Advanced Trains
|
||||
description=Realistic trains and various equipment for railways, with a focus on automated train operation. No trains included, please install those separately.
|
||||
author=orwell96
|
120
mods/advtrains/serialize_lib/api.md
Normal file
|
@ -0,0 +1,120 @@
|
|||
# serialize_lib API
|
||||
|
||||
## Serialization Library (serialize.lua)
|
||||
|
||||
### config table
|
||||
|
||||
Serialization functions accept a config table. Currently only one configuration option is defined.
|
||||
|
||||
config = {
|
||||
skip_empty_tables = false
|
||||
-- used for write_to_fd/write_to_file
|
||||
-- if true, does not store empty tables
|
||||
-- On next read, keys that mapped to empty tables resolve to nil
|
||||
}
|
||||
|
||||
If you want to use all-default config options, you can pass `nil` as the config parameter.
|
||||
|
||||
### Serialization limits
|
||||
|
||||
* Only strings, booleans, numbers and tables can be serialized, no functions or userdata
|
||||
* serialize_lib requires that no reference loops are present in the table to be serialized. Currently, when passing a table that has a reference loop, serialize_lib will produce a stack overflow.
|
||||
|
||||
### Functions
|
||||
|
||||
All of these functions call `error(<message>)` if an error occurs. Errors can be caught with `pcall()`.
|
||||
|
||||
#### write_to_fd(root_table, file, config)
|
||||
Writes the contents of `root_table` to the file from the file handle given by `file`, and closes the file descriptor afterwards.
|
||||
|
||||
#### write_to_file(root_table, filename, config)
|
||||
First, opens `filename` for write. Then, writes the contents of `root_table` to the file.
|
||||
|
||||
#### read_from_fd(file)
|
||||
Reads the file from the file handle given by `file`, and closes the file descriptor afterwards. Returns the deserialized table.
|
||||
|
||||
#### read_from_file(filename)
|
||||
First, opens `filename` for read. Then, reads the file and returns the deserialized table.
|
||||
|
||||
### External Lua Module
|
||||
serialize.lua can be loaded as a standard Lua module even outside Minetest, like this:
|
||||
|
||||
local serialize = require("serialize")
|
||||
|
||||
## General API
|
||||
|
||||
### Minetest wrappers for serialization functions
|
||||
|
||||
Serialize_lib wraps write_to_file and read_from_file into 2 functions that do not throw errors but instead log the fact to the server log and have an appropriate return value:
|
||||
|
||||
#### serialize_lib.write_table_to_file(root_table, filename)
|
||||
|
||||
Serializes `root_table` into `filename`. On success, returns true. On failure, logs the error, then returns false and the error message.
|
||||
|
||||
#### serialize_lib.read_table_from_file(filename)
|
||||
|
||||
Deserializes the given file. On success, returns the deserialized table. On failure, logs the error, then returns false and the error message.
|
||||
|
||||
## Atomic API
|
||||
|
||||
serialize_lib provides functions for atomic saving. This means that if the process is interrupted during writing the save file, it is ensured that no save data gets corrupted and that instead the old state is read.
|
||||
|
||||
The atomic system is flexible, and can be used not only to save serialized Lua tables but arbitrary file formats by means of a callback function. This callback function gets passed a file descriptor to operate on.
|
||||
|
||||
### Concept
|
||||
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)
|
||||
|
||||
### Functions
|
||||
|
||||
All of these functions return either true on success or nil, error on error.
|
||||
|
||||
#### serialize_lib.load_atomic(filename, callback)
|
||||
|
||||
Load a saved state.
|
||||
|
||||
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.
|
||||
|
||||
#### serialize_lib.save_atomic(data, filename, callback, config)
|
||||
|
||||
Save a file atomically.
|
||||
|
||||
'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!
|
||||
|
||||
#### serialize_lib.save_atomic_multiple(parts_table, filename_prefix, callbacks_table, config)
|
||||
|
||||
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.
|
||||
|
||||
* Example: 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!
|
|
@ -65,7 +65,7 @@ local function save_atomic_move_file(filename)
|
|||
end
|
||||
|
||||
local function open_file_and_save_callback(callback, filename)
|
||||
local file, err = io.open(filename, "w")
|
||||
local file, err = io.open(filename, "wb")
|
||||
if not file then
|
||||
error("Failed opening file '"..filename.."' for write:\n"..err)
|
||||
end
|
||||
|
@ -75,7 +75,7 @@ local function open_file_and_save_callback(callback, filename)
|
|||
end
|
||||
|
||||
local function open_file_and_load_callback(filename, callback)
|
||||
local file, err = io.open(filename, "r")
|
||||
local file, err = io.open(filename, "rb")
|
||||
if not file then
|
||||
error("Failed opening file '"..filename.."' for read:\n"..err)
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ function serialize_lib.load_atomic(filename, callback)
|
|||
local cbfunc = callback or ser.read_from_fd
|
||||
|
||||
-- try <filename>
|
||||
local file, ret = io.open(filename, "r")
|
||||
local file, ret = io.open(filename, "rb")
|
||||
if file then
|
||||
-- read the file using the callback
|
||||
local success
|
||||
|
@ -107,7 +107,7 @@ function serialize_lib.load_atomic(filename, callback)
|
|||
end
|
||||
end
|
||||
|
||||
if minetest.settings:get_bool("serialize_lib_strict_loading") then
|
||||
if minetest.settings:get_bool("serialize_lib_strict_loading", true) then
|
||||
serialize_lib.save_lock = true
|
||||
error("Loading data from file '"..filename.."' failed:\n"
|
||||
..ret.."\nDisable Strict Loading to ignore.")
|
||||
|
@ -117,7 +117,7 @@ function serialize_lib.load_atomic(filename, callback)
|
|||
serialize_lib.log_warn(ret)
|
||||
|
||||
-- try <filename>.new
|
||||
file, ret = io.open(filename..".new", "r")
|
||||
file, ret = io.open(filename..".new", "rb")
|
||||
if file then
|
||||
-- read the file using the callback
|
||||
local success
|
||||
|
@ -151,7 +151,7 @@ function serialize_lib.save_atomic(data, filename, callback, config)
|
|||
|
||||
local cbfunc = callback or ser.write_to_fd
|
||||
|
||||
local file, ret = io.open(filename..".new", "w")
|
||||
local file, ret = io.open(filename..".new", "wb")
|
||||
if file then
|
||||
-- save the file using the callback
|
||||
local success
|
||||
|
@ -189,7 +189,7 @@ function serialize_lib.save_atomic_multiple(parts_table, filename_prefix, callba
|
|||
end
|
||||
|
||||
local success = false
|
||||
local file, ret = io.open(filename..".new", "w")
|
||||
local file, ret = io.open(filename..".new", "wb")
|
||||
if file then
|
||||
-- save the file using the callback
|
||||
success, ret = pcall(cbfunc, data, file, config)
|
||||
|
|
|
@ -57,6 +57,7 @@ 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)
|
||||
return false,ret
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
@ -67,8 +68,9 @@ 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)
|
||||
return false,ret
|
||||
end
|
||||
return ret
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
|
662
mods/advtrains/serialize_lib/license.txt
Normal file
|
@ -0,0 +1,662 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
|
||||
Copyright (C) {{ year }} {{ organization }}
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
|
@ -1 +1,4 @@
|
|||
name=serialize_lib
|
||||
title=Lua Serialization Library
|
||||
description=A library to efficiently write and read Lua tables to/from a file, with support for atomic operations
|
||||
author=orwell96
|
||||
|
|
|
@ -5,3 +5,44 @@ 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.
|
||||
|
||||
## API documentation
|
||||
|
||||
For API documentation, see `api.md`.
|
||||
|
||||
## Configuration
|
||||
|
||||
serialize_lib includes two configuration options:
|
||||
|
||||
### serialize_lib_strict_loading (Strict loading)
|
||||
* Type: boolean
|
||||
* Default: false
|
||||
|
||||
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_no_auto_windows_mode (No automatic Windows Mode)
|
||||
* Type: boolean
|
||||
* Default: 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.
|
||||
|
||||
## License
|
||||
serialize_lib
|
||||
Copyright (C) 2020-2021 orwell96
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
@ -3,6 +3,9 @@
|
|||
-- Contains the serialization and deserialization routines
|
||||
|
||||
--[[
|
||||
Version history:
|
||||
1 - initial
|
||||
2 - also escaping CR character as &r
|
||||
|
||||
Structure of entry:
|
||||
[keytype][key]:[valuetype][val]
|
||||
|
@ -19,7 +22,7 @@ Table:
|
|||
E
|
||||
|
||||
example:
|
||||
LUA_SER v=1 {
|
||||
LUA_SER v=2 {
|
||||
Skey:Svalue key = "value",
|
||||
N1:Seins [1] = "eins",
|
||||
B1:T [true] = {
|
||||
|
@ -32,7 +35,7 @@ String representations:
|
|||
In strings the following characters are escaped by &
|
||||
'&' -> '&&'
|
||||
(line break) -> '&n'
|
||||
(CR) -> '&r' --> required?
|
||||
(CR) -> '&r'
|
||||
':' -> '&:'
|
||||
All other characters are unchanged as they bear no special meaning.
|
||||
]]
|
||||
|
@ -97,6 +100,7 @@ end
|
|||
function escape_chars(str)
|
||||
local rstr = string.gsub(str, "&", "&&")
|
||||
rstr = string.gsub(rstr, ":", "&:")
|
||||
rstr = string.gsub(rstr, "\r", "&r")
|
||||
rstr = string.gsub(rstr, "\n", "&n")
|
||||
return rstr
|
||||
end
|
||||
|
@ -113,6 +117,8 @@ function read_table(t, file)
|
|||
file:close()
|
||||
error("Unexpected EOF or read error!")
|
||||
end
|
||||
-- possibly windows fix: strip trailing \r's from line
|
||||
line = string.gsub(line, "\r$", "")
|
||||
|
||||
if line=="E" then
|
||||
-- done with this table
|
||||
|
@ -172,6 +178,7 @@ end
|
|||
function unescape_chars(str) --TODO
|
||||
local rstr = string.gsub(str, "&:", ":")
|
||||
rstr = string.gsub(rstr, "&n", "\n")
|
||||
rstr = string.gsub(rstr, "&r", "\r")
|
||||
rstr = string.gsub(rstr, "&&", "&")
|
||||
return rstr
|
||||
end
|
||||
|
@ -187,7 +194,7 @@ config = {
|
|||
|
||||
-- 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")
|
||||
file:write("LUA_SER v=2\n")
|
||||
write_table(root_table, file, config)
|
||||
file:write("E\nEND_SER\n")
|
||||
file:close()
|
||||
|
@ -197,14 +204,18 @@ end
|
|||
-- 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
|
||||
local first_line = file:read("*line")
|
||||
-- possibly windows fix: strip trailing \r's from line
|
||||
first_line = string.gsub(first_line, "\r$", "")
|
||||
if not string.match(first_line, "LUA_SER v=[12]") then
|
||||
file:close()
|
||||
error("Expected header, got '"..first_line.."' instead!")
|
||||
end
|
||||
local t = {}
|
||||
read_table(t, file)
|
||||
local last_line = file:read("*l")
|
||||
local last_line = file:read("*line")
|
||||
-- possibly windows fix: strip trailing \r's from line
|
||||
last_line = string.gsub(last_line, "\r$", "")
|
||||
file:close()
|
||||
if last_line ~= "END_SER" then
|
||||
error("Missing END_SER, got '"..last_line.."' instead!")
|
||||
|
@ -216,7 +227,7 @@ end
|
|||
-- config: see above
|
||||
function write_to_file(root_table, filename, config)
|
||||
-- try opening the file
|
||||
local file, err = io.open(filename, "w")
|
||||
local file, err = io.open(filename, "wb")
|
||||
if not file then
|
||||
error("Failed opening file '"..filename.."' for write:\n"..err)
|
||||
end
|
||||
|
@ -228,7 +239,7 @@ 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")
|
||||
local file, err = io.open(filename, "rb")
|
||||
if not file then
|
||||
error("Failed opening file '"..filename.."' for read:\n"..err)
|
||||
end
|
||||
|
|
|
@ -18,5 +18,7 @@ Based on Immersive Sounds .36 mod by Neuromancer and optimized to run on servers
|
|||
- 1.3 - Added API for use with other mods, code rewrite
|
||||
- 1.4 - Re-ordered water sets to come before fire and lava, day/night sounds play when leaves around and above ground
|
||||
- 1.5 - Added 'flame_sound' and fire redo check, code tidy and tweak, added ephemeral flag for background sounds.
|
||||
- 1.6 - Finding env_sounds disables water and lava sets, added 'ambience_water_move' flag to override water walking sounds, use eye level for head node.
|
||||
- 1.7 - Music will play every 20-30 minutes if found, use '/mvol 0' to stop playing music or disable in-game.
|
||||
|
||||
Code license: MIT
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
|
||||
ambience = {}
|
||||
|
||||
-- override default water sounds
|
||||
minetest.override_item("default:water_source", { sounds = {} })
|
||||
minetest.override_item("default:water_flowing", { sounds = {} })
|
||||
minetest.override_item("default:river_water_source", { sounds = {} })
|
||||
minetest.override_item("default:river_water_flowing", { sounds = {} })
|
||||
|
||||
-- settings
|
||||
local SOUNDVOLUME = 1.0
|
||||
local MUSICVOLUME = 1.0
|
||||
local MUSICVOLUME = 0.6
|
||||
local play_music = minetest.settings:get_bool("ambience_music") ~= false
|
||||
local pplus = minetest.get_modpath("playerplus")
|
||||
local radius = 6
|
||||
|
@ -19,8 +13,6 @@ local sound_set_order = {} -- needed because pairs loops randomly through tables
|
|||
local set_nodes = {} -- all the nodes needed for sets
|
||||
|
||||
|
||||
-- global functions
|
||||
|
||||
-- add set to list
|
||||
ambience.add_set = function(set_name, def)
|
||||
|
||||
|
@ -73,11 +65,8 @@ end
|
|||
|
||||
-- return set from list using name
|
||||
ambience.get_set = function(set_name)
|
||||
|
||||
if sound_sets[set_name] then
|
||||
return sound_sets[set_name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- remove set from list
|
||||
|
@ -100,42 +89,61 @@ ambience.del_set = function(set_name)
|
|||
end
|
||||
|
||||
|
||||
-- setup table when player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
playing[player:get_player_name()] = {music = -1}
|
||||
end)
|
||||
|
||||
-- remove table when player leaves
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
playing[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
|
||||
-- plays music and selects sound set
|
||||
local get_ambience = function(player, tod, name)
|
||||
|
||||
-- play server or local music if available
|
||||
if play_music and playing[name] then
|
||||
-- play server or local music if music enabled and music not already playing
|
||||
if play_music and MUSICVOLUME > 0
|
||||
and playing[name] and playing[name].music < 0 then
|
||||
|
||||
-- play at midnight
|
||||
if tod >= 0.0 and tod <= 0.01 then
|
||||
-- count backwards
|
||||
playing[name].music = playing[name].music -1
|
||||
|
||||
if not playing[name].music then
|
||||
-- play music every 20 minutes
|
||||
if playing[name].music < -(60 * 20) then
|
||||
|
||||
playing[name].music = minetest.sound_play("ambience_music", {
|
||||
to_player = player:get_player_name(),
|
||||
to_player = name,
|
||||
gain = MUSICVOLUME
|
||||
})
|
||||
|
||||
-- reset music timer after 10 minutes
|
||||
minetest.after(60 * 10, function(name)
|
||||
|
||||
if playing[name] then
|
||||
playing[name].music = -1
|
||||
end
|
||||
end, name)
|
||||
end
|
||||
|
||||
elseif tod > 0.1 and playing[name].music then
|
||||
--print("-- music count", playing[name].music)
|
||||
|
||||
playing[name].music = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- get foot and head level nodes at player position
|
||||
local pos = player:get_pos() ; if not pos then return end
|
||||
local prop = player:get_properties()
|
||||
|
||||
pos.y = pos.y + 1.4 -- head level
|
||||
pos.y = pos.y + prop.eye_height -- eye level
|
||||
|
||||
local nod_head = pplus and name and playerplus[name].nod_head or
|
||||
minetest.get_node(pos).name
|
||||
local nod_head = pplus and name and playerplus[name]
|
||||
and playerplus[name].nod_head or minetest.get_node(pos).name
|
||||
|
||||
pos.y = pos.y - 1.2 -- foot level
|
||||
pos.y = (pos.y - prop.eye_height) + 0.2 -- foot level
|
||||
|
||||
local nod_feet = pplus and name and playerplus[name].nod_feet or
|
||||
minetest.get_node(pos).name
|
||||
local nod_feet = pplus and name and playerplus[name]
|
||||
and playerplus[name].nod_feet or minetest.get_node(pos).name
|
||||
|
||||
pos.y = pos.y - 0.2 -- reset pos
|
||||
|
||||
|
@ -168,6 +176,8 @@ local get_ambience = function(player, tod, name)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil, nil -- ADDED
|
||||
end
|
||||
|
||||
|
||||
|
@ -182,49 +192,44 @@ minetest.register_globalstep(function(dtime)
|
|||
if timer < 1 then return end
|
||||
timer = 0
|
||||
|
||||
-- get list of players and set some variables
|
||||
local players = minetest.get_connected_players()
|
||||
local player_name, number, chance, ambience, handler, ok
|
||||
local tod = minetest.get_timeofday()
|
||||
|
||||
-- loop through players
|
||||
for n = 1, #players do
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
|
||||
player_name = players[n]:get_player_name()
|
||||
player_name = player:get_player_name()
|
||||
|
||||
--local t1 = os.clock()
|
||||
|
||||
local set_name, MORE_GAIN = get_ambience(players[n], tod, player_name)
|
||||
local set_name, MORE_GAIN = get_ambience(player, tod, player_name)
|
||||
|
||||
--print(string.format("elapsed time: %.4f\n", os.clock() - t1))
|
||||
|
||||
ok = true -- everything starts off ok
|
||||
ok = playing[player_name] -- everything starts off ok if player found
|
||||
|
||||
-- are we playing something already?
|
||||
if ok and playing[player_name].handler then
|
||||
|
||||
-- stop current sound if another set active or gain changed
|
||||
if playing[player_name]
|
||||
and playing[player_name].handler then
|
||||
|
||||
if playing[player_name].set ~= set_name
|
||||
or (playing[player_name].set == set_name
|
||||
and playing[player_name].gain ~= MORE_GAIN) then
|
||||
or playing[player_name].gain ~= MORE_GAIN then
|
||||
|
||||
--print ("-- change stop", set_name, playing[player_name].old_handler)
|
||||
--print ("-- change stop", set_name, playing[player_name].handler)
|
||||
|
||||
minetest.sound_stop(playing[player_name].old_handler)
|
||||
minetest.sound_stop(playing[player_name].handler)
|
||||
|
||||
playing[player_name].set = nil
|
||||
playing[player_name].handler = nil
|
||||
playing[player_name].gain = nil
|
||||
playing[player_name].handler = nil
|
||||
else
|
||||
ok = false -- sound set still playing, skip new sound
|
||||
end
|
||||
end
|
||||
|
||||
-- set random chance and reset seed
|
||||
-- set random chance
|
||||
chance = random(1, 1000)
|
||||
|
||||
math.randomseed(tod + chance)
|
||||
|
||||
-- if chance is lower than set frequency then select set
|
||||
if ok and set_name and chance < sound_sets[set_name].frequency then
|
||||
|
||||
|
@ -248,33 +253,29 @@ minetest.register_globalstep(function(dtime)
|
|||
--print("-- current handler", handler)
|
||||
|
||||
-- set what player is currently listening to
|
||||
playing[player_name] = {
|
||||
set = set_name, gain = MORE_GAIN,
|
||||
handler = handler, old_handler = handler
|
||||
}
|
||||
playing[player_name].set = set_name
|
||||
playing[player_name].gain = MORE_GAIN
|
||||
playing[player_name].handler = handler
|
||||
|
||||
-- set timer to stop sound
|
||||
minetest.after(ambience.length, function()
|
||||
|
||||
--print("-- after", set_name, handler)
|
||||
|
||||
-- make sure we are stopping same sound we started
|
||||
if playing[player_name]
|
||||
and playing[player_name].handler
|
||||
and playing[player_name].old_handler == handler then
|
||||
minetest.after(ambience.length, function(handler, player_name)
|
||||
|
||||
--print("-- timed stop", set_name, handler)
|
||||
|
||||
--minetest.sound_stop(playing[player_name].handler)
|
||||
if handler then
|
||||
minetest.sound_stop(handler)
|
||||
|
||||
-- reset player variables and backup handler
|
||||
playing[player_name] = {
|
||||
set = nil, gain = nil,
|
||||
handler = nil, old_handler = nil
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
-- reset variables if handlers match
|
||||
if playing[player_name]
|
||||
and playing[player_name].handler == handler then
|
||||
|
||||
--print("-- timed reset", handler, player_name)
|
||||
|
||||
playing[player_name].set = nil
|
||||
playing[player_name].gain = nil
|
||||
playing[player_name].handler = nil
|
||||
end
|
||||
end, handler, player_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -295,30 +296,34 @@ minetest.register_chatcommand("svol", {
|
|||
if SOUNDVOLUME > 1.0 then SOUNDVOLUME = 1.0 end
|
||||
|
||||
return true, "Sound volume set to " .. SOUNDVOLUME
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- music volume command (0 stops music)
|
||||
minetest.register_chatcommand("mvol", {
|
||||
params = "<mvol>",
|
||||
description = "set music volume (0.1 to 1.0)",
|
||||
description = "set music volume (0.1 to 1.0, 0 to stop music)",
|
||||
privs = {server = true},
|
||||
|
||||
func = function(name, param)
|
||||
|
||||
MUSICVOLUME = tonumber(param) or MUSICVOLUME
|
||||
|
||||
-- ability to stop music just as it begins
|
||||
if MUSICVOLUME == 0 and playing[name].music then
|
||||
-- ability to stop music by setting volume to 0
|
||||
if MUSICVOLUME == 0 and playing[name].music
|
||||
and playing[name].music >= 0 then
|
||||
|
||||
minetest.sound_stop(playing[name].music)
|
||||
|
||||
playing[name].music = -1
|
||||
end
|
||||
|
||||
if MUSICVOLUME < 0.1 then MUSICVOLUME = 0.1 end
|
||||
if MUSICVOLUME < 0 then MUSICVOLUME = 0 end
|
||||
if MUSICVOLUME > 1.0 then MUSICVOLUME = 1.0 end
|
||||
|
||||
return true, "Music volume set to " .. MUSICVOLUME
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
# If enabled will play a random music file from ./minetest/sounds at midnight
|
||||
ambience_music (Ambience music) bool true
|
||||
|
||||
# If enabled then ambience will take over sounds when moving in water
|
||||
ambience_water_move (Ambience water movement) bool true
|
||||
|
|
|
@ -25,14 +25,22 @@ ambience.add_set("underwater", {
|
|||
end
|
||||
})
|
||||
|
||||
-- Splashing sound plays when player walks inside water nodes
|
||||
-- Splashing sound plays when player walks inside water nodes (if enabled)
|
||||
|
||||
if minetest.settings:get_bool("ambience_water_move") ~= false then
|
||||
|
||||
-- override default water sounds
|
||||
minetest.override_item("default:water_source", { sounds = {} })
|
||||
minetest.override_item("default:water_flowing", { sounds = {} })
|
||||
minetest.override_item("default:river_water_source", { sounds = {} })
|
||||
minetest.override_item("default:river_water_flowing", { sounds = {} })
|
||||
|
||||
ambience.add_set("splash", {
|
||||
|
||||
frequency = 1000,
|
||||
|
||||
sounds = {
|
||||
{name = "swim_splashing", length = 3},
|
||||
{name = "swim_splashing", length = 3}
|
||||
},
|
||||
|
||||
sound_check = function(def)
|
||||
|
@ -49,7 +57,9 @@ ambience.add_set("splash", {
|
|||
end
|
||||
})
|
||||
|
||||
-- check for env_sounds mod, if not found enable water flowing sounds
|
||||
end
|
||||
|
||||
-- check for env_sounds mod, if not found enable water flowing and lava sounds
|
||||
if not minetest.get_modpath("env_sounds") then
|
||||
|
||||
-- Water sound plays when near flowing water
|
||||
|
@ -102,8 +112,34 @@ ambience.add_set("river", {
|
|||
end
|
||||
})
|
||||
|
||||
-- Lava sound plays when near lava
|
||||
|
||||
ambience.add_set("lava", {
|
||||
|
||||
frequency = 1000,
|
||||
|
||||
sounds = {
|
||||
{name = "lava", length = 7}
|
||||
},
|
||||
|
||||
nodes = {"default:lava_source", "default:lava_flowing"},
|
||||
|
||||
sound_check = function(def)
|
||||
|
||||
local c = (def.totals["default:lava_source"] or 0)
|
||||
+ (def.totals["default:lava_flowing"] or 0)
|
||||
|
||||
if c > 20 then
|
||||
return "lava", 0.5
|
||||
|
||||
elseif c > 5 then
|
||||
return "lava"
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
else
|
||||
print ("[Ambience] found env_sounds, flowing water sounds disabled.")
|
||||
print ("[Ambience] found env_sounds, flowing water and lava sounds disabled.")
|
||||
end
|
||||
|
||||
-- Only add fire sounds set if flame_sound is disabled or fire redo active
|
||||
|
@ -170,32 +206,6 @@ ambience.add_set("largefire", {
|
|||
|
||||
end
|
||||
|
||||
-- Lava sound plays when near lava
|
||||
|
||||
ambience.add_set("lava", {
|
||||
|
||||
frequency = 1000,
|
||||
|
||||
sounds = {
|
||||
{name = "lava", length = 7}
|
||||
},
|
||||
|
||||
nodes = {"default:lava_source", "default:lava_flowing"},
|
||||
|
||||
sound_check = function(def)
|
||||
|
||||
local c = (def.totals["default:lava_source"] or 0)
|
||||
+ (def.totals["default:lava_flowing"] or 0)
|
||||
|
||||
if c > 20 then
|
||||
return "lava", 0.5
|
||||
|
||||
elseif c > 5 then
|
||||
return "lava"
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Beach sounds play when below y-pos 6 and 150+ water source found
|
||||
|
||||
ambience.add_set("beach", {
|
||||
|
@ -228,7 +238,7 @@ ambience.add_set("ice", {
|
|||
frequency = 250,
|
||||
|
||||
sounds = {
|
||||
{name = "icecrack", length = 23},
|
||||
{name = "icecrack", length = 23, gain = 0.7},
|
||||
{name = "desertwind", length = 8},
|
||||
{name = "wind", length = 9}
|
||||
},
|
||||
|
@ -270,7 +280,7 @@ ambience.add_set("desert", {
|
|||
end
|
||||
})
|
||||
|
||||
-- Cave sounds play when below player position Y -25
|
||||
-- Cave sounds play when below player position Y -25 and water nearby
|
||||
|
||||
ambience.add_set("cave", {
|
||||
|
||||
|
@ -283,7 +293,9 @@ ambience.add_set("cave", {
|
|||
|
||||
sound_check = function(def)
|
||||
|
||||
if def.pos.y < -25 then
|
||||
local c = (def.totals["default:water_source"] or 0)
|
||||
|
||||
if c > 0 and def.pos.y < -25 then
|
||||
return "cave"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,4 +4,6 @@ farming?
|
|||
ethereal?
|
||||
moreores?
|
||||
3d_armor?
|
||||
shields?
|
||||
xanadu?
|
||||
mobs?
|
||||
|
|
|
@ -208,6 +208,7 @@ local anvildef = {
|
|||
is_ground_content = false,
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
use_texture_alpha = "clip",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
@ -219,6 +220,21 @@ local anvildef = {
|
|||
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
|
||||
---------------- added
|
||||
can_dig = function(pos, player)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if inv:is_empty("input") and inv:is_empty("output") then
|
||||
|
||||
if not minetest.is_protected(pos, player:get_player_name()) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
-----------------
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
|
|
@ -141,7 +141,46 @@ if minetest.get_modpath("3d_armor") then
|
|||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("shields") then
|
||||
|
||||
if armor.materials.steel then
|
||||
add_tool("shields:shield_steel", "default:steel_ingot", 7)
|
||||
end
|
||||
|
||||
if armor.materials.bronze then
|
||||
add_tool("shields:shield_bronze", "default:bronze_ingot", 7)
|
||||
end
|
||||
|
||||
if armor.materials.diamond then
|
||||
add_tool("shields:shield_diamond", "default:diamond", 7)
|
||||
end
|
||||
|
||||
if armor.materials.gold then
|
||||
add_tool("shields:shield_gold", "default:gold_ingot", 7)
|
||||
end
|
||||
|
||||
if armor.materials.mithril then
|
||||
add_tool("shields:shield_mithril", "moreores:mithril_ingot", 7)
|
||||
end
|
||||
|
||||
if armor.materials.crystal then
|
||||
add_tool("shields:shield_crystal", "ethereal:crystal_ingot", 7)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mobs_monster") then
|
||||
add_tool("mobs:pick_lava", "mobs:lava_orb", 3, true)
|
||||
end
|
||||
|
||||
-- Xanadu mod
|
||||
if minetest.get_modpath("xanadu") then
|
||||
add_tool("xanadu:axe_super", "default:diamond", 18, true)
|
||||
add_tool("mobs:pick_lava", "mobs:lava_orb", 3, true)
|
||||
add_tool("xanadu:helmet_ccrystal", "ethereal:crystal_ingot", 5)
|
||||
add_tool("xanadu:chestplate_ccrystal", "ethereal:crystal_ingot", 8)
|
||||
add_tool("xanadu:leggings_ccrystal", "ethereal:crystal_ingot", 7)
|
||||
add_tool("xanadu:boots_ccrystal", "ethereal:crystal_ingot", 4)
|
||||
add_tool("3d_armor:boots_nyan", "nyancat:nyancat_rainbow", 4)
|
||||
add_tool("3d_armor:helmet_watercrystal", "ethereal:crystal_ingot", 5)
|
||||
add_tool("3d_armor:boots_mese", "default:mese_crystal", 8)
|
||||
end
|
||||
|
|
|
@ -2,11 +2,13 @@ Baked Clay
|
|||
|
||||
This mod lets the player bake clay into hardened blocks and colour them with
|
||||
dye (8x baked clay and 1x dye in centre), stairs and slabs are also available.
|
||||
Cooking baked clay turns it into glazed terracotta blocks.
|
||||
|
||||
https://forum.minetest.net/viewtopic.php?id=8890
|
||||
|
||||
Changelog:
|
||||
|
||||
- 1.0 - Added glazed terracotta blocks when you cook baked clay in furnace (thanks D3monPixel)
|
||||
- 0.9 - Baked clay now works in the technic cnc machine
|
||||
- 0.8 - Cooking clay block in furnace gives natural baked clay which you can dye
|
||||
- 0.7 - Added support for stairsplus so that stairs are registered properly
|
||||
|
@ -17,7 +19,7 @@ Changelog:
|
|||
- 0.2 - Any colour of baked clay can be re-dyed into another colour
|
||||
- 0.1 - Initial Release
|
||||
|
||||
Lucky Blocks: 9
|
||||
Lucky Blocks: 10
|
||||
|
||||
|
||||
Note: Under settings you will find 'colored_clay_compatibility' switch that when enabled will register aliases for the older colored clay mod and it's stairplus stairs.
|
||||
|
|
|
@ -17,7 +17,7 @@ local clay = {
|
|||
{"brown", "Brown"},
|
||||
{"pink", "Pink"},
|
||||
{"dark_grey", "Dark Grey"},
|
||||
{"dark_green", "Dark Green"},
|
||||
{"dark_green", "Dark Green"}
|
||||
}
|
||||
|
||||
local techcnc_mod = minetest.get_modpath("technic_cnc")
|
||||
|
@ -27,42 +27,50 @@ local stairsplus_mod = minetest.get_modpath("moreblocks")
|
|||
|
||||
for _, clay in pairs(clay) do
|
||||
|
||||
-- node definition
|
||||
-- node
|
||||
|
||||
minetest.register_node("bakedclay:" .. clay[1], {
|
||||
description = clay[2] .. " Baked Clay",
|
||||
tiles = {"baked_clay_" .. clay[1] ..".png"},
|
||||
groups = {cracky = 3, bakedclay = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sounds = default.node_sound_stone_defaults()
|
||||
})
|
||||
|
||||
-- craft from dye and any baked clay
|
||||
-- craft recipe
|
||||
|
||||
if clay[1] ~= "natural" then
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bakedclay:" .. clay[1] .. " 8",
|
||||
recipe = {
|
||||
{"group:bakedclay", "group:bakedclay", "group:bakedclay"},
|
||||
{"group:bakedclay", "dye:" .. clay[1], "group:bakedclay"},
|
||||
{"group:bakedclay", "group:bakedclay", "group:bakedclay"}
|
||||
},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- register stairsplus stairs if found
|
||||
-- stairs plus
|
||||
if stairsplus_mod then
|
||||
|
||||
stairsplus:register_all("bakedclay", "baked_clay_" .. clay[1], "bakedclay:" .. clay[1], {
|
||||
stairsplus:register_all("bakedclay", "baked_clay_" .. clay[1],
|
||||
"bakedclay:" .. clay[1], {
|
||||
description = clay[2] .. " Baked Clay",
|
||||
tiles = {"baked_clay_" .. clay[1] .. ".png"},
|
||||
groups = {cracky = 3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sounds = default.node_sound_stone_defaults()
|
||||
})
|
||||
|
||||
stairsplus:register_alias_all("bakedclay", clay[1], "bakedclay", "baked_clay_" .. clay[1])
|
||||
minetest.register_alias("stairs:slab_bakedclay_".. clay[1], "bakedclay:slab_baked_clay_" .. clay[1])
|
||||
minetest.register_alias("stairs:stair_bakedclay_".. clay[1], "bakedclay:stair_baked_clay_" .. clay[1])
|
||||
stairsplus:register_alias_all("bakedclay", clay[1],
|
||||
"bakedclay", "baked_clay_" .. clay[1])
|
||||
|
||||
-- register all stair types for stairs redo
|
||||
minetest.register_alias("stairs:slab_bakedclay_".. clay[1],
|
||||
"bakedclay:slab_baked_clay_" .. clay[1])
|
||||
|
||||
minetest.register_alias("stairs:stair_bakedclay_".. clay[1],
|
||||
"bakedclay:stair_baked_clay_" .. clay[1])
|
||||
|
||||
-- stairs redo
|
||||
elseif stairs_mod and stairs.mod then
|
||||
|
||||
stairs.register_all("bakedclay_" .. clay[1], "bakedclay:" .. clay[1],
|
||||
|
@ -71,7 +79,7 @@ for _, clay in pairs(clay) do
|
|||
clay[2] .. " Baked Clay",
|
||||
default.node_sound_stone_defaults())
|
||||
|
||||
-- register stair and slab using default stairs
|
||||
-- default stairs
|
||||
elseif stairs_mod then
|
||||
|
||||
stairs.register_stair_and_slab("bakedclay_".. clay[1], "bakedclay:".. clay[1],
|
||||
|
@ -92,6 +100,56 @@ for _, clay in pairs(clay) do
|
|||
end
|
||||
end
|
||||
|
||||
-- Terracotta blocks (textures by D3monPixel, thanks for use :)
|
||||
for _, clay in pairs(clay) do
|
||||
|
||||
if clay[1] ~= "natural" then
|
||||
|
||||
local texture = "baked_clay_terracotta_" .. clay[1] ..".png"
|
||||
|
||||
minetest.register_node("bakedclay:terracotta_" .. clay[1], {
|
||||
description = clay[2] .. " Glazed Terracotta",
|
||||
tiles = {
|
||||
texture .. "",
|
||||
texture .. "",
|
||||
texture .. "^[transformR180",
|
||||
texture .. "",
|
||||
texture .. "^[transformR270",
|
||||
texture .. "^[transformR90",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky = 3, terracotta = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "bakedclay:terracotta_" .. clay[1],
|
||||
recipe = "bakedclay:" .. clay[1]
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- special light blue glazed terracotta block
|
||||
local texture = "baked_clay_terracotta_light_blue.png"
|
||||
|
||||
minetest.register_node("bakedclay:terracotta_light_blue", {
|
||||
description = "Light Blue Glazed Terracotta",
|
||||
tiles = {
|
||||
texture .. "",
|
||||
texture .. "",
|
||||
texture .. "^[transformR180",
|
||||
texture .. "",
|
||||
texture .. "^[transformR270",
|
||||
texture .. "^[transformR90",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky = 3, terracotta = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
-- cook clay block into white baked clay
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -108,33 +166,28 @@ minetest.register_craft( {
|
|||
recipe = {"dye:black", "dye:black", "dye:white"}
|
||||
})
|
||||
|
||||
-- only add light grey recipe if unifieddye mod isnt present (conflict)
|
||||
if not minetest.get_modpath("unifieddyes") then
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "dye:grey 3",
|
||||
recipe = {"dye:black", "dye:white", "dye:white"}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "dye:green 4",
|
||||
recipe = {"default:cactus"}
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "dye:black 4",
|
||||
recipe = {"default:coal_lump"}
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "dye:brown 4",
|
||||
recipe = {"default:dry_shrub"}
|
||||
})
|
||||
|
||||
-- only add light grey recipe if unifieddye mod isnt present (conflict)
|
||||
if not minetest.get_modpath("unifieddyes") then
|
||||
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "dye:grey 3",
|
||||
recipe = {"dye:black", "dye:white", "dye:white"}
|
||||
})
|
||||
end
|
||||
|
||||
-- 2x2 red baked clay makes 16x clay brick
|
||||
minetest.register_craft( {
|
||||
output = "default:clay_brick 16",
|
||||
|
@ -176,10 +229,17 @@ local function add_simple_flower(name, desc, box, f_groups)
|
|||
end
|
||||
|
||||
local flowers = {
|
||||
{"delphinium", "Blue Delphinium", {-0.15, -0.5, -0.15, 0.15, 0.3, 0.15}, {color_cyan = 1}},
|
||||
{"thistle", "Thistle", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_magenta = 1}},
|
||||
{"lazarus", "Lazarus Bell", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_pink = 1}},
|
||||
{"mannagrass", "Reed Mannagrass", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_dark_green = 1}},
|
||||
{"delphinium", "Blue Delphinium",
|
||||
{-0.15, -0.5, -0.15, 0.15, 0.3, 0.15}, {color_cyan = 1}},
|
||||
|
||||
{"thistle", "Thistle",
|
||||
{-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_magenta = 1}},
|
||||
|
||||
{"lazarus", "Lazarus Bell",
|
||||
{-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_pink = 1}},
|
||||
|
||||
{"mannagrass", "Reed Mannagrass",
|
||||
{-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_dark_green = 1}}
|
||||
}
|
||||
|
||||
for _,item in pairs(flowers) do
|
||||
|
@ -202,7 +262,7 @@ minetest.register_decoration({
|
|||
},
|
||||
y_min = 10,
|
||||
y_max = 90,
|
||||
decoration = "bakedclay:delphinium",
|
||||
decoration = "bakedclay:delphinium"
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
|
@ -219,7 +279,7 @@ minetest.register_decoration({
|
|||
},
|
||||
y_min = 15,
|
||||
y_max = 90,
|
||||
decoration = "bakedclay:thistle",
|
||||
decoration = "bakedclay:thistle"
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
|
@ -238,7 +298,7 @@ minetest.register_decoration({
|
|||
y_max = 90,
|
||||
decoration = "bakedclay:lazarus",
|
||||
spawn_by = "default:jungletree",
|
||||
num_spawn_by = 1,
|
||||
num_spawn_by = 1
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
|
@ -257,13 +317,15 @@ minetest.register_decoration({
|
|||
y_max = 15,
|
||||
decoration = "bakedclay:mannagrass",
|
||||
spawn_by = "group:water",
|
||||
num_spawn_by = 1,
|
||||
num_spawn_by = 1
|
||||
})
|
||||
|
||||
-- add lucky blocks
|
||||
-- lucky blocks
|
||||
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
|
||||
local p = "bakedclay:"
|
||||
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {"bakedclay:"}, 10, true},
|
||||
{"fal", {p.."black", p.."blue", p.."brown", p.."cyan", p.."dark_green",
|
||||
|
@ -295,13 +357,36 @@ lucky_block:add_blocks({
|
|||
{name = p.."red", max = 30},
|
||||
{name = p.."violet", max = 30},
|
||||
{name = p.."white", max = 30},
|
||||
{name = p.."yellow", max = 30},
|
||||
{name = p.."yellow", max = 30}
|
||||
}},
|
||||
})
|
||||
|
||||
p = "bakedclay:terracotta_"
|
||||
|
||||
lucky_block:add_blocks({
|
||||
{"nod", "default:chest", 0, {
|
||||
{name = p.."light_blue", max = 20},
|
||||
{name = p.."black", max = 20},
|
||||
{name = p.."blue", max = 20},
|
||||
{name = p.."brown", max = 20},
|
||||
{name = p.."cyan", max = 20},
|
||||
{name = p.."dark_green", max = 20},
|
||||
{name = p.."dark_grey", max = 20},
|
||||
{name = p.."green", max = 20},
|
||||
{name = p.."grey", max = 20},
|
||||
{name = p.."magenta", max = 20},
|
||||
{name = p.."orange", max = 20},
|
||||
{name = p.."pink", max = 20},
|
||||
{name = p.."red", max = 20},
|
||||
{name = p.."violet", max = 20},
|
||||
{name = p.."white", max = 20},
|
||||
{name = p.."yellow", max = 20}
|
||||
}}
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- colored clay compatibility
|
||||
|
||||
if minetest.settings:get_bool("colored_clay_compatibility") == true then
|
||||
|
||||
local cc = {
|
||||
|
|
|
@ -19,3 +19,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
Textures by D3monPixel (https://mcpedl.com/better-glazed-terracotta-pack)
|
||||
baked_clay_terracotta*.png
|
||||
|
|
BIN
mods/bakedclay/textures/baked_clay_terracotta_black.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_blue.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_brown.png
Normal file
After Width: | Height: | Size: 718 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_cyan.png
Normal file
After Width: | Height: | Size: 661 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_dark_green.png
Normal file
After Width: | Height: | Size: 714 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_dark_grey.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_green.png
Normal file
After Width: | Height: | Size: 575 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_grey.png
Normal file
After Width: | Height: | Size: 659 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_light_blue.png
Normal file
After Width: | Height: | Size: 589 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_magenta.png
Normal file
After Width: | Height: | Size: 275 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_orange.png
Normal file
After Width: | Height: | Size: 606 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_pink.png
Normal file
After Width: | Height: | Size: 409 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_red.png
Normal file
After Width: | Height: | Size: 292 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_violet.png
Normal file
After Width: | Height: | Size: 619 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_white.png
Normal file
After Width: | Height: | Size: 512 B |
BIN
mods/bakedclay/textures/baked_clay_terracotta_yellow.png
Normal file
After Width: | Height: | Size: 676 B |
|
@ -23,6 +23,7 @@ signs_lib.register_sign("basic_signs:sign_wall_locked", {
|
|||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true,
|
||||
use_texture_alpha = "clip",
|
||||
})
|
||||
|
||||
signs_lib.register_sign("basic_signs:sign_wall_glass", {
|
||||
|
@ -45,7 +46,7 @@ signs_lib.register_sign("basic_signs:sign_wall_glass", {
|
|||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true,
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "blend",
|
||||
})
|
||||
|
||||
signs_lib.register_sign("basic_signs:sign_wall_obsidian_glass", {
|
||||
|
@ -68,7 +69,7 @@ signs_lib.register_sign("basic_signs:sign_wall_obsidian_glass", {
|
|||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true,
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "blend",
|
||||
})
|
||||
|
||||
minetest.register_alias("locked_sign:sign_wall_locked", "basic_signs:sign_wall_locked")
|
||||
|
@ -93,7 +94,7 @@ signs_lib.register_sign("basic_signs:sign_wall_plastic", {
|
|||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true,
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
})
|
||||
|
||||
-- array : color, translated color, default text color
|
||||
|
@ -137,6 +138,7 @@ for i, color in ipairs(sign_colors) do
|
|||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true,
|
||||
use_texture_alpha = "clip",
|
||||
})
|
||||
|
||||
minetest.register_alias("basic_signs:sign_wall_steel_"..color[1].."_onpole", "basic_signs:sign_steel_"..color[1].."_onpole")
|
||||
|
|
2
mods/advtrains/advtrains_train_industrial/init.lua → mods/basic_trains/advtrains_train_industrial/init.lua
Normal file → Executable file
|
@ -45,7 +45,7 @@ advtrains.register_wagon("engine_industrial_big", {
|
|||
seats = {
|
||||
{
|
||||
name=S("Driver Stand (right)"),
|
||||
attach_offset={x=5, y=7, z=20},
|
||||
attach_offset={x=5, y=-3, z=20},
|
||||
view_offset={x=5.2, y=-4, z=11},
|
||||
driving_ctrl_access=true,
|
||||
group = "dstand",
|
6
mods/basic_trains/advtrains_train_industrial/mod.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
name=advtrains_train_industrial
|
||||
title=Advtrains Industrial Train (Basic Trains)
|
||||
description=Industrial train set for Advanced Trains
|
||||
author=orwell96
|
||||
|
||||
depends=advtrains,advtrains_train_track
|