forked from VoxeLibre/VoxeLibre
Compare commits
5 Commits
master
...
player-glo
Author | SHA1 | Date |
---|---|---|
AFCMS | 753cdb09d7 | |
AFCMS | a1f56c4190 | |
AFCMS | fbc613d726 | |
AFCMS | bace4f5f20 | |
AFCMS | c7a144aa10 |
|
@ -44,8 +44,8 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
controls.players[name] = nil
|
controls.players[name] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
for _, player in pairs(get_connected_players()) do
|
execute = function(player, dtime)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local player_controls = player:get_player_control()
|
local player_controls = player:get_player_control()
|
||||||
if controls.players[player_name] then
|
if controls.players[player_name] then
|
||||||
|
@ -71,5 +71,5 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end)
|
})
|
|
@ -1,4 +1,5 @@
|
||||||
name = controls
|
name = controls
|
||||||
author = Arcelmi
|
author = Arcelmi
|
||||||
|
depends = mcl_util
|
||||||
description = Controls framework by Arcelmi
|
description = Controls framework by Arcelmi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
# mcl_util
|
||||||
|
|
||||||
|
Provide utility functions for mcl2
|
||||||
|
|
||||||
|
## mcl_util.register_player_globalstep(def)
|
||||||
|
Used to register a player globalstep.
|
||||||
|
Use this insteed of global step if you need to execute action on all players to avoid calling the same functions multiple time.
|
||||||
|
|
||||||
|
```
|
||||||
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
return true --return false if you want to skip "execute" function
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
--do some cool stuff
|
||||||
|
--will be executed for every player at each server step
|
||||||
|
end,
|
||||||
|
after_execute = function(dtime)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## mcl_util.registered_player_globalstep
|
||||||
|
Table containing all registered player globalstep.
|
|
@ -1,3 +1,5 @@
|
||||||
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
mcl_util = {}
|
mcl_util = {}
|
||||||
|
|
||||||
-- Based on minetest.rotate_and_place
|
-- Based on minetest.rotate_and_place
|
||||||
|
@ -418,3 +420,5 @@ function mcl_util.get_color(colorstr)
|
||||||
return colorstr, hex
|
return colorstr, hex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
dofile(modpath.."/playerstep.lua")
|
|
@ -0,0 +1,25 @@
|
||||||
|
local get_connected_players = minetest.get_connected_players
|
||||||
|
|
||||||
|
mcl_util.registered_player_globalstep = {}
|
||||||
|
local registered_player_globalstep = mcl_util.registered_player_globalstep
|
||||||
|
|
||||||
|
function mcl_util.register_player_globalstep(def)
|
||||||
|
if not def.can_execute then def.can_execute = function() return true end end
|
||||||
|
table.insert(mcl_util.registered_player_globalstep, {can_execute=def.can_execute, func=def.execute})
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
local players = get_connected_players()
|
||||||
|
for i = 1, #registered_player_globalstep do
|
||||||
|
if registered_player_globalstep[i].can_execute and registered_player_globalstep[i].can_execute(dtime) then
|
||||||
|
for p = 1, #players do
|
||||||
|
registered_player_globalstep[i].func(players[p], dtime)
|
||||||
|
end
|
||||||
|
if registered_player_globalstep[i].after_execute then
|
||||||
|
registered_player_globalstep[i].after_execute(dtime)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
|
@ -52,3 +52,33 @@ minetest.register_globalstep(function(dtime)
|
||||||
timer = 0
|
timer = 0
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--[[mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
timer = timer + dtime;
|
||||||
|
if timer >= 0.3 then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
local pp = player:get_pos()
|
||||||
|
pp.y = ceil(pp.y)
|
||||||
|
local loc = vector_add(pp, {x=0,y=-1,z=0})
|
||||||
|
if loc ~= nil then
|
||||||
|
local nodeiamon = get_node(loc)
|
||||||
|
if nodeiamon ~= nil then
|
||||||
|
if on_walk[nodeiamon.name] then
|
||||||
|
on_walk[nodeiamon.name](loc, nodeiamon, player)
|
||||||
|
end
|
||||||
|
for i = 1, #registered_globals do
|
||||||
|
registered_globals[i](loc, nodeiamon, player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
after_execute = function(dtime)
|
||||||
|
timer = 0
|
||||||
|
end,
|
||||||
|
})]]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
name = walkover
|
name = walkover
|
||||||
author = lordfingle
|
author = lordfingle
|
||||||
|
depends = mcl_util
|
||||||
description = Some mode developers have shown an interest in having an `on_walk_over` event. This is useful for pressure-plates and the like.
|
description = Some mode developers have shown an interest in having an `on_walk_over` event. This is useful for pressure-plates and the like.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ local is_in_void = mcl_worlds.is_in_void
|
||||||
local get_spawn_pos = mcl_spawn.get_player_spawn_pos
|
local get_spawn_pos = mcl_spawn.get_player_spawn_pos
|
||||||
local death_msg = mcl_death_messages.player_damage
|
local death_msg = mcl_death_messages.player_damage
|
||||||
local send_chat = minetest.chat_send_player
|
local send_chat = minetest.chat_send_player
|
||||||
local get_connected = minetest.get_connected_players
|
|
||||||
|
|
||||||
local voidtimer = 0
|
local voidtimer = 0
|
||||||
local VOID_DAMAGE_FREQ = 0.5
|
local VOID_DAMAGE_FREQ = 0.5
|
||||||
|
@ -54,14 +53,15 @@ minetest.register_on_mods_loaded(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Hurt players or teleport them back to spawn if they are too deep in the void
|
-- Hurt players or teleport them back to spawn if they are too deep in the void
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
voidtimer = voidtimer + dtime
|
voidtimer = voidtimer + dtime
|
||||||
if voidtimer > VOID_DAMAGE_FREQ then
|
if voidtimer > VOID_DAMAGE_FREQ then
|
||||||
voidtimer = 0
|
voidtimer = 0
|
||||||
local enable_damage = minetest.settings:get_bool("enable_damage")
|
return true
|
||||||
local players = get_connected()
|
end
|
||||||
for p=1, #players do
|
end,
|
||||||
local player = players[p]
|
execute = function(player, dtime)
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
local void, void_deadly = is_in_void(pos)
|
local void, void_deadly = is_in_void(pos)
|
||||||
if void_deadly then
|
if void_deadly then
|
||||||
|
@ -85,6 +85,5 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end
|
})
|
||||||
end)
|
|
|
@ -1,6 +1,8 @@
|
||||||
local S = minetest.get_translator("doc_items")
|
local S = minetest.get_translator("doc_items")
|
||||||
local N = function(s) return s end
|
local N = function(s) return s end
|
||||||
|
|
||||||
|
local math = math
|
||||||
|
|
||||||
doc.sub.items = {}
|
doc.sub.items = {}
|
||||||
|
|
||||||
-- Template texts
|
-- Template texts
|
||||||
|
@ -1397,16 +1399,18 @@ TODO: If possible, try to replace this functionality by updating the revealed it
|
||||||
soon the player obtained a new item (probably needs new Minetest callbacks). ]]
|
soon the player obtained a new item (probably needs new Minetest callbacks). ]]
|
||||||
local checktime = 8
|
local checktime = 8
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
timer = timer + dtime
|
|
||||||
if timer > checktime then
|
|
||||||
local players = minetest.get_connected_players()
|
|
||||||
for p=1, #players do
|
|
||||||
reveal_items_in_inventory(players[p])
|
|
||||||
end
|
|
||||||
|
|
||||||
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
timer = timer + dtime
|
||||||
|
if timer > checktime then return true end
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
reveal_items_in_inventory(player)
|
||||||
|
end,
|
||||||
|
after_execute = function(dtime)
|
||||||
timer = math.fmod(timer, checktime)
|
timer = math.fmod(timer, checktime)
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
|
|
||||||
minetest.register_on_mods_loaded(gather_descs)
|
minetest.register_on_mods_loaded(gather_descs)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name = doc_items
|
name = doc_items
|
||||||
author = Wuzzy
|
author = Wuzzy
|
||||||
description = Adds automatically generated help texts for items.
|
description = Adds automatically generated help texts for items.
|
||||||
depends = doc
|
depends = doc, mcl_util
|
||||||
|
|
|
@ -112,7 +112,7 @@ end)
|
||||||
|
|
||||||
local main_timer = 0
|
local main_timer = 0
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
--[[minetest.register_globalstep(function(dtime)
|
||||||
main_timer = main_timer + dtime
|
main_timer = main_timer + dtime
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if main_timer > mcl_hbarmor.tick or timer > 4 then
|
if main_timer > mcl_hbarmor.tick or timer > 4 then
|
||||||
|
@ -132,4 +132,29 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if timer > 4 then timer = 0 end
|
if timer > 4 then timer = 0 end
|
||||||
end)
|
end)]]
|
||||||
|
|
||||||
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
main_timer = main_timer + dtime
|
||||||
|
timer = timer + dtime
|
||||||
|
if main_timer > mcl_hbarmor.tick or timer > 4 then
|
||||||
|
if minetest.settings:get_bool("enable_damage") then
|
||||||
|
if main_timer > mcl_hbarmor.tick then main_timer = 0 end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if timer > 4 then timer = 0 end
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if mcl_hbarmor.player_active[name] == true then
|
||||||
|
local ret = mcl_hbarmor.get_armor(player)
|
||||||
|
if ret == false then
|
||||||
|
minetest.log("error", "[mcl_hbarmor] Call to mcl_hbarmor.get_armor in globalstep returned with false!")
|
||||||
|
end
|
||||||
|
-- update all hud elements
|
||||||
|
update_hud(player)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name = mcl_hbarmor
|
name = mcl_hbarmor
|
||||||
author = BlockMen
|
author = BlockMen
|
||||||
description = Adds a HUD bar displaying the current damage of the player's armor.
|
description = Adds a HUD bar displaying the current damage of the player's armor.
|
||||||
depends = hudbars, mcl_armor
|
depends = hudbars, mcl_armor, mcl_util
|
||||||
|
|
|
@ -64,13 +64,12 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
wieldindex[name] = nil
|
wieldindex[name] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
execute = function(player, dtime)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local wstack = player:get_wielded_item()
|
local wstack = player:get_wielded_item()
|
||||||
local wname = wstack:get_name()
|
local wname = wstack:get_name()
|
||||||
local windex = player:get_wield_index()
|
local windex = player:get_wield_index()
|
||||||
|
|
||||||
if dtimes[player_name] and dtimes[player_name] < dlimit then
|
if dtimes[player_name] and dtimes[player_name] < dlimit then
|
||||||
dtimes[player_name] = dtimes[player_name] + dtime
|
dtimes[player_name] = dtimes[player_name] + dtime
|
||||||
if dtimes[player_name] > dlimit and huds[player_name] then
|
if dtimes[player_name] > dlimit and huds[player_name] then
|
||||||
|
@ -83,12 +82,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
wieldindex[player_name] = windex
|
wieldindex[player_name] = windex
|
||||||
wield[player_name] = wname
|
wield[player_name] = wname
|
||||||
dtimes[player_name] = 0
|
dtimes[player_name] = 0
|
||||||
|
|
||||||
if huds[player_name] then
|
if huds[player_name] then
|
||||||
|
|
||||||
local def = minetest.registered_items[wname]
|
local def = minetest.registered_items[wname]
|
||||||
local meta = wstack:get_meta()
|
local meta = wstack:get_meta()
|
||||||
|
|
||||||
--[[ Get description. Order of preference:
|
--[[ Get description. Order of preference:
|
||||||
* description from metadata
|
* description from metadata
|
||||||
* description from item definition
|
* description from item definition
|
||||||
|
@ -108,6 +104,5 @@ minetest.register_globalstep(function(dtime)
|
||||||
player:hud_change(huds[player_name], 'text', desc)
|
player:hud_change(huds[player_name], 'text', desc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
name = show_wielded_item
|
name = show_wielded_item
|
||||||
author = 4aiman
|
author = 4aiman
|
||||||
description = Displays the name of the wielded item.
|
description = Displays the name of the wielded item.
|
||||||
|
depends = mcl_util
|
||||||
optional_depends = hudbars
|
optional_depends = hudbars
|
||||||
|
|
|
@ -340,17 +340,15 @@ controls.register_on_hold(function(player, key, time)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
execute = function(player, dtime)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local wielditem = player:get_wielded_item()
|
local wielditem = player:get_wielded_item()
|
||||||
local wieldindex = player:get_wield_index()
|
if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:bow_0" and wielditem:get_name()~="mcl_bows:bow_1" and wielditem:get_name()~="mcl_bows:bow_2" and wielditem:get_name()~="mcl_bows:bow_0_enchanted" and wielditem:get_name()~="mcl_bows:bow_1_enchanted" and wielditem:get_name()~="mcl_bows:bow_2_enchanted") or player:get_wield_index() ~= bow_index[name]) then
|
||||||
local controls = player:get_player_control()
|
|
||||||
if type(bow_load[name]) == "number" and ((wielditem:get_name()~="mcl_bows:bow_0" and wielditem:get_name()~="mcl_bows:bow_1" and wielditem:get_name()~="mcl_bows:bow_2" and wielditem:get_name()~="mcl_bows:bow_0_enchanted" and wielditem:get_name()~="mcl_bows:bow_1_enchanted" and wielditem:get_name()~="mcl_bows:bow_2_enchanted") or wieldindex ~= bow_index[name]) then
|
|
||||||
reset_bow_state(player, true)
|
reset_bow_state(player, true)
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
reset_bows(player)
|
reset_bows(player)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name = mcl_bows
|
name = mcl_bows
|
||||||
author = Arcelmi
|
author = Arcelmi
|
||||||
description = This mod adds bows and arrows for MineClone 2.
|
description = This mod adds bows and arrows for MineClone 2.
|
||||||
depends = controls, mcl_particles, mcl_enchanting, mcl_init
|
depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util
|
||||||
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button
|
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,11 @@ end
|
||||||
-- This timer makes sure the clocks get updated from time to time regardless of time_speed,
|
-- This timer makes sure the clocks get updated from time to time regardless of time_speed,
|
||||||
-- just in case some clocks in the world go wrong
|
-- just in case some clocks in the world go wrong
|
||||||
local force_clock_update_timer = 0
|
local force_clock_update_timer = 0
|
||||||
|
local now
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
local now = watch.get_clock_frame()
|
can_execute = function(dtime)
|
||||||
|
now = watch.get_clock_frame()
|
||||||
force_clock_update_timer = force_clock_update_timer + dtime
|
force_clock_update_timer = force_clock_update_timer + dtime
|
||||||
random_timer = random_timer + dtime
|
random_timer = random_timer + dtime
|
||||||
-- This causes the random spinning of the clock
|
-- This causes the random spinning of the clock
|
||||||
|
@ -86,15 +88,14 @@ minetest.register_globalstep(function(dtime)
|
||||||
random_frame = (random_frame + math.random(-4, 4)) % clock_frames
|
random_frame = (random_frame + math.random(-4, 4)) % clock_frames
|
||||||
random_timer = 0
|
random_timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if watch.old_time == now and force_clock_update_timer < 60 then
|
if watch.old_time == now and force_clock_update_timer < 60 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
force_clock_update_timer = 0
|
force_clock_update_timer = 0
|
||||||
|
|
||||||
watch.old_time = now
|
watch.old_time = now
|
||||||
|
return true
|
||||||
for p, player in pairs(minetest.get_connected_players()) do
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
for s, stack in pairs(player:get_inventory():get_list("main")) do
|
for s, stack in pairs(player:get_inventory():get_list("main")) do
|
||||||
local dim = mcl_worlds.pos_to_dimension(player:get_pos())
|
local dim = mcl_worlds.pos_to_dimension(player:get_pos())
|
||||||
local frame
|
local frame
|
||||||
|
@ -111,8 +112,8 @@ minetest.register_globalstep(function(dtime)
|
||||||
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..frame.." "..count)
|
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..frame.." "..count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
|
|
||||||
-- Immediately set correct clock time after crafting
|
-- Immediately set correct clock time after crafting
|
||||||
minetest.register_on_craft(function(itemstack)
|
minetest.register_on_craft(function(itemstack)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name = mcl_clock
|
name = mcl_clock
|
||||||
description = A fantasy clock item roughly shows the time of day.
|
description = A fantasy clock item roughly shows the time of day.
|
||||||
depends = mcl_init, mcl_worlds, mesecons
|
depends = mcl_init, mcl_worlds, mesecons, mcl_util
|
||||||
optional_depends = doc
|
optional_depends = doc
|
||||||
|
|
|
@ -12,14 +12,8 @@ local random_timer_trigger = 0.5 -- random compass spinning tick in seconds. Inc
|
||||||
|
|
||||||
local random_frame = math.random(0, compass_frames-1)
|
local random_frame = math.random(0, compass_frames-1)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
local math = math
|
||||||
random_timer = random_timer + dtime
|
|
||||||
|
|
||||||
if random_timer >= random_timer_trigger then
|
|
||||||
random_frame = (random_frame + math.random(-1, 1)) % compass_frames
|
|
||||||
random_timer = 0
|
|
||||||
end
|
|
||||||
for i,player in pairs(minetest.get_connected_players()) do
|
|
||||||
local function has_compass(player)
|
local function has_compass(player)
|
||||||
for _,stack in pairs(player:get_inventory():get_list("main")) do
|
for _,stack in pairs(player:get_inventory():get_list("main")) do
|
||||||
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then
|
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then
|
||||||
|
@ -28,6 +22,17 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
random_timer = random_timer + dtime
|
||||||
|
if random_timer >= random_timer_trigger then
|
||||||
|
random_frame = (random_frame + math.random(-1, 1)) % compass_frames
|
||||||
|
random_timer = 0
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
if has_compass(player) then
|
if has_compass(player) then
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
local dim = mcl_worlds.pos_to_dimension(pos)
|
local dim = mcl_worlds.pos_to_dimension(pos)
|
||||||
|
@ -61,8 +66,8 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
|
|
||||||
local images = {}
|
local images = {}
|
||||||
for frame = 0, compass_frames-1 do
|
for frame = 0, compass_frames-1 do
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name = mcl_compass
|
name = mcl_compass
|
||||||
description = A compass item which points towards the world origin.
|
description = A compass item which points towards the world origin.
|
||||||
depends = mcl_core, mcl_worlds, mesecons
|
depends = mcl_core, mcl_worlds, mesecons, mcl_util
|
||||||
optional_depends = doc
|
optional_depends = doc
|
||||||
|
|
|
@ -19,7 +19,7 @@ local find_nodes_in_area = minetest.find_nodes_in_area
|
||||||
local find_node_near = minetest.find_node_near
|
local find_node_near = minetest.find_node_near
|
||||||
local get_item_group = minetest.get_item_group
|
local get_item_group = minetest.get_item_group
|
||||||
|
|
||||||
local get_connected_players = minetest.get_connected_players
|
--local get_connected_players = minetest.get_connected_players
|
||||||
|
|
||||||
local vector = vector
|
local vector = vector
|
||||||
local math = math
|
local math = math
|
||||||
|
@ -463,7 +463,7 @@ if flame_sound then
|
||||||
|
|
||||||
-- Cycle for updating players sounds
|
-- Cycle for updating players sounds
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
--[[minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if timer < cycle then
|
if timer < cycle then
|
||||||
return
|
return
|
||||||
|
@ -474,7 +474,21 @@ if flame_sound then
|
||||||
for n = 1, #players do
|
for n = 1, #players do
|
||||||
mcl_fire.update_player_sound(players[n])
|
mcl_fire.update_player_sound(players[n])
|
||||||
end
|
end
|
||||||
end)
|
end)]]
|
||||||
|
|
||||||
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
timer = timer + dtime
|
||||||
|
if timer < cycle then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
timer = 0
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
mcl_fire.update_player_sound(player)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Stop sound and clear handle on player leave
|
-- Stop sound and clear handle on player leave
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
name = mcl_fire
|
name = mcl_fire
|
||||||
depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles
|
depends = mcl_core, mcl_worlds, mcl_sounds, mcl_particles, mcl_util
|
||||||
optional_depends = mcl_portals
|
optional_depends = mcl_portals
|
|
@ -97,14 +97,16 @@ end)
|
||||||
|
|
||||||
local updatetimer = 0
|
local updatetimer = 0
|
||||||
if not minetest.is_creative_enabled("") then
|
if not minetest.is_creative_enabled("") then
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
updatetimer = updatetimer + dtime
|
updatetimer = updatetimer + dtime
|
||||||
if updatetimer > 0.1 then
|
if updatetimer > 0.1 then return true else return false end
|
||||||
local players = minetest.get_connected_players()
|
end,
|
||||||
for i=1, #players do
|
execute = function(player, dtime)
|
||||||
update_minimap(players[i])
|
update_minimap(player)
|
||||||
end
|
end,
|
||||||
|
after_execute = function(dtime)
|
||||||
updatetimer = updatetimer - dtime
|
updatetimer = updatetimer - dtime
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = mcl_maps
|
name = mcl_maps
|
||||||
depends = mcl_wip
|
depends = mcl_wip, mcl_util
|
||||||
|
|
|
@ -181,6 +181,54 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--[[mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
main_timer = main_timer + dtime
|
||||||
|
timer = timer + dtime
|
||||||
|
if main_timer > mcl_hunger.HUD_TICK or timer > 0.5 then
|
||||||
|
if main_timer > mcl_hunger.HUD_TICK then main_timer = 0 end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local h = tonumber(mcl_hunger.get_hunger(player))
|
||||||
|
local hp = player:get_hp()
|
||||||
|
if timer > 0.5 then
|
||||||
|
-- Slow health regeneration, and hunger damage (every 4s).
|
||||||
|
-- Regeneration rate based on tutorial video <https://www.youtube.com/watch?v=zs2t-xCVHBo>.
|
||||||
|
-- Minecraft Wiki seems to be wrong in claiming that full hunger gives 0.5s regen rate.
|
||||||
|
if timerMult == 0 then
|
||||||
|
if h >= 18 and hp > 0 and hp < 20 then
|
||||||
|
-- +1 HP, +exhaustion
|
||||||
|
player:set_hp(hp+1)
|
||||||
|
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_REGEN)
|
||||||
|
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player))
|
||||||
|
elseif h == 0 then
|
||||||
|
-- Damage hungry player down to 1 HP
|
||||||
|
-- TODO: Allow starvation at higher difficulty levels
|
||||||
|
if hp-1 > 0 then
|
||||||
|
if mod_death_messages then
|
||||||
|
mcl_death_messages.player_damage(player, S("@1 starved to death.", name))
|
||||||
|
end
|
||||||
|
player:set_hp(hp-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
after_execute = function(dtime)
|
||||||
|
if timer > 0.5 then
|
||||||
|
timer = 0
|
||||||
|
timerMult = timerMult + 1
|
||||||
|
if timerMult > 7 then
|
||||||
|
timerMult = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})]]
|
||||||
|
|
||||||
--[[ IF HUNGER IS NOT ENABLED ]]
|
--[[ IF HUNGER IS NOT ENABLED ]]
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name = mcl_hunger
|
name = mcl_hunger
|
||||||
author = BlockMen
|
author = BlockMen
|
||||||
description = Adds a simple hunger meachanic with satiation, food poisoning and different healing.
|
description = Adds a simple hunger meachanic with satiation, food poisoning and different healing.
|
||||||
depends = hudbars
|
depends = hudbars, mcl_util
|
||||||
optional_depends = mcl_death_messages
|
optional_depends = mcl_death_messages
|
||||||
|
|
|
@ -147,8 +147,8 @@ local player_set_animation = mcl_player.player_set_animation
|
||||||
local player_attached = mcl_player.player_attached
|
local player_attached = mcl_player.player_attached
|
||||||
|
|
||||||
-- Check each player and apply animations
|
-- Check each player and apply animations
|
||||||
minetest.register_globalstep(function(dtime)
|
mcl_util.register_player_globalstep({
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
execute = function(player, dtime)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local model_name = player_model[name]
|
local model_name = player_model[name]
|
||||||
local model = model_name and models[model_name]
|
local model = model_name and models[model_name]
|
||||||
|
@ -167,8 +167,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
animation_speed_mod = animation_speed_mod / 2
|
animation_speed_mod = animation_speed_mod / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- ask if player is swiming
|
-- ask if player is swiming
|
||||||
local head_in_water = minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0
|
local head_in_water = minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0
|
||||||
-- ask if player is sprinting
|
-- ask if player is sprinting
|
||||||
|
@ -217,8 +215,8 @@ minetest.register_globalstep(function(dtime)
|
||||||
player_set_animation(player, "sneak_stand", animation_speed_mod)
|
player_set_animation(player, "sneak_stand", animation_speed_mod)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
end)
|
})
|
||||||
|
|
||||||
-- Don't change HP if the player falls in the water or through End Portal:
|
-- Don't change HP if the player falls in the water or through End Portal:
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
name = mcl_player
|
name = mcl_player
|
||||||
author = celeron55
|
author = celeron55
|
||||||
|
depends = mcl_util
|
||||||
description = Adds the 3D player model, taken from Minetest Game 0.4.16.
|
description = Adds the 3D player model, taken from Minetest Game 0.4.16.
|
||||||
|
|
|
@ -39,37 +39,51 @@ local get_player_nodes = function(player_pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
time = time + dtime
|
time = time + dtime
|
||||||
|
|
||||||
-- Run the rest of the code every 0.5 seconds
|
-- Run the rest of the code every 0.5 seconds
|
||||||
if time < 0.5 then
|
if time < 0.5 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- reset time for next check
|
-- reset time for next check
|
||||||
-- FIXME: Make sure a regular check interval applies
|
-- FIXME: Make sure a regular check interval applies
|
||||||
time = 0
|
time = 0
|
||||||
|
|
||||||
-- check players
|
-- check players
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
-- who am I?
|
-- who am I?
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
-- where am I?
|
-- where am I?
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
||||||
mcl_playerinfo[name].node_stand = node_stand
|
mcl_playerinfo[name].node_stand = node_stand
|
||||||
mcl_playerinfo[name].node_stand_below = node_stand_below
|
mcl_playerinfo[name].node_stand_below = node_stand_below
|
||||||
mcl_playerinfo[name].node_head = node_head
|
mcl_playerinfo[name].node_head = node_head
|
||||||
mcl_playerinfo[name].node_feet = node_feet
|
mcl_playerinfo[name].node_feet = node_feet
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--[[mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime)
|
||||||
|
time = time + dtime
|
||||||
|
if time < 0.5 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
-- reset time for next check
|
||||||
|
-- FIXME: Make sure a regular check interval applies
|
||||||
|
time = 0
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
||||||
|
mcl_playerinfo[name].node_stand = node_stand
|
||||||
|
mcl_playerinfo[name].node_stand_below = node_stand_below
|
||||||
|
mcl_playerinfo[name].node_head = node_head
|
||||||
|
mcl_playerinfo[name].node_feet = node_feet
|
||||||
|
end,
|
||||||
|
})]]
|
||||||
|
|
||||||
-- set to blank on join (for 3rd party mods)
|
-- set to blank on join (for 3rd party mods)
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name = mcl_playerinfo
|
name = mcl_playerinfo
|
||||||
author = TenPlus1
|
author = TenPlus1
|
||||||
description = This is a helper mod for other mod to query the nodes around the player.
|
description = This is a helper mod for other mod to query the nodes around the player.
|
||||||
depends = mcl_init, mcl_core, mcl_particles, mcl_death_messages
|
depends = mcl_init, mcl_core, mcl_particles, mcl_death_messages, mcl_util
|
||||||
|
|
|
@ -81,11 +81,18 @@ minetest.register_on_joinplayer(function(player)
|
||||||
end, player)
|
end, player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function()
|
--[[minetest.register_globalstep(function()
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
wieldview:update_wielded_item(player)
|
wieldview:update_wielded_item(player)
|
||||||
end
|
end
|
||||||
end)
|
end)]]
|
||||||
|
|
||||||
|
mcl_util.register_player_globalstep({
|
||||||
|
can_execute = function(dtime) return true end,
|
||||||
|
execute = function(player, dtime)
|
||||||
|
wieldview:update_wielded_item(player)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_entity("wieldview:wieldnode", {
|
minetest.register_entity("wieldview:wieldnode", {
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name = wieldview
|
name = wieldview
|
||||||
author = stujones11
|
author = stujones11
|
||||||
description = Makes hand wielded items visible to other players.
|
description = Makes hand wielded items visible to other players.
|
||||||
depends = mcl_armor
|
depends = mcl_armor, mcl_util
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue