mirror of
https://github.com/minetest-mods/player_monoids.git
synced 2025-01-10 01:20:20 +01:00
Add .luacheckrc
and fix warnings.
This commit is contained in:
parent
481ef9e2cd
commit
5d90e32196
9
.luacheckrc
Normal file
9
.luacheckrc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"minetest",
|
||||||
|
"vector",
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"player_monoids",
|
||||||
|
}
|
2
init.lua
2
init.lua
@ -65,7 +65,7 @@ function mon_meta:add_change(player, value, id)
|
|||||||
local p_name = player:get_player_name()
|
local p_name = player:get_player_name()
|
||||||
|
|
||||||
local def = self.def
|
local def = self.def
|
||||||
|
|
||||||
local p_effects = self.player_map[p_name]
|
local p_effects = self.player_map[p_name]
|
||||||
if p_effects == nil then
|
if p_effects == nil then
|
||||||
p_effects = {}
|
p_effects = {}
|
||||||
|
@ -1,17 +1,5 @@
|
|||||||
-- Standard effect monoids, to provide canonicity.
|
-- Standard effect monoids, to provide canonicity.
|
||||||
|
|
||||||
local function mult(x, y) return x * y end
|
|
||||||
|
|
||||||
local function mult_fold(elems)
|
|
||||||
local tot = 1
|
|
||||||
|
|
||||||
for k,v in pairs(elems) do
|
|
||||||
tot = tot * v
|
|
||||||
end
|
|
||||||
|
|
||||||
return tot
|
|
||||||
end
|
|
||||||
|
|
||||||
local function v_mult(v1, v2)
|
local function v_mult(v1, v2)
|
||||||
local res = {}
|
local res = {}
|
||||||
|
|
||||||
@ -26,7 +14,7 @@ local function v_mult_fold(identity)
|
|||||||
return function(elems)
|
return function(elems)
|
||||||
local tot = identity
|
local tot = identity
|
||||||
|
|
||||||
for k, v in pairs(elems) do
|
for _, v in pairs(elems) do
|
||||||
tot = v_mult(tot, v)
|
tot = v_mult(tot, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,7 +30,7 @@ player_monoids.speed = monoid({
|
|||||||
combine = function(x, y) return x * y end,
|
combine = function(x, y) return x * y end,
|
||||||
fold = function(elems)
|
fold = function(elems)
|
||||||
local res = 1
|
local res = 1
|
||||||
for k, v in pairs(elems) do
|
for _, v in pairs(elems) do
|
||||||
res = res * v
|
res = res * v
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,7 +51,7 @@ player_monoids.jump = monoid({
|
|||||||
combine = function(x, y) return x * y end,
|
combine = function(x, y) return x * y end,
|
||||||
fold = function(elems)
|
fold = function(elems)
|
||||||
local res = 1
|
local res = 1
|
||||||
for k, v in pairs(elems) do
|
for _, v in pairs(elems) do
|
||||||
res = res * v
|
res = res * v
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -83,7 +71,7 @@ player_monoids.gravity = monoid({
|
|||||||
combine = function(x, y) return x * y end,
|
combine = function(x, y) return x * y end,
|
||||||
fold = function(elems)
|
fold = function(elems)
|
||||||
local res = 1
|
local res = 1
|
||||||
for k, v in pairs(elems) do
|
for _, v in pairs(elems) do
|
||||||
res = res * v
|
res = res * v
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -103,7 +91,7 @@ player_monoids.gravity = monoid({
|
|||||||
player_monoids.fly = monoid({
|
player_monoids.fly = monoid({
|
||||||
combine = function(p, q) return p or q end,
|
combine = function(p, q) return p or q end,
|
||||||
fold = function(elems)
|
fold = function(elems)
|
||||||
for k, v in pairs(elems) do
|
for _, v in pairs(elems) do
|
||||||
if v then return true end
|
if v then return true end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -130,7 +118,7 @@ player_monoids.fly = monoid({
|
|||||||
player_monoids.noclip = monoid({
|
player_monoids.noclip = monoid({
|
||||||
combine = function(p, q) return p or q end,
|
combine = function(p, q) return p or q end,
|
||||||
fold = function(elems)
|
fold = function(elems)
|
||||||
for k, v in pairs(elems) do
|
for _, v in pairs(elems) do
|
||||||
if v then return true end
|
if v then return true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
2
test.lua
2
test.lua
@ -11,7 +11,7 @@ local function test(player)
|
|||||||
local p_name = player:get_player_name()
|
local p_name = player:get_player_name()
|
||||||
|
|
||||||
minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
|
minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
|
||||||
|
|
||||||
minetest.after(3, function()
|
minetest.after(3, function()
|
||||||
speed:del_change(player, ch_id)
|
speed:del_change(player, ch_id)
|
||||||
minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
|
minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
|
||||||
|
Loading…
Reference in New Issue
Block a user