Skip to content

Commit

Permalink
* Move cheat menu to mod setting
Browse files Browse the repository at this point in the history
* Show Admin Panel default to false
* Add Auto-Targeting toggle to mod top GUI
* Check if Orbital Ion Cannon is already tracked by silo-script to avoid adding multiple copies to the tracked-items-table
  • Loading branch information
Suprcheese committed Mar 11, 2019
1 parent 0be73f4 commit c9b425c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
28 changes: 19 additions & 9 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ function On_Init()
global.auto_tick = global.auto_tick or 0
global.readyTick = {}
if remote.interfaces["silo_script"] then
remote.call("silo_script", "add_tracked_item", "orbital-ion-cannon")
local tracked_items = remote.call("silo_script", "get_tracked_items")
if not tracked_items["orbital-ion-cannon"] then
remote.call("silo_script", "add_tracked_item", "orbital-ion-cannon")
end
end
if not global.permissions then
global.permissions = {}
global.permissions[-2] = false
global.permissions[-1] = true
global.permissions[-2] = settings.global["ion-cannon-auto-targeting"].value
global.permissions[-1] = false
global.permissions[0] = false
end
for i, player in pairs(game.players) do
Expand Down Expand Up @@ -103,7 +106,7 @@ script.on_event(defines.events.on_forces_merging, function(event)
end)

function init_GUI(player)
if #global.forces_ion_cannon_table[player.force.name] == 0 then
if #global.forces_ion_cannon_table[player.force.name] == 0 and not player.cheat_mode then
local frame = player.gui.left["ion-cannon-stats"]
if frame then
frame.destroy()
Expand Down Expand Up @@ -153,9 +156,9 @@ function open_GUI(player)
frame.add{type = "table", column_count = 2, name = "ion-cannon-admin-panel-header"}
frame["ion-cannon-admin-panel-header"].add{type = "label", caption = {"ion-cannon-admin-panel-show"}}
frame["ion-cannon-admin-panel-header"].add{type = "checkbox", state = global.permissions[-1], name = "show"}
frame["ion-cannon-admin-panel-header"].add{type = "label", caption = {"ion-cannon-cheat-menu-show"}}
if global.permissions[-2] == nil then global.permissions[-2] = false end
frame["ion-cannon-admin-panel-header"].add{type = "checkbox", state = global.permissions[-2], name = "cheats"}
-- frame["ion-cannon-admin-panel-header"].add{type = "label", caption = {"ion-cannon-cheat-menu-show"}}
if global.permissions[-2] == nil then global.permissions[-2] = settings.global["ion-cannon-auto-targeting"].value end
-- frame["ion-cannon-admin-panel-header"].add{type = "checkbox", state = global.permissions[-2], name = "cheats"}
if frame["ion-cannon-admin-panel-header"]["show"].state then
frame.add{type = "table", column_count = 2, name = "ion-cannon-admin-panel-table"}
frame["ion-cannon-admin-panel-table"].add{type = "label", caption = {"player-names"}}
Expand All @@ -167,12 +170,15 @@ function open_GUI(player)
frame["ion-cannon-admin-panel-table"].add{type = "checkbox", state = global.permissions[player.index], name = player.index .. ""}
end
end
if frame["ion-cannon-admin-panel-header"]["cheats"].state then
-- if frame["ion-cannon-admin-panel-header"]["cheats"].state then
if settings.global["ion-cannon-cheat-menu"].value then
frame["ion-cannon-admin-panel-header"].add{type = "label", caption = {"ion-cannon-cheat-one"}}
frame["ion-cannon-admin-panel-header"].add{type = "button", name = "add-ion-cannon", style = "ion-cannon-button-style"}
frame["ion-cannon-admin-panel-header"].add{type = "label", caption = {"ion-cannon-cheat-five"}}
frame["ion-cannon-admin-panel-header"].add{type = "button", name = "add-five-ion-cannon", style = "ion-cannon-button-style"}
end
frame["ion-cannon-admin-panel-header"].add{type = "label", caption = {"mod-setting-name.ion-cannon-auto-targeting"}}
frame["ion-cannon-admin-panel-header"].add{type = "checkbox", state = global.permissions[-2], name = "ion-cannon-auto-target-enabled"}
end
frame.add{type = "table", column_count = 1, name = "ion-cannon-table"}
frame["ion-cannon-table"].add{type = "label", caption = {"ion-cannons-in-orbit", #global.forces_ion_cannon_table[forceName]}}
Expand Down Expand Up @@ -516,10 +522,14 @@ script.on_event(defines.events.on_gui_checked_state_changed, function(event)
global.goToFull[event.player_index] = false
global.permissions[-1] = checkbox.state
open_GUI(game.players[event.player_index])
elseif checkbox.name == "cheats" then
elseif checkbox.name == "ion-cannon-auto-target-enabled" then
global.goToFull[event.player_index] = false
global.permissions[-2] = checkbox.state
open_GUI(game.players[event.player_index])
-- elseif checkbox.name == "cheats" then
-- global.goToFull[event.player_index] = false
-- global.permissions[-2] = checkbox.state
-- open_GUI(game.players[event.player_index])
else
local index = tonumber(checkbox.name)
if checkbox.parent.name == "ion-cannon-admin-panel-table" then
Expand Down
3 changes: 2 additions & 1 deletion locale/en/en.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ allowed=Allowed
toggle-all=Toggle All
ion-permission-denied=Error: You have been blocked from targeting ion cannons by an admin.

ion-cannon-cheat-menu-show=Show Cheat Menu
ion-cannon-cheat-one=Cheat: Launch one Ion Cannon
ion-cannon-cheat-five=Cheat: Launch five Ion Cannons

Expand Down Expand Up @@ -71,6 +70,7 @@ ion-cannon-ready-ticks=Min. Duration Between "Ion Cannon Ready" Announcements (t
ion-cannon-bob-updates=Enable Bob's Mods-compatibility
ion-cannon-chart-tag-duration=Map Marker Duration (ticks)
ion-cannon-min-cannons-ready=Minimum Cannons Ready Before Auto-Targeting
ion-cannon-cheat-menu=Show Cheat Menu
[mod-setting-description]
ion-cannon-cooldown-seconds= The cooldown time for each orbital ion cannon, in seconds.
Expand All @@ -90,3 +90,4 @@ ion-cannon-ready-ticks= The number of gameticks that must pass between consecuti
ion-cannon-bob-updates= If true, this mod will update its recipes and technologies to include new, high-tier items from Bob's Electronics, Tech, Warfare, and/or Power mods.
ion-cannon-chart-tag-duration= How long the map markers for ion cannon targets will last before being deleted, measured in gameticks. There are 60 ticks per second, so the default 720 ticks would be 12 seconds -- 5 seconds beyond the default time of 7 seconds from target designation to blast impact.
ion-cannon-min-cannons-ready= The minimum number of ready-to-fire cannons required before any targets will be auto-designated. This lets you have a buffer of ion cannons that will always be available for manual targeting.
ion-cannon-cheat-menu=Display a cheat menu in the mod dialog that allows you to add ion cannons into orbit for free.
4 changes: 2 additions & 2 deletions locale/fr/fr.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ allowed=Autorisé
toggle-all=Cocher/décocher tout
ion-permission-denied=Erreur : un admin vous a interdit d'utiliser les canons à ions.
ion-cannon-cheat-menu-show=Afficher le menu de triche
ion-cannon-cheat-one=Triche : Mettre en orbite un canon à ions
ion-cannon-cheat-five=Triche : Mettre en orbite cinq canons à ions
Expand Down Expand Up @@ -70,6 +69,7 @@ ion-cannon-ready-ticks=Délai minimal entre 2 annonces "Ion Cannon Ready" (en ti
ion-cannon-bob-updates=Activer la compatibilité avec Bob's Mods
ion-cannon-chart-tag-duration=Durée du marqueur de tir sur la carte (en ticks)
ion-cannon-min-cannons-ready=Nombre minimal de canons à ions prêts avant le ciblage automatisé
ion-cannon-cheat-menu=Afficher le menu de triche

[mod-setting-description]
ion-cannon-cooldown-seconds= La cadence de tir de chaque canon à ions (en secondes)
Expand All @@ -83,7 +83,7 @@ ion-cannon-heatup-multiplier= Ce multiplicateur affecte le temps qui s'écoule e
ion-cannon-auto-targeting= Activer le ciblage automatisé par balayage radar
ion-cannon-target-worms= Activer le ciblage automatisé des vers (en plus des nids alien)
ion-cannon-auto-target-visible= Activer le ciblage automatisé des nouvelles colonies dans la zone visible. Attention : une colonie s'établissant à proximité immédiate de vos structures pourrait causer un tir responsable de dommages collatéraux
ion-cannon-custom-alerts= Activer les alertes personnalisées lors de la désignation d'une cible aux canons à ions
ion-cannon-custom-alerts= Activer les alertes personnalisées lors de la désignation d'une cible aux canons à ions
ion-cannon-flames= Activer l'embrasement des objets à l'intérieur de la zone d'explosion. Attention : les incendies peuvent se propager, notamment en forêt.
ion-cannon-ready-ticks=Le délai minimal entre 2 annonces vocales "Ion cannon ready" (en ticks). 1 seconde vaut 60 ticks. La valeur par défaut, 300 ticks, correspond donc à 5 secondes.
ion-cannon-bob-updates= Activer pour mettre à jour les recettes et technologies en fonction des nouveaux objets de haut niveau introduits par les mods suivants : Bob's Electronics, Tech, Warfare, et/ou Power.
Expand Down
2 changes: 1 addition & 1 deletion locale/ru/ru.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ allowed=Разрешено
toggle-all=Переключить все
ion-permission-denied=Ошибка: администратор заблокировал вам доступ к ионным пушкам.

ion-cannon-cheat-menu-show=Показать чит-меню
ion-cannon-cheat-one=Чит: Запустить одну ионную пушку
ion-cannon-cheat-five=Чит: Запустить пять ионных пушек

Expand Down Expand Up @@ -70,6 +69,7 @@ ion-cannon-ready-ticks=Минимум Продолжительность меж
ion-cannon-bob-updates=Включить совместимость модов Боба
ion-cannon-chart-tag-duration=Маркер карты продолжительность (тики)
ion-cannon-min-cannons-ready=Минимум пушек, готовых перед автоматическим огнем
ion-cannon-cheat-menu=Показать чит-меню

[mod-setting-description]
ion-cannon-cooldown-seconds=Время перезарядки каждой орбитальной ионной пушки в секундах.
Expand Down
7 changes: 7 additions & 0 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ data:extend({
default_value = 2,
minimum_value = 0
},
{
type = "bool-setting",
name = "ion-cannon-cheat-menu",
setting_type = "runtime-global",
order = "g",
default_value = false
},
-- Runtime (per player)
{
type = "bool-setting",
Expand Down

0 comments on commit c9b425c

Please sign in to comment.