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

@@ -17,9 +17,9 @@ local bonus_store = Store.register(function(player)
end)
-- Apply a bonus amount to a player
local function apply_bonus(player,amount)
local function apply_bonus(player, amount)
if not amount then return end
for bonus,min_max in pairs(config) do
for bonus, min_max in pairs(config) do
local increase = min_max[2]*amount
player[bonus] = min_max[1]+increase
end
@@ -28,32 +28,32 @@ end
--- Changes the amount of bonus you receive
-- @command bonus
-- @tparam number amount range 0-50 the percent increase for your bonus
Commands.new_command('bonus','Changes the amount of bonus you receive')
:add_param('amount','integer-range',0,50)
:register(function(player,amount)
Commands.new_command('bonus', 'Changes the amount of bonus you receive')
:add_param('amount', 'integer-range', 0,50)
:register(function(player, amount)
local percent = amount/100
Store.set(bonus_store,player,percent)
Commands.print{'expcom-bonus.set',amount}
Commands.print({'expcom-bonus.wip'},'orange')
Store.set(bonus_store, player, percent)
Commands.print{'expcom-bonus.set', amount}
Commands.print({'expcom-bonus.wip'}, 'orange')
end)
-- When store is updated apply new bonus to the player
Store.watch(bonus_store,function(value,category)
Store.watch(bonus_store, function(value, category)
local player = Game.get_player_from_any(category)
apply_bonus(player,value)
apply_bonus(player, value)
end)
-- When a player respawns re-apply bonus
Event.add(defines.events.on_player_respawned,function(event)
Event.add(defines.events.on_player_respawned, function(event)
local player = Game.get_player_by_index(event.player_index)
local value = Store.get(bonus_store,player)
apply_bonus(player,value)
local value = Store.get(bonus_store, player)
apply_bonus(player, value)
end)
-- When a player dies allow them to have instant respawn
Event.add(defines.events.on_player_died,function(event)
Event.add(defines.events.on_player_died, function(event)
local player = Game.get_player_by_index(event.player_index)
if Roles.player_has_flag(player,'instance-respawn') then
if Roles.player_has_flag(player, 'instance-respawn') then
player.ticks_to_respawn = 120
end
end)
@@ -61,12 +61,12 @@ end)
-- Remove bonus if a player no longer has access to the command
local function role_update(event)
local player = Game.get_player_by_index(event.player_index)
if not Roles.player_allowed(player,'command/bonus') then
Store.clear(bonus_store,player)
if not Roles.player_allowed(player, 'command/bonus') then
Store.clear(bonus_store, player)
end
end
Event.add(Roles.events.on_role_assigned,role_update)
Event.add(Roles.events.on_role_unassigned,role_update)
Event.add(Roles.events.on_role_assigned, role_update)
Event.add(Roles.events.on_role_unassigned, role_update)
return bonus_store