Bionic Commando (NES) - Lua
Jump to navigation
Jump to search
Equipment Select
This Lua script will let you change your equipment at any time. Middle-click your mouse in the emulator and it will open an equipment menu. Left-click on everything you want, and click OK to continue. It currently works on the USA and European releases, but not the Japanese release. Works with FCEUX and BizHawk.
-- Lua script for Bionic Commando. -- Click the middle mouse button to open a menu which will let you change your equipment on the fly. -- Written by Dean Tersigni (TheAlmightyGuru), 2020-12-31 -- Please visit www.romdetectives.com for more scripts. function drawText (x, y, text, foreColor, backColor) if emulator == "FCEUX" then gui.text(x, y, text, foreColor, backColor) elseif emulator == "BizHawk" then gui.pixelText(x, y, text, foreColor, backColor, 0) end end function drawBox (x1, y1, x2, y2, fillColor, lineColor) if emulator == "FCEUX" then gui.drawbox(x1, y1, x2, y2, fillColor, lineColor) elseif emulator == "BizHawk" then gui.drawBox(x1, y1, x2, y2, lineColor, fillColor) end end -- Determine which emulator is being used. if FCEU then emulator = "FCEUX" elseif bizstring then emulator = "BizHawk" else emulator = "Unknown" end -- Setup buttons for the menu. buttons = { { 0x04CA, 0, "Rifle", 8, 20, 118, 32 }, { 0x04CA, 1, "Rocker Launcher", 8, 36, 118, 48 }, { 0x04CA, 2, "Wide Cannon", 8, 52, 118, 64 }, { 0x04CA, 3, "Machinegun", 8, 68, 118, 80 }, { 0x04CA, 4, "3 Way", 8, 84, 118, 96 }, { 0x04D1, 0, "Pendant", 128, 20, 238, 32 }, { 0x04D1, 1, "Helmet", 128, 36, 238, 48 }, { 0x04D1, 2, "Bulletproof Vest", 128, 52, 238, 64 }, { 0x04D8, 0, "Flare Bombs", 8, 120, 118, 132 }, { 0x04D8, 1, "Medicine", 8, 136, 118, 148 }, { 0x04D8, 2, "Permit", 8, 152, 118, 164 }, { 0x04D8, 3, "Steel Boots", 8, 168, 118, 180 }, { 0x04D8, 4, "Rapid Fire Device", 8, 184, 118, 196 }, { 0x04DF, 0, "Alpha", 128, 120, 238, 132 }, { 0x04DF, 1, "Beta", 128, 136, 238, 148 }, { 0x04DF, 2, "Gamma", 128, 152, 238, 164 }, { 0x04DF, 3, "Delta", 128, 168, 238, 180 }, { 0, 0, "OK", 230, 212, 250, 224 } } while true do -- Use emulator-specific methods for reading mouse input. if emulator == "FCEUX" then mouse = input.get() leftClick = mouse.leftclick middleClick = mouse.middleclick mouseX = mouse.xmouse mouseY = mouse.ymouse elseif emulator == "BizHawk" then mouse = input.getmouse() leftClick = mouse.Left middleClick = mouse.Middle mouseX = mouse.X -- Correct for NTSC missing the first 8 scanlines. if emu.getdisplaytype() == "NTSC" then mouseY = mouse.Y + 8 else mouseY = mouse.Y end end if middleClick then if not menuOpen then menuOpen = true end end if menuOpen then -- Draw the menu. for i, v in pairs(buttons) do -- Find the selected item in each group to highlight it. if v[3] ~= "OK" then if memory.readbyte(v[1]) == v[2] then boxColor = "yellow" else boxColor = "white" end else boxColor = "white" end drawBox(v[4], v[5], v[6], v[7], boxColor, "green") drawText(v[4] + 4, v[5] + 3, v[3], "black", boxColor) -- Check for clicking on this button. if leftClick then if mouseX >= v[4] and mouseY >= v[5] and mouseX <= v[6] and mouseY <= v[7] then if v[3] == "OK" then menuOpen = false else -- Set this as the active gun/armor/item/communicator. memory.writebyte(v[1], v[2]) -- If the player doesn't have this gun/armor/item/communicator, give it to them. if memory.readbyte(v[1] + 1 + v[2]) == 0x00 then memory.writebyte(v[1] + 1 + v[2], 0x01) end end end end end end emu.frameadvance() end