Skip to content

Commit

Permalink
Fix /cheat command not researching all valid technologies.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinwessels committed May 1, 2024
1 parent 7e26c32 commit 63712a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 0.5.5
Date: ??.??.2024
Bugfixes:
- Fix /cheat command not researching all valid technologies. (#24)
---------------------------------------------------------------------------------------------------
Version: 0.5.4
Date: 13.04.2024
Changes:
Expand Down
25 changes: 25 additions & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,28 @@ remote.add_interface("Ultracube", {
["milestones_presets"] = milestones,
})

script.on_event(defines.events.on_console_command, function(event)
if event.command ~= "cheat" then return end
local player = game.get_player(event.player_index)
if not player.admin then return end

local function recusively_research_techs(force)
-- Research the first found tech, and then call it again
for _, tech in pairs(force.technologies) do
if
tech.enabled -- Make sure we only research techs the player are able to research
and not tech.researched
and tech.level < 4 -- Ignore infinite techs
and tech.name ~= "cube-everything" -- Don't auto-win the game
then
tech.researched = true

-- Only try again if we found a tech to research
recusively_research_techs(force)
return
end
end
end

recusively_research_techs(player.force)
end)

0 comments on commit 63712a5

Please sign in to comment.