Fixed Existing Lua Check Errors

This commit is contained in:
Cooldude2606
2020-05-26 18:21:10 +01:00
parent 2aaeb06be3
commit 32507492b8
76 changed files with 1622 additions and 1617 deletions

View File

@@ -6,27 +6,27 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
local format_chat_colour = _C.format_chat_colour --- @dep expcore.common
local function step_component(c1,c2)
local function step_component(c1, c2)
if c1 < 0 then
return 0,c2+c1
return 0, c2+c1
elseif c1 > 1 then
return 1,c2-c1+1
return 1, c2-c1+1
else
return c1,c2
return c1, c2
end
end
local function step_color(color)
color.r,color.g = step_component(color.r,color.g)
color.g,color.b = step_component(color.g,color.b)
color.b,color.r = step_component(color.b,color.r)
color.r = step_component(color.r,0)
color.r, color.g = step_component(color.r, color.g)
color.g, color.b = step_component(color.g, color.b)
color.b, color.r = step_component(color.b, color.r)
color.r = step_component(color.r, 0)
return color
end
local function next_color(color,step)
local function next_color(color, step)
step = step or 0.1
local new_color = {r=0,g=0,b=0}
local new_color = {r=0, g=0, b=0}
if color.b == 0 and color.r ~= 0 then
new_color.r = color.r-step
new_color.g = color.g+step
@@ -43,19 +43,19 @@ end
--- Sends an rainbow message in the chat
-- @command rainbow
-- @tparam string message the message that will be printed in chat
Commands.new_command('rainbow','Sends an rainbow message in the chat')
:add_param('message',false)
Commands.new_command('rainbow', 'Sends an rainbow message in the chat')
:add_param('message', false)
:enable_auto_concat()
:register(function(player,message,raw)
:register(function(player, message)
local player_name = player and player.name or '<Server>'
local player_color = player and player.color or nil
local color_step = 3/message:len()
if color_step > 1 then color_step = 1 end
local current_color = {r=1,g=0,b=0}
local output = format_chat_colour(player_name..': ',player_color)
output = output..message:gsub('%S',function(letter)
local rtn = format_chat_colour(letter,current_color)
current_color = next_color(current_color,color_step)
local current_color = {r=1, g=0, b=0}
local output = format_chat_colour(player_name..': ', player_color)
output = output..message:gsub('%S', function(letter)
local rtn = format_chat_colour(letter, current_color)
current_color = next_color(current_color, color_step)
return rtn
end)
game.print(output)