update ambience, bonemeal, cblocks, cottages, farming_redo,
pipeworks, signs_lib, unified inventorymaster
parent
ac8d5c3ae0
commit
5a37e0bece
|
@ -0,0 +1 @@
|
|||
20210626-0349
|
|
@ -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,16 +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
|
||||
|
@ -98,7 +91,7 @@ end
|
|||
|
||||
-- setup table when player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
playing[player:get_player_name()] = {}
|
||||
playing[player:get_player_name()] = {music = -1}
|
||||
end)
|
||||
|
||||
-- remove table when player leaves
|
||||
|
@ -110,35 +103,43 @@ end)
|
|||
-- plays music and selects sound set
|
||||
local get_ambience = function(player, tod, name)
|
||||
|
||||
-- play server or local music if available
|
||||
if play_music then
|
||||
-- play server or local music if music enabled and music not already playing
|
||||
if play_music and MUSICVOLUME > 0 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 = name,
|
||||
gain = MUSICVOLUME
|
||||
})
|
||||
end
|
||||
playing[name].music = minetest.sound_play("ambience_music", {
|
||||
to_player = name,
|
||||
gain = MUSICVOLUME
|
||||
})
|
||||
|
||||
elseif tod > 0.1 and playing[name].music then
|
||||
-- reset music timer after 10 minutes
|
||||
minetest.after(60 * 10, function(name)
|
||||
|
||||
playing[name].music = nil
|
||||
if playing[name] then
|
||||
playing[name].music = -1
|
||||
end
|
||||
end, name)
|
||||
end
|
||||
|
||||
--print("-- music count", playing[name].music)
|
||||
|
||||
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]
|
||||
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]
|
||||
and playerplus[name].nod_feet or minetest.get_node(pos).name
|
||||
|
@ -190,23 +191,21 @@ 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 = playing[player_name] -- everything starts off ok if player around
|
||||
ok = playing[player_name] -- everything starts off ok if player found
|
||||
|
||||
-- are we playing something already?
|
||||
if ok and playing[player_name].handler then
|
||||
|
@ -258,25 +257,24 @@ minetest.register_globalstep(function(dtime)
|
|||
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].handler == handler then
|
||||
minetest.after(ambience.length, function(handler, player_name)
|
||||
|
||||
--print("-- timed stop", set_name, handler)
|
||||
|
||||
if handler then
|
||||
minetest.sound_stop(handler)
|
||||
end
|
||||
|
||||
-- reset variables if handlers match
|
||||
if playing[player_name]
|
||||
and playing[player_name].handler == handler then
|
||||
|
||||
--print("-- timed reset", handler, player_name)
|
||||
|
||||
-- reset player variables
|
||||
playing[player_name].set = nil
|
||||
playing[player_name].gain = nil
|
||||
playing[player_name].handler = nil
|
||||
end
|
||||
end)
|
||||
end, handler, player_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -304,19 +302,23 @@ minetest.register_chatcommand("svol", {
|
|||
-- 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
|
||||
|
|
|
@ -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,7 +25,15 @@ 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", {
|
||||
|
||||
|
@ -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,6 +112,32 @@ 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.")
|
||||
end
|
||||
|
@ -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", {
|
||||
|
|
|
@ -95,6 +95,8 @@ end)
|
|||
|
||||
-- default biomes deco
|
||||
local deco = {
|
||||
{"default:dry_dirt", dry_grass, {}},
|
||||
{"default:dry_dirt_with_dry_grass", dry_grass, {}},
|
||||
{"default:dirt_with_dry_grass", dry_grass, flowers},
|
||||
{"default:sand", {}, {"default:dry_shrub", "", "", ""} },
|
||||
{"default:desert_sand", {}, {"default:dry_shrub", "", "", ""} },
|
||||
|
|
|
@ -106,6 +106,8 @@ cblocks_stairs("cblocks:stonebrick_" .. colours[i][1], {
|
|||
is_ground_content = false,
|
||||
groups = {cracky = 2, stone = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
on_place = minetest.rotate_node,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -170,7 +172,9 @@ cblocks_stairs("cblocks:wood_" .. col, {
|
|||
use_texture_alpha = "opaque",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
|
||||
sounds = default.node_sound_wood_defaults()
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
on_place = minetest.rotate_node,
|
||||
})
|
||||
|
||||
set_alias(colours[i][1], "wood")
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
|
||||
local S = cottages.S
|
||||
|
||||
-- disable repair with anvil by setting a message for the item in question
|
||||
cottages.forbid_repair = {}
|
||||
-- example for hammer no longer beeing able to repair the hammer
|
||||
--cottages.forbid_repair["cottages:hammer"] = 'The hammer is too complex for repairing.'
|
||||
|
||||
|
||||
-- the hammer for the anvil
|
||||
minetest.register_tool("cottages:hammer", {
|
||||
description = S("Steel hammer for repairing tools on the anvil"),
|
||||
|
@ -138,6 +144,12 @@ minetest.register_node("cottages:anvil", {
|
|||
S('The workpiece slot is for damaged tools only.'));
|
||||
return 0;
|
||||
end
|
||||
if( listname=='input'
|
||||
and cottages.forbid_repair[ stack:get_name() ]) then
|
||||
minetest.chat_send_player( player:get_player_name(),
|
||||
S(cottages.forbid_repair[ stack:get_name() ]));
|
||||
return 0;
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
|
||||
|
@ -181,6 +193,14 @@ minetest.register_node("cottages:anvil", {
|
|||
-- 65535 is max damage
|
||||
local damage_state = 40-math.floor(input:get_wear()/1638);
|
||||
|
||||
-- just to make sure that it really can't get repaired if it should not
|
||||
-- (if the check of placing the item in the input slot failed somehow)
|
||||
if( puncher and name and cottages.forbid_repair[ input:get_name() ]) then
|
||||
minetest.chat_send_player( name,
|
||||
S(cottages.forbid_repair[ input:get_name() ]));
|
||||
return;
|
||||
end
|
||||
|
||||
local tool_name = input:get_name();
|
||||
local hud_image = "";
|
||||
if( tool_name
|
||||
|
|
|
@ -117,7 +117,7 @@ minetest.register_node("cottages:water_gen", {
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
|
||||
groups = {tree = 1, choppy = 2, cracky = 1, flammable = 2},
|
||||
sounds = cottages.sounds.wood,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
|
@ -178,8 +178,14 @@ minetest.register_node("cottages:water_gen", {
|
|||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main") and
|
||||
default.can_interact_with_node(player, pos)
|
||||
local bucket = meta:get_string("bucket")
|
||||
local start = meta:get_string("fillstarttime")
|
||||
return inv:is_empty("main")
|
||||
and default.can_interact_with_node(player, pos)
|
||||
and (not(bucket) or bucket == "")
|
||||
and ((not(start) or start == "" or
|
||||
(minetest.get_us_time()/1000000) - tonumber(start)
|
||||
>= cottages.water_fill_time -2))
|
||||
end,
|
||||
-- no inventory move allowed
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
|
@ -213,7 +219,7 @@ minetest.register_node("cottages:water_gen", {
|
|||
cottages.switch_public(pos, formname, fields, sender, 'tree trunk well')
|
||||
end,
|
||||
-- punch to place and retrieve bucket
|
||||
on_punch = function(pos, node, puncher)
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
if( not( pos ) or not( node ) or not( puncher )) then
|
||||
return
|
||||
end
|
||||
|
@ -223,7 +229,8 @@ minetest.register_node("cottages:water_gen", {
|
|||
local owner = meta:get_string("owner")
|
||||
local public = meta:get_string("public")
|
||||
if( name ~= owner and public~="public") then
|
||||
minetest.chat_send_player( name, S("This tree trunk well is owned by %s. You can't use it."):format(name))
|
||||
minetest.chat_send_player( name,
|
||||
S("This tree trunk well is owned by %s. You can't use it."):format(owner))
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -233,13 +240,18 @@ minetest.register_node("cottages:water_gen", {
|
|||
-- is the well working on something? (either empty or full bucket)
|
||||
local bucket = meta:get_string("bucket")
|
||||
-- there is a bucket loaded - either empty or full
|
||||
if( bucket and bucket~="") then
|
||||
if( bucket and bucket~="" and bucket ~= "bucket:bucket_empty") then
|
||||
if( not(pinv:room_for_item("main", bucket))) then
|
||||
minetest.chat_send_player( puncher:get_player_name(),
|
||||
S("Sorry. You have no room for the bucket. Please free some "..
|
||||
"space in your inventory first!"))
|
||||
return
|
||||
end
|
||||
elseif( bucket and bucket == "bucket:bucket_empty") then
|
||||
minetest.chat_send_player( puncher:get_player_name(),
|
||||
S("Please wait until your bucket has been filled."))
|
||||
-- do not give the empty bucket back immediately
|
||||
return
|
||||
end
|
||||
|
||||
-- remove the old entity (either a bucket will be placed now or a bucket taken)
|
||||
|
@ -267,8 +279,6 @@ minetest.register_node("cottages:water_gen", {
|
|||
if( wielded
|
||||
and wielded:get_name()
|
||||
and wielded:get_name() == "bucket:bucket_empty") then
|
||||
-- remove the bucket from the players inventory
|
||||
pinv:remove_item( "main", "bucket:bucket_empty")
|
||||
-- remember that we got a bucket loaded
|
||||
meta:set_string("bucket", "bucket:bucket_empty")
|
||||
-- create the entity
|
||||
|
@ -280,6 +290,8 @@ minetest.register_node("cottages:water_gen", {
|
|||
minetest.after(cottages.water_fill_time, cottages.water_gen_fill_bucket, pos)
|
||||
-- the bucket will only be filled if the water ran long enough
|
||||
meta:set_string("fillstarttime", tostring(minetest.get_us_time()/1000000))
|
||||
-- remove the bucket from the players inventory
|
||||
pinv:remove_item( "main", "bucket:bucket_empty")
|
||||
return;
|
||||
end
|
||||
-- buckets can also be emptied here
|
||||
|
|
|
@ -15,13 +15,6 @@ minetest.override_item("default:apple", {
|
|||
leafdecay = 3, leafdecay_drop = 1}
|
||||
})
|
||||
|
||||
if minetest.registered_nodes["flowers:mushroom_brown"] then
|
||||
minetest.override_item("flowers:mushroom_brown", {
|
||||
light_source = 1,
|
||||
groups = {food_mushroom = 1, snappy = 3, attached_node = 1, flammable = 2}
|
||||
})
|
||||
end
|
||||
|
||||
--= Aliases
|
||||
|
||||
-- Banana
|
||||
|
|
|
@ -71,22 +71,22 @@ def.tiles = {"farming_melon_7.png"}
|
|||
minetest.register_node("farming:melon_7", table.copy(def))
|
||||
|
||||
-- stage 8 (final)
|
||||
def.drawtype = "nodebox"
|
||||
def.description = S("Melon")
|
||||
def.tiles = {
|
||||
"farming_melon_top.png", "farming_melon_bottom.png", "farming_melon_side.png"
|
||||
}
|
||||
def.selection_box = {-.5, -.5, -.5, .5, .5, .5}
|
||||
def.walkable = true
|
||||
def.buildable_to = false
|
||||
def.paramtype2 = "facedir"
|
||||
def.groups = {
|
||||
food_melon = 1, snappy = 2, oddly_breakable_by_hand = 1,
|
||||
flammable = 2, plant = 1
|
||||
}
|
||||
def.drop = "farming:melon_8"
|
||||
def.on_place = minetest.rotate_node
|
||||
minetest.register_node("farming:melon_8", table.copy(def))
|
||||
minetest.register_node("farming:melon_8", {
|
||||
description = S("Melon"),
|
||||
tiles = {
|
||||
"farming_melon_top.png",
|
||||
"farming_melon_bottom.png",
|
||||
"farming_melon_side.png"
|
||||
},
|
||||
groups = {
|
||||
food_melon = 1, snappy = 2, oddly_breakable_by_hand = 1,
|
||||
flammable = 2, plant = 1
|
||||
},
|
||||
drop = "farming:melon_8",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
-- add to registered_plants
|
||||
farming.registered_plants["farming:melon"] = {
|
||||
|
|
|
@ -183,7 +183,7 @@ minetest.register_node("farming:pumpkin_8", {
|
|||
description = S("Pumpkin"),
|
||||
tiles = {
|
||||
"farming_pumpkin_top.png",
|
||||
"farming_pumpkin_top.png",
|
||||
"farming_pumpkin_bottom.png",
|
||||
"farming_pumpkin_side.png"
|
||||
},
|
||||
groups = {
|
||||
|
@ -191,7 +191,9 @@ minetest.register_node("farming:pumpkin_8", {
|
|||
flammable = 2, plant = 1
|
||||
},
|
||||
drop = "farming:pumpkin_8",
|
||||
sounds = default.node_sound_wood_defaults()
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
minetest.register_alias("farming:pumpkin", "farming:pumpkin_8")
|
||||
|
|
|
@ -42,15 +42,26 @@ minetest.register_node("farming:soy_sauce", {
|
|||
sounds = default.node_sound_glass_defaults()
|
||||
})
|
||||
|
||||
-- river water availability check
|
||||
local bucket_water
|
||||
|
||||
if minetest.get_mapgen_setting("mgname") == "valleys"
|
||||
or minetest.get_modpath("ethereal") then
|
||||
bucket_water = "bucket:bucket_river_water"
|
||||
else
|
||||
bucket_water = "bucket:bucket_water"
|
||||
end
|
||||
|
||||
-- soy sauce recipe
|
||||
minetest.register_craft( {
|
||||
output = "farming:soy_sauce",
|
||||
recipe = {
|
||||
{"group:food_soy", "group:food_salt", "group:food_soy"},
|
||||
{"", "group:food_juicer", ""},
|
||||
{"", "bucket:bucket_river_water", "vessels:glass_bottle"}
|
||||
{"", bucket_water, "vessels:glass_bottle"}
|
||||
},
|
||||
replacements = {
|
||||
{"bucket:bucket_river_water", "bucket:bucket_empty"},
|
||||
{bucket_water, "bucket:bucket_empty"},
|
||||
{"group:food_juicer", "farming:juicer"}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -361,7 +361,7 @@ farming.add_to_scythe_not_drops = function(item)
|
|||
end
|
||||
|
||||
minetest.register_tool("farming:scythe_mithril", {
|
||||
description = S("Mithril Scythe (Right-click to harvest and replant crops)"),
|
||||
description = S("Mithril Scythe (Use to harvest and replant crops)"),
|
||||
inventory_image = "farming_scythe_mithril.png",
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 258 B |
|
@ -190,8 +190,9 @@ local function update_meta(meta, enabled)
|
|||
"listring[context;dst]" ..
|
||||
"listring[current_player;main]"
|
||||
if minetest.get_modpath("digilines") then
|
||||
fs = fs.."field[1,3.5;4,1;channel;"..S("Channel")..";${channel}]"
|
||||
fs = fs.."button_exit[5,3.2;2,1;save;"..S("Save").."]"
|
||||
fs = fs.."field[0.3,3.5;4.5,1;channel;"..S("Channel")..";${channel}]"..
|
||||
"button[4.5,3.2;1.5,1;set_channel;"..S("Set").."]"..
|
||||
"button_exit[6,3.2;2,1;close;"..S("Close").."]"
|
||||
end
|
||||
meta:set_string("formspec",fs)
|
||||
|
||||
|
@ -276,7 +277,7 @@ minetest.register_node("pipeworks:autocrafter", {
|
|||
update_meta(meta, false)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if (fields.quit and not fields.key_enter_field)
|
||||
if not fields.channel or (fields.quit and not fields.key_enter_field)
|
||||
or not pipeworks.may_configure(pos, sender) then
|
||||
return
|
||||
end
|
||||
|
@ -288,8 +289,9 @@ minetest.register_node("pipeworks:autocrafter", {
|
|||
if update_meta(meta, true) then
|
||||
start_crafter(pos)
|
||||
end
|
||||
elseif fields.save then
|
||||
meta:set_string("channel",fields.channel)
|
||||
end
|
||||
if fields.channel then
|
||||
meta:set_string("channel", fields.channel)
|
||||
end
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
|
|
|
@ -4,6 +4,9 @@ local filename=minetest.get_worldpath() .. "/teleport_tubes"
|
|||
local tp_tube_db = nil -- nil forces a read
|
||||
local tp_tube_db_version = 2.0
|
||||
|
||||
-- cached rceiver list: hash(pos) => {receivers}
|
||||
local cache = {}
|
||||
|
||||
local function hash(pos)
|
||||
return string.format("%.30g", minetest.hash_node_position(pos))
|
||||
end
|
||||
|
@ -18,6 +21,8 @@ local function save_tube_db()
|
|||
else
|
||||
error(err)
|
||||
end
|
||||
-- reset tp-tube cache
|
||||
cache = {}
|
||||
end
|
||||
|
||||
local function migrate_tube_db()
|
||||
|
@ -101,6 +106,12 @@ local function read_node_with_vm(pos)
|
|||
end
|
||||
|
||||
local function get_receivers(pos, channel)
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
if cache[hash] then
|
||||
-- re-use cached result
|
||||
return cache[hash]
|
||||
end
|
||||
|
||||
local tubes = tp_tube_db or read_tube_db()
|
||||
local receivers = {}
|
||||
local dirty = false
|
||||
|
@ -121,6 +132,8 @@ local function get_receivers(pos, channel)
|
|||
if dirty then
|
||||
save_tube_db()
|
||||
end
|
||||
-- cache the result for next time
|
||||
cache[hash] = receivers
|
||||
return receivers
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ That said, there are some basic text formatting options:
|
|||
|
||||
Writing "^" followed by a letter "a" through "h" will produce double-wide versions of these arrows, in the same order. These wide arrows occupy 0x89 to 0x91 in the character set.
|
||||
|
||||
* A color may be specified in the sign text by using "#" followed by a single hexadcimal digit (0-9 or a-f). These colors come from the standard Linux/IRC/CGA color set, and are shown in the sign's formspec. Any color change will remain in effect until changed again, or until the next line break. Any number of color changes in any arbitrary arrangement is allowed.
|
||||
* A color may be specified in the sign text by using "#" followed by a single hexadcimal digit (0-9 or a-f). These colors come from the standard Linux/IRC/CGA color set, and are shown in the sign's formspec. Any color change will remain in effect until changed again, or until the next line break. Any number of color changes in any arbitrary arrangement is allowed. To write "#" on a sign, write "##".
|
||||
|
||||
* Most writable signs can display double-wide text by flipping a switch in the sign's formspec.
|
||||
|
||||
|
|
|
@ -555,8 +555,9 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||
end
|
||||
end
|
||||
local c = word:sub(i, i)
|
||||
if c == "#" then
|
||||
local cc = tonumber(word:sub(i+1, i+1), 16)
|
||||
local c2 = word:sub(i+1, i+1)
|
||||
if c == "#" and c2 ~= "#" then
|
||||
local cc = tonumber(c2, 16)
|
||||
if cc then
|
||||
i = i + 1
|
||||
cur_color = cc
|
||||
|
|
|
@ -54,7 +54,7 @@ function ui.get_formspec(player, page)
|
|||
if not pagedef then
|
||||
return "" -- Invalid page name
|
||||
end
|
||||
|
||||
|
||||
local formspec = {
|
||||
"formspec_version[4]",
|
||||
"size["..ui_peruser.formw..","..ui_peruser.formh.."]",
|
||||
|
|
Loading…
Reference in New Issue