X Tutup
Skip to content

Commit faeb40f

Browse files
committed
Fix hyperspace fuel cheat
Set icons inactive on jump/hyperspace.
1 parent de64685 commit faeb40f

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

data/pigui/modules/info-view/03-econ-trade.lua

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,26 @@ local function transfer_hyperfuel_mil(hyperdrive, amt)
217217
end
218218

219219
local function fuelTransferButton(drive, amt)
220-
local icon = amt < 0 and icons.chevron_down or icons.chevron_up
220+
local driveEnabled = false
221221

222-
if ui.button(ui.get_icon_glyph(icon) .. tostring(math.abs(amt))) then
222+
-- Don't allow transferring fuel while the hyperdrive is doing its thing
223+
if Game.player:IsHyperspaceActive() or
224+
Game.player.flightState == "JUMPING" or
225+
Game.player.flightState == "HYPERSPACE" then
226+
driveEnabled = true
227+
end
223228

224-
if drive.fuel == Commodities.hydrogen then
225-
transfer_hyperfuel_hydrogen(drive, amt)
226-
elseif drive.fuel == Commodities.military_fuel then
227-
transfer_hyperfuel_mil(drive, amt)
228-
end
229+
local color = driveEnabled and ui.theme.buttonColors.disabled or ui.theme.buttonColors.default
230+
local icon = amt < 0 and icons.chevron_down or icons.chevron_up
229231

232+
if ui.button(ui.get_icon_glyph(icon) .. tostring(math.abs(amt)), Vector2(100, 0), color) then
233+
if not driveEnabled then
234+
if drive.fuel == Commodities.hydrogen then
235+
transfer_hyperfuel_hydrogen(drive, amt)
236+
elseif drive.fuel == Commodities.military_fuel then
237+
transfer_hyperfuel_mil(drive, amt)
238+
end
239+
end
230240
end
231241
end
232242

@@ -246,9 +256,6 @@ local function drawCentered(id, fun)
246256
end
247257

248258
local function drawFuelTransfer(drive)
249-
-- Don't allow transferring fuel while the hyperdrive is doing its thing
250-
if Game.player:IsHyperspaceActive() then return end
251-
252259
drawCentered("Hyperdrive", function()
253260
ui.horizontalGroup(function()
254261
fuelTransferButton(drive, 10)

0 commit comments

Comments
 (0)
X Tutup