[Twinsen] Capsule lifetime isn't changed in UI
Posted: Tue Dec 10, 2019 12:28 pm
If one modifies the force.following_robots_lifetime_modifier, it takes effect but doesn't modify the tooltip, unlike damage, firing rate, etc.
www.factorio.com
https://forums.factorio.com/
Code: Select all
local commands_table = {}
commands_table.follower_lifetime_bonus = {}
commands_table.follower_lifetime_bonus.command = "follower_lifetime_bonus"
commands_table.follower_lifetime_bonus.help = "add or subtract to following_robots_lifetime_bonus. no +/- sets the value, no number prints the value. Value can be decimal"
commands_table.follower_lifetime_bonus.func = function(callback)
local prm = callback.parameter
local player_index = callback.player_index
local value = nil
local sign = nil
if prm ~= nil then
-- game.player.print("string passed was " .. prm)
else
-- game.player.print("nothing was passed")
end
if prm == nil then prm = "" end
sign = string.match(prm, "^([+-])")
value = string.match(prm, "^[+-]?([0-9]*%.?[0-9]*)")
-- the pattern [0-9]*%.?[0-9]* may match none, none, none, producing a successful ""
if value == nil or value == "" then
game.player.print("No or invalid value. The current bonus is " .. game.get_player(player_index).force.following_robots_lifetime_modifier)
return
end
--implicitly prm is not nil for this
if sign == nil then
game.player.print("setting follower lifetime bonus to " .. value)
game.get_player(player_index).force.following_robots_lifetime_modifier = tonumber(value)
game.player.print("Bonus is now: " .. game.get_player(player_index).force.following_robots_lifetime_modifier)
return
elseif sign == "+" then
game.player.print("Adding to bonus")
game.get_player(player_index).force.following_robots_lifetime_modifier = game.get_player(player_index).force.following_robots_lifetime_modifier + tonumber(value)
game.player.print("Bonus is now: " .. game.get_player(player_index).force.following_robots_lifetime_modifier)
return
elseif sign == "-" then
game.player.print("Subtracting from bonus")
game.get_player(player_index).force.following_robots_lifetime_modifier = game.get_player(player_index).force.following_robots_lifetime_modifier - tonumber(value)
game.player.print("Bonus is now: " .. game.get_player(player_index).force.following_robots_lifetime_modifier)
return
end
-- we should never reach here
return
end
for _, cmd in pairs(commands_table) do
commands.add_command(cmd.command, cmd.help, cmd.func)
end