Code cleanup and add settings file

This commit is contained in:
KaadmY 2017-05-11 20:24:40 -07:00
parent b667b4561e
commit 41edd82122
10 changed files with 227 additions and 151 deletions

View File

@ -1,7 +1,10 @@
#day-night cycle is 12 min(about)
# Day-night cycle is 12 min(about)
time_speed = 120
# movement
# Movement
movement_acceleration_default = 3.3
movement_acceleration_fast = 5.0
movement_acceleration_air = 2.0
@ -18,102 +21,125 @@ movement_liquid_sink = 30.0
movement_gravity = 9.8
# privs
default_privs = interact, shout, spawn, fast, player_skin
# Privileges
default_privs = fast, interact, player_skin, shout, spawn, zoom
# If the welcome formspec is shown on join
# if the welcome formspec is shown on join
welcome_enable = true
# if you're given the inital stuff; a stone pick and 10 torches
# If you're given the inital stuff; a stone pick and 10 torches
give_initial_stuff = false
# if players with interact can use the /fixlight chat command
# If players with interact can use the /fixlight chat command
fixlight_command_enable = true
# if you can name chests when the sign is below the chest; may cause problems
# If you can name chests when the sign is below the chest; may cause problems
signs_allow_name_above = false
# possible player skins; make sure they exist in the form "player_skins_[skin].png"!
# Player skins list
# Make sure they exist in the form "player_skins_[skin].png"
# and "player_skins_[skin]_icon.png"!
player_skins_names = male,female
# if you drop items in your inventory when you die
# If you drop items in your inventory when you die
drop_items_on_die = true
# mob stuff
# Mob stuff
mobs_enable_blood = false
# if mobs don't attack within 256 nodes of the static_spawn_point; disabled in singleplayer
mobs_peaceful = false
# If mobs don't attack within 256 nodes of the static_spawn_point;
# disabled in singleplayer
mobs_safe_spawn = true
# if beds can be slept in
# If beds can be slept in
bed_enabled = true
# if music players are usable
# If music players are usable
music_enable = true
music_track = music_catsong
music_track_length = 30.0
music_volume = 0.8
# if dynamically changing weather is enabled
# If dynamically changing weather is enabled
weather_enable = true
weather_snow_enable = false
# if pvp is enabled
# If pvp is enabled
enable_pvp = true
# tnt is enabled
# TNT is enabled
tnt_enable = true
# if testing stuff is enabled
# If testing stuff is enabled
testing_enable = false
# if hunger is enabled
# If hunger is enabled
hunger_enable = true
hunger_step = 3
# headbars(health bars above players/entities)
# Headbars (health bars above players/entities)
headbars_enable = true
headbars_scale = 1
# private messages
# Private messages
pm_enable_saving = true
# ambience noises (uncomment the lines below to disable specific ambient sounds)
ambiance_volume = 1.0
#ambiance_disable_birds = true
#ambiance_disable_crickets = true
#ambiance_disable_flowing_water = true
# Ambiance sounds
ambience_enable = true
ambiance_volume = 1.0
ambiance_disable_birds = false
ambiance_disable_crickets = false
ambiance_disable_flowing_water = false
# Server (user stuff)
# server(user stuff)
max_users = 16
player_transfer_distance = 5 # 80 nodes
# server(performance stuff)
max_block_generate_distance = 5
max_block_send_distance = 3
# Server(performance stuff)
max_block_generate_distance = 6
max_block_send_distance = 5
max_simultaneous_block_sends_per_client = 20
max_simultaneous_block_sends_server_total = 100
time_send_interval = 5
active_block_range = 4
active_block_range = 5
server_map_save_interval = 20
# mapgen
# Mapgen
# NP: offset, scale, (spread factors), seed offset, number of octaves, persistence, lacunarity
# generic
# Generic
water_level = 1
mg_flags = trees, caves
mg_biome_np_humidity = 50, 20, (600, 850, 600), 31478, 2, 0.5, 2.0
# mapgen v6
mgv6_spflags = nojungles
mgv6_freq_desert = 0.65
mgv6_freq_beach = -0.04
# Mapgen v7
#mapgen v7
mgv7_np_terrain_base = 10, 25, (750, 1500, 750), 88533, 5, 0.65, 2, 2
# valleys mapgen
# Valleys mapgen
mg_valleys_river_size = 5
mg_valleys_river_depth = 2

View File

@ -71,8 +71,8 @@ function achievements.trigger_achievement(player, aname, times)
achievements.achievements[name][aname] = -1
minetest.after(2.0, function()
minetest.chat_send_all(
core.colorize("#0f0", "*** " .. name .." has earned the achievement [" ..
achievements.registered_achievements[aname].title .. "]"))
minetest.colorize("#0f0", "*** " .. name .." has earned the achievement [" ..
achievements.registered_achievements[aname].title .. "]"))
end)
end

View File

@ -14,14 +14,14 @@ ambiance.sounds["birds"] = {
dist = 8,
nodename = "group:leaves",
can_play = function(pos)
local tod = (minetest.get_timeofday() or 1) * 2
local tod = (minetest.get_timeofday() or 1) * 2
if tod > 0.47 and tod < 1.53 then -- bit of overlap into crickets
return true
end
if tod > 0.47 and tod < 1.53 then -- bit of overlap into crickets
return true
end
return false
end,
return false
end,
}
ambiance.sounds["crickets"] = {
@ -31,112 +31,114 @@ ambiance.sounds["crickets"] = {
dist = 8,
nodename = "group:grass",
can_play = function(pos)
local tod = (minetest.get_timeofday() or 1) * 2
local tod = (minetest.get_timeofday() or 1) * 2
if tod < 0.5 or tod > 1.5 then
return true
end
if tod < 0.5 or tod > 1.5 then
return true
end
return false
end,
return false
end,
}
ambiance.sounds["flowing_water"] = {
length = 3.3,
chance = 1,
file = "default_water",
file = "ambiance_water",
dist = 16,
nodename = "group:flowing_water",
}
local ambiance_volume = tonumber(minetest.setting_get("ambiance_volume")) or 1.0
local soundspec = {}
local lastsound = {}
if minetest.setting_getbool("ambiance_enable") == true then
local soundspec = {}
local lastsound = {}
local function ambient_node_near(sound, pos)
local nodepos = minetest.find_node_near(pos, sound.dist, sound.nodename)
local function ambient_node_near(sound, pos)
local nodepos = minetest.find_node_near(pos, sound.dist, sound.nodename)
if nodepos ~= nil and math.random(1, sound.chance) == 1 then
return nodepos
end
return nil
end
local function step(dtime)
local player_positions = {}
for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos()
local name = player:get_player_name()
for soundname, sound in pairs(ambiance.sounds) do
if not minetest.setting_getbool("ambiance_disable_" .. soundname) then
if lastsound[name][soundname] then
lastsound[name][soundname] = lastsound[name][soundname] + dtime
else
lastsound[name][soundname] = 0
end
if lastsound[name][soundname] > sound.length then
local sourcepos = ambient_node_near(sound, pos)
if sound.can_play and sourcepos ~= nil and (not sound.can_play(sourcepos)) then
sourcepos = nil
end
if sourcepos == nil then
if soundspec[name][soundname] then
minetest.sound_stop(soundspec[name][soundname])
soundspec[name][soundname] = nil
lastsound[name][soundname] = 0
end
else
local ok = true
for _, p in pairs(player_positions) do
if (p.x * pos.x) + (p.y * pos.y) + (p.z * pos.z) < sound.dist * sound.dist then
ok = false
end
end
if ok then
soundspec[name][soundname] = minetest.sound_play(
sound.file,
{
pos = sourcepos,
max_hear_distance = sound.dist,
gain = ambiance_volume,
})
lastsound[name][soundname] = 0
end
end
end
end
if nodepos ~= nil and math.random(1, sound.chance) == 1 then
return nodepos
end
table.insert(player_positions, pos)
return nil
end
local function step(dtime)
local player_positions = {}
for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos()
local name = player:get_player_name()
for soundname, sound in pairs(ambiance.sounds) do
if not minetest.setting_getbool("ambiance_disable_" .. soundname) then
if lastsound[name][soundname] then
lastsound[name][soundname] = lastsound[name][soundname] + dtime
else
lastsound[name][soundname] = 0
end
if lastsound[name][soundname] > sound.length then
local sourcepos = ambient_node_near(sound, pos)
if sound.can_play and sourcepos ~= nil and (not sound.can_play(sourcepos)) then
sourcepos = nil
end
if sourcepos == nil then
if soundspec[name][soundname] then
minetest.sound_stop(soundspec[name][soundname])
soundspec[name][soundname] = nil
lastsound[name][soundname] = 0
end
else
local ok = true
for _, p in pairs(player_positions) do
if (p.x * pos.x) + (p.y * pos.y) + (p.z * pos.z) < sound.dist * sound.dist then
ok = false
end
end
if ok then
soundspec[name][soundname] = minetest.sound_play(
sound.file,
{
pos = sourcepos,
max_hear_distance = sound.dist,
gain = ambiance_volume,
})
lastsound[name][soundname] = 0
end
end
end
end
end
table.insert(player_positions, pos)
end
end
local function on_joinplayer(player)
local name = player:get_player_name()
soundspec[name] = {}
lastsound[name] = {}
end
local function on_leaveplayer(player)
local name = player:get_player_name()
soundspec[name] = nil
lastsound[name] = nil
end
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_globalstep(step)
end
local function on_joinplayer(player)
local name = player:get_player_name()
soundspec[name] = {}
lastsound[name] = {}
end
local function on_leaveplayer(player)
local name = player:get_player_name()
soundspec[name] = nil
lastsound[name] = nil
end
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_globalstep(step)
default.log("mod:ambiance", "loaded")
default.log("mod:ambiance", "loaded")

View File

@ -256,10 +256,5 @@ end)
minetest.register_on_joinplayer(
function(player)
local function welcome()
minetest.chat_send_player(player:get_player_name(), core.colorize("#0f0", "Welcome to Pixture! Type /help for a list of commands."))
end
minetest.after(1.0, welcome)
player:set_inventory_formspec(default.ui.get_page("core_crafting"))
end)

View File

@ -16,7 +16,7 @@ local function step(dtime)
if player_pos.x < -30000 or player_pos.x > 30000
or player_pos.y < -30000 or player_pos.y > 30000
or player_pos.z < -30000 or player_pos.z > 30000 then
minetest.chat_send_player(name, core.colorize("#f00", "Don't go past 30000m in any direction!"))
minetest.chat_send_player(name, minetest.colorize("#f00", "Don't go past 30000m in any direction!"))
player:setpos(player_lastpos[name])
end
@ -100,25 +100,34 @@ local function on_joinplayer(player)
player_health[name] = player:get_hp()
-- uncomment to enable player-on-player collisions
player_lastpos[name] = player:getpos()
-- Uncomment to enable player-on-player collisions
-- player:set_properties({physical = true})
-- uncomment to disable the sneak glitch
-- Uncomment to disable the sneak glitch
player:set_physics_override({sneak_glitch = false})
-- uncomment to disable the minimap
-- Uncomment to disable the minimap
player:hud_set_flags({minimap = false})
player_lastpos[name] = player:getpos()
-- Welcome
local function welcome()
minetest.chat_send_player(player:get_player_name(), minetest.colorize("#ff0", "Welcome to Pixture! Type /help for a list of commands."))
end
minetest.after(1.0, welcome)
end
local function on_leaveplayer(player)
local name=player:get_player_name()
player_health[name] = nil
player_lastpos[name] = nil
player_soundspec[name] = nil
player_lastsound[name] = nil
player_health[name] = nil
player_lastpos[name] = nil
end
minetest.register_on_joinplayer(on_joinplayer)

View File

@ -62,7 +62,7 @@ minetest.register_tool(
if own then
minetest.chat_send_player(
own,
core.colorize("#f00", player:get_player_name() .. " has broken into your locked chest!"))
minetest.colorize("#f00", player:get_player_name() .. " has broken into your locked chest!"))
end
end

View File

@ -6,6 +6,7 @@ mobs.mod = "redo"
local damage_enabled = minetest.setting_getbool("enable_damage") or false
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs") or false
local enable_blood = minetest.setting_getbool("mobs_enable_blood") or false
mobs.protected = tonumber(minetest.setting_get("mobs_spawn_protected")) or 0
mobs.remove = minetest.setting_getbool("remove_far_mobs") or false

View File

@ -71,10 +71,10 @@ if enable_saving then
local name = player:get_player_name()
if messages[name] ~= nil and #messages[name] >= 1 then
minetest.chat_send_player(name, core.colorize("#0ff", "You have " .. #messages[name] .. " saved PMs. Type /pms to view."))
minetest.chat_send_player(name, minetest.colorize("#0ff", "You have " .. #messages[name] .. " saved PMs. Type /pms to view."))
return false
else
minetest.chat_send_player(name, core.colorize("#0ff", "You have no saved PMs. Send PMs with the /pm command."))
minetest.chat_send_player(name, minetest.colorize("#0ff", "You have no saved PMs. Send PMs with the /pm command."))
return true
end
end)

43
settingtypes.txt Normal file
View File

@ -0,0 +1,43 @@
##
## Pixture's menu settings
##
## Multiplayer settings
welcome_enable (Welcome) bool true
## Player stuff
give_initial_stuff (Give initial items) bool false
drop_items_on_die (Drop items on death) bool true
enable_pvp (PvP) bool true
## Mobs
mobs_peaceful (Peaceful mobs) bool false
mobs_safe_spawn (Safe spawn from mobs) bool true
static_spawn_radius (Safe spawn radius) int 256
## Beds
bed_enable (Enable beds) bool true
## Music
music_enable (Enable music players) bool true
## Weather
weather_enable (Enable dynamic weather) bool true
## Ambiance
ambiance_enable (Enable ambient sounds) bool true
## Player skins
player_skins_names (Player skin list) string male,female