Skip to content

Instantly share code, notes, and snippets.

Created March 26, 2017 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bc20af065e32f47b16b86578e76668e9 to your computer and use it in GitHub Desktop.
Save anonymous/bc20af065e32f47b16b86578e76668e9 to your computer and use it in GitHub Desktop.
--Global Mario & the 7 Orbs level script
--Coded by Sambo (Feel free to use any part of this code, but please credit me if you do. This took HOURS of work. You may not use my custom HUD images though, except for the items that appear in the reserve box.)
--User Data (encrypted to discourage CHEATING)
local encrypt = loadAPI("encrypt")
_G["saveData"] = encrypt.Data(Data.DATA_WORLD, "Save", true)
if not saveData:get("data_created") then --While this part could be removed, it helps me keep track of saved data values.
saveData:set("data_created", 1)
--Unlockable Item Data
saveData:set("bombsUnlocked", 0)
saveData:set("springUnlocked", 0) -- Unlocks by clearing level ww1-BoingyBoing Land
saveData:set("greenShoeUnlocked", 0)
saveData:set("redShoeUnlocked", 0)
saveData:set("blueShoeUnlocked", 0)
saveData:save()
end
local twoPlayerCheck = false
_G["split_screen_offset"] = 0 -- Fixes 'arithmatic on nil value' bug when testing value in lunadll.
local starsCounted = false
_G["show_hud"] = true
local s = 0
--Shop data and vars
shopData = Data(Data.DATA_WORLD, "Shop", false) -- Sets up shop data. Nothing is actually saved here; it is simply used to allow for variable keys.
local shop_initialized = false
local starCheck = false
local keyPressed = true
local shopHUD_loaded = true
local showScrollUp = 0
local showScrollDown = 0
function Shop_Initialize() --Loads shop item list if this level contains a shop.
shopData:set("item1", "Mushroom")
shopData:set("item2", "Fire Flower")
shopData:set("item3", "Super Leaf")
NPC1isSpawned, NPC2IsSpawned = false, false
items = 3
i = 1
if shop == "MIShop" then
if saveData:get("star_Purchased") == nil then
shopData:set("item4", "Power Star")
items = 4
end
elseif shop == "normal" then --Unlockable shop items
if DCoins_total >= 30 then
items = items + 1
shopData:set("item" .. items, "Ice Flower")
if DCoins_total >= 50 then
items = items + 1
shopData:set("item" .. items, "Tanooki Suit")
if DCoins_total >= 75 then
items = items + 1
shopData:set("item" .. items, "Hammer Suit")
end
end
end
if saveData:get("bombsUnlocked") == 1 then
items = items + 1
shopData:set("item" .. items, "Bombs")
end
if saveData:get("springUnlocked") == 1 then
items = items + 1
shopData:set("item" .. items, "Spring")
end
if saveData:get("greenShoeUnlocked") == 1 then
items = items + 1
shopData:set("item" .. items, "Green Shoe")
end
if saveData:get("redShoeUnlocked") == 1 then
items = items + 1
shopData:set("item" .. items, "Red Shoe")
end
if saveData:get("blueShoeUnlocked") == 1 then
items = items + 1
shopData:set("item" .. items, "Blue Shoe")
end
if items < 11 then
items = items + 1
shopData:set("item" .. items, "???")
end
end
end
function onLoopShop()
--Check if Star has been purchased
if starCheck == false then
starCheck = true
if saveData:get("shopStar") ~= nil then
triggerEvent("star room open")
end
end
if shopHUD_loaded == false then
shopHUD_loaded = true
if show_shopHUD == true then
loadImage("../HUD/shop_hud.png", 0, 0xdc00ff)
placeSprite(1, 0, 124, 124)
elseif show_shopHUD == false then
loadImage("NONE", 0, 0xdc00ff)
end
end
if show_shopHUD == true then
local name = ""
local cost = 0
local id = 0
--Show Controls
printText("(jump) Select Item (sel) exit", 146, 370)
--Shop item list
if shopData:get("item" .. i - 5) ~= "" then
showScrollUp = 1
else
showScrollUp = 0
end
printText(shopData:get("item" .. i - 4), 156, 158)
printText(shopData:get("item" .. i - 3), 156, 178)
printText(shopData:get("item" .. i - 2), 156, 198)
printText(shopData:get("item" .. i - 1), 156, 218)
printText(shopData:get("item" .. i), 156, 238)
printText(shopData:get("item" .. i + 1), 156, 258)
printText(shopData:get("item" .. i + 2), 156, 278)
printText(shopData:get("item" .. i + 3), 156, 298)
printText(shopData:get("item" .. i + 4), 156, 318)
if shopData:get("item" .. i + 5) ~= "" then
showScrollDown = 1
else
showScrollDown = 0
end
if scrollChange ~= showScrollUp + showScrollDown then
scrollChange = showScrollUp + showScrollDown
if showScrollUp == 1 then
loadImage("../HUD/scroll_up.png", 16 + s, 0xdc00ff)
placeSprite(1, 16 + s, 280, 138)
else
loadImage("NONE", 16 + s, 0xdc00ff)
end
if showScrollDown == 1 then
loadImage("../HUD/scroll_down.png", 17 + s, 0xdc00ff)
placeSprite(1, 17 + s, 280, 338)
else
loadImage("NONE", 17 + s, 0xdc00ff)
end
end
--Item Cost and Description
if shopData:get("item" .. i) == "Mushroom" then
cost, id = 15, 9
desc1 = "Allows you to "
desc2 = "take one hit "
desc3 = "without being "
desc4 = "killed. "
desc5, desc6 = "", ""
elseif shopData:get("item" .. i) == "Super Leaf" then
cost, id = 30, "NONE"
desc1 = "allows you to "
desc2 = "glide and kill "
desc3 = "enemies with a "
desc4 = "tail. Includes "
desc5 = "a complimentary"
desc6 = "mushroom. "
elseif shopData:get("item" .. i) == "Fire Flower" then
cost, id = 25, 14
desc1 = "allows you to "
desc2 = "throw fireballs"
desc3 = "at your "
desc4 = "enemies. "
desc5, desc6 = "", ""
elseif shopData:get("item" .. i) == "Power Star" then
if saveData:get("star_Purchased") == nil then
cost = 1000
else
cost = "sold"
end
id = "NONE"
desc1 = "you know you"
desc2 = "want it. =P"
desc3 = "includes free"
desc4 = "Tanooki Suit."
desc5, desc6 = "", ""
elseif shopData:get("item" .. i) == "Ice Flower" then
cost, id = 45, 264
desc1 = "allows you to "
desc2 = "freeze enemies "
desc3 = "and throw them "
desc4 = "at each other. "
desc5, desc6 = "", ""
elseif shopData:get("item" .. i) == "Tanooki Suit" then
cost, id = 75, 169
desc1 = "same as a super"
desc2 = "leaf, but with "
desc3 = "an added "
desc4 = "ability. ;) "
desc5, desc6 = "", ""
elseif shopData:get("item" .. i) == "Hammer Suit" then
cost, id = 100, 170
desc1 = "allows you to "
desc2 = "throw hammers "
desc3 = "that can kill "
desc4 = "almost "
desc5 = "anything. "
desc6 = ""
elseif shopData:get("item" .. i) == "Bombs" then
cost, id = 25, "NONE"
desc1 = "Can be thrown "
desc2 = "by pressing "
desc3 = "alt-run. you "
desc4 = "can carry up to"
desc5 = "10 of them. "
desc6 = ""
elseif shopData:get("item" .. i) == "Spring" then
cost, id = 100, "NONE"
desc1 = "Carry item. "
desc2 = "allows you to "
desc3 = "bounce to "
desc4 = "higher areas. "
desc5 = "(one use) "
desc6 = ""
elseif shopData:get("item" .. i) == "Green Shoe" then
cost, id = 120, "NONE"
desc1 = "carry item. "
desc2 = "prevents damage"
desc3 = "from spikes, "
desc4 = "munchers, and "
desc5 = "most enemies. "
desc6 = ""
elseif shopData:get("item" .. i) == "Red Shoe" then
cost, id = 200, "NONE"
desc1 = "Carry item. "
desc2 = "same as a green"
desc3 = "shoe, but also "
desc4 = "allows you to "
desc5 = "walk on lava "
desc6 = "unharmed. "
elseif shopData:get("item" .. i) == "Blue Shoe" then
cost, id = 300, "NONE"
desc1 = "carry item. "
desc2 = "same as a green"
desc3 = "shoe, but with "
desc4 = "wings!!! "
desc5, desc6 = "", ""
elseif shopData:get("item" .. i) == "???" then
cost, id = "UNAVAILABLE", "NONE"
desc1 = "This item is "
desc2 = "locked. "
desc3, desc4, desc5, desc6 = "", "", "", ""
end
printText(cost .. "", 514, 144)
printText(desc1, 466, 208)
printText(desc2, 466, 228)
printText(desc3, 466, 248)
printText(desc4, 466, 268)
printText(desc5, 466, 288)
printText(desc6, 466, 308)
--Menu Navigation
if keyPressed == false then
if player.upKeyPressing == true then
if i > 1 then
i = i - 1
keyPressed = true
Audio.playSFX("../HUD/slide.ogg")
end
elseif player.downKeyPressing == true then
if i < items then
i = i + 1
keyPressed = true
Audio.playSFX("../HUD/slide.ogg")
end
elseif player.runKeyPressing == true then --Attempt to purchase selected item if jump is pressed. (Jump is replaced with run in onInputUpdate to prevent the player from jumping)
keyPressed = true
if cost == "sold" then
triggerEvent("already purchased")
elseif cost == "UNAVAILABLE" then
triggerEvent("item locked")
else
if coins < cost then
triggerEvent("not enough coins")
elseif coins >= cost then
if id == "NONE" then
if shopData:get("item" .. i) == "Power Star" then
coins = coins - cost
cost = "sold"
saveData:set("star_Purchased", 1)
triggerEvent("star room open")
Audio.playSFX("../HUD/cha-ching!.ogg")
elseif shopData:get("item" .. i) == "Super Leaf" then
if NPC1isSpawned == false then
NPC1isSpawned = true
triggerEvent ("leaf 1")
coins = coins - cost
Audio.playSFX("../HUD/cha-ching!.ogg")
elseif NPC2IsSpawned == false then
NPC2IsSpawned = true
triggerEvent ("leaf 2")
coins = coins - cost
Audio.playSFX("../HUD/cha-ching!.ogg")
elseif NPC2IsSpawned == true then
triggerEvent("out of space")
end
--***DON'T FORGET TO ADD CARRY ITEM FUNCTIONS HERE***
end
else
if NPC1isSpawned == false then
NPC1isSpawned = true
NPC.spawn(id, shop_xpos1, -200160, 0)
coins = coins - cost
Audio.playSFX("../HUD/cha-ching!.ogg")
elseif NPC2IsSpawned == false then
NPC2IsSpawned = true
NPC.spawn(id, shop_xpos2, -200160, 0)
coins = coins - cost
Audio.playSFX("../HUD/cha-ching!.ogg")
elseif NPC2IsSpawned == true then
triggerEvent("out of space")
end
end
end
end
keyPressed = true
elseif player.altRunKeyPressing == true then --Hide shop screen if select is pressed.
i = 1
triggerEvent("shop hide")
loadImage("NONE", 16 + s, 0xdc00ff)
loadImage("NONE", 17 + s, 0xdc00ff)
end
end
if player.upKeyPressing == false then
if player.downKeyPressing == false then
if player.runKeyPressing == false then
if player.altRunKeyPressing == false then
keyPressed = false
end
end
end
end
end
end
--npc counter
_G["countNPCID"] = function(id)
local npcs = findnpcs(id, -1)
local count = 0
for k,v in pairs(npcs) do
count = count + 1
end
return count
end
--Save
_G ["save"] = function()
saveData:set("coins", coins + levelCoins)
saveData:set("DCoins", DCoins)
saveData:set("DCoins_total", DCoins_total)
saveData:save()
end
function onEvent(eventName)
if split_route == false then
if eventName == "dc-trig-1" then
_G["saveData"]:set(level_code .. "-dc-1", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 472 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-2" then
_G["saveData"]:set(level_code .. "-dc-2", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 484 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-3" then
_G["saveData"]:set(level_code .. "-dc-3", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 496 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-4" then
_G["saveData"]:set(level_code .. "-dc-4", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 508 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-5" then
_G["saveData"]:set(level_code .. "-dc-5", 1)
DCoins = DCoins + 1
Graphics.placeSprite(1, 8 + s, 520 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
end
elseif split_route == true then
if eventName == "dc-trig-1" then
_G["saveData"]:set(level_code .. "-dc-1", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 534 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-2" then
_G["saveData"]:set(level_code .. "-dc-2", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 546 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-3" then
_G["saveData"]:set(level_code .. "-dc-3", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 558 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-4" then
_G["saveData"]:set(level_code .. "-dc-4", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 570 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-5" then
_G["saveData"]:set(level_code .. "-dc-5", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 582 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-L1" then
_G["saveData"]:set(level_code .. "-dc-L1", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 520 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-L2" then
_G["saveData"]:set(level_code .. "-dc-L2", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 508 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-L3" then
_G["saveData"]:set(level_code .. "-dc-L3", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 496 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-L4" then
_G["saveData"]:set(level_code .. "-dc-L4", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 484 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
elseif eventName == "dc-trig-L5" then
_G["saveData"]:set(level_code .. "-dc-L5", 1)
DCoins = DCoins + 1
DCoins_total = DCoins_total + 1
Graphics.placeSprite(1, 8 + s, 472 - split_screen_offset, 72)
triggerEvent("dc-trig-hide")
end
end
--Activate indicator for collected Star(s)
if eventName == "Level - Start" then
if saveData:get("star_Purchased") ~= nil then
triggerEvent("star room open (alt)")
end
elseif eventName == "(give player time to freak out...)" then
i = 1
show_shopHUD = false
shopHUD_loaded = false
elseif eventName == "star-trig" then
Graphics.placeSprite(1, 8 + s, 250 - split_screen_offset, 66)
saveData:set(level_code .. "-star", 1)
triggerEvent("dc-trig-hide")
elseif eventName == "star-trig-2" then
Graphics.placeSprite(1, 8 + s, 260 - split_screen_offset, 66)
saveData:set(level_code .. "-star2", 1)
triggerEvent("dc-trig-hide")
elseif eventName == "shop" then
show_shopHUD = true
shopHUD_loaded = false
scrollChange = nil
keyPressed = true
elseif eventName == "shop hide" then
show_shopHUD = false
shopHUD_loaded = false
end
end
function onLoad()
level_cleared = 0 -- Set to 1 if the level has been cleared
checkpoint = 0 -- Set to 1 if the checkpoint has been reached
HUD_loaded = nil --Controls HUD loading and reloading
runTest = ""
coin_switch = 0 --Set to 1 if collected Dragon Coins have been turned grey
--Get number of Dragon Coins
_G["DCoins"] = _G["saveData"]:get("DCoins")
if(DCoins == nil) then
DCoins = 0
end
--Get Total Dragon Coins collected (This value will never decrease. The other one can.)
_G["DCoins_total"] = saveData:get("DCoins_total")
if DCoins_total == nil then
DCoins_total = 0
end
--Hide default HUD
hud(false)
--Get number of coins
levelCoins = 0
end
function onLoop()
--Run shop loops if this level has a shop.
if shop ~= nil then
if shop_initialized == false then
shop_initialized = true
Shop_Initialize()
end
onLoopShop()
end
--Coin collection algorithm
if mem(0x00b2c5a8, FIELD_WORD) ~= 0 then --0x00b2c5a8 is the mem address for the player's coin total. This uses that address to add coins to my coin counter, then resets the address. This way, the coin counter has no limit.
if oneUp then
oneUp = oneUp + mem(0x00b2c5a8, FIELD_WORD)
end
levelCoins = levelCoins + mem(0x00b2c5a8, FIELD_WORD)
mem(0x00b2c5a8, FIELD_WORD, 0)
end
if show_hud == true then
--Coin counter
printText(levelCoins .. "", 514 - split_screen_offset, 14)
--Life counter
printText(mem(0x00b2c5ac, FIELD_FLOAT).. "", 292 - split_screen_offset, 14)
--Star counter
printText(mem(0x00b251e0, FIELD_DWORD).. "", 292 - split_screen_offset, 44)
--Dragon Coin counter
printText(DCoins .. "", 514 - split_screen_offset, 44)
end
--1up management
if oneUp == nil then -- "# Comparison to nil value" bugfix
oneUp = 0
end
if oneUp >= 100 then
mem(0x00b2c5ac, FIELD_FLOAT, mem(0x00b2c5ac, FIELD_FLOAT) + 1) --Give the player a 1up
playSFX(15) -- Play 1up SFX
oneUp = oneUp - 100 -- reset counter
end
--Save userdata if checkpoint is reached
local checkpoint_count = countNPCID(192)
if checkpoint_count == 0 and checkpoint == 0 then
save()
checkpoint = 1
end
--Save userdata if level is completed
if winState() ~= 0 and level_cleared == 0 then
save()
level_cleared = 1
end
--Offset control for P1's Reserve Box
if (player2 ~= nil) then
_G["reserve_offset_x"] = 22
_G["reserve_offset_y"] = 4
if twoPlayerCheck == false then
twoPlayerCheck = true
triggerEvent("2P Item Mode")
end
--Offset control for split-screen mode
if mem(mem(0x00b25124, FIELD_DWORD) + 72, FIELD_DFLOAT) == 400 then
_G["split_screen_offset"] = 170
else
_G["split_screen_offset"] = 0
end
else
_G["reserve_offset_x"] = 0
_G["reserve_offset_y"] = 0
split_screen_offset = 0
end
--HUD loader (loads the HUD in a different postion if the screen splits)
if (HUD_loaded ~= reserve_offset_x + split_screen_offset) then
HUD_loaded = reserve_offset_x + split_screen_offset
-- Empty current image slots
Graphics.loadImage("NONE", 1 + s, 0xdc00ff)
Graphics.loadImage("NONE", 2 + s, 0xdc00ff)
Graphics.loadImage("NONE", 3 + s, 0xdc00ff)
Graphics.loadImage("NONE", 4 + s, 0xdc00ff)
Graphics.loadImage("NONE", 5 + s, 0xdc00ff)
Graphics.loadImage("NONE", 6 + s, 0xdc00ff)
Graphics.loadImage("NONE", 7 + s, 0xdc00ff)
Graphics.loadImage("NONE", 8 + s, 0xdc00ff)
Graphics.loadImage("NONE", 9 + s, 0xdc00ff)
Graphics.loadImage("NONE", 10 + s, 0xdc00ff)
Graphics.loadImage("NONE", 11 + s, 0xdc00ff)
Graphics.loadImage("NONE", 12 + s, 0xdc00ff)
Graphics.loadImage("NONE", 13 + s, 0xdc00ff)
Graphics.loadImage("NONE", 14 + s, 0xdc00ff)
Graphics.loadImage("NONE", 15 + s, 0xdc00ff)
-- Change current image slots
if split_screen_offset == 0 then
s = 0
else
s = 15
end
if show_hud == false then
Graphics.loadImage("NONE", 1 + s, 0xdc00ff)
Graphics.loadImage("NONE", 2 + s, 0xdc00ff)
Graphics.loadImage("NONE", 3 + s, 0xdc00ff)
Graphics.loadImage("NONE", 4 + s, 0xdc00ff)
Graphics.loadImage("NONE", 5 + s, 0xdc00ff)
Graphics.loadImage("NONE", 6 + s, 0xdc00ff)
Graphics.loadImage("NONE", 7 + s, 0xdc00ff)
Graphics.loadImage("NONE", 8 + s, 0xdc00ff)
Graphics.loadImage("NONE", 9 + s, 0xdc00ff)
Graphics.loadImage("NONE", 10 + s, 0xdc00ff)
Graphics.loadImage("NONE", 11 + s, 0xdc00ff)
Graphics.loadImage("NONE", 12 + s, 0xdc00ff)
Graphics.loadImage("NONE", 13 + s, 0xdc00ff)
Graphics.loadImage("NONE", 14 + s, 0xdc00ff)
Graphics.loadImage("NONE", 15 + s, 0xdc00ff)
elseif show_hud == true then
--Reset Reserve Box
reserve, reserve2 = nil, nil
--Load custom HUD
Graphics.loadImage("../HUD/hud.png", 1 + s, 0xdc00ff);
Graphics.placeSprite(1, 1 + s, 174 - split_screen_offset, 10)
--Load reserve box
if (player2 ~= nil) then
Graphics.loadImage ("../HUD/2P_reserve.png", 2 + s, 0xdc00ff)
Graphics.placeSprite (1, 2 + s, 352 - split_screen_offset, 10)
else
Graphics.loadImage ("../HUD/1P_reserve.png", 2 + s, 0xdc00ff)
Graphics.placeSprite (1, 2 + s, 364, 10)
end
--Load Star Slot if Stars are present
local star_count = countNPCID(97) + countNPCID(196)
if star_count >= 1 then
Graphics.loadImage("../HUD/starslot.png", 5 + s, 0xdc00ff);
Graphics.placeSprite(1, 5 + s, 248 - split_screen_offset, 64)
if star_count == 2 then
Graphics.placeSprite(1, 5 + s, 258 - split_screen_offset, 64)
end
end
--Show Collected Stars
if saveData:get(level_code .. "-star") ~= nil then
Graphics.placeSprite(1, 8 + s, 250 - split_screen_offset, 66)
end
if saveData:get(level_code .. "-star2") ~= nil then
Graphics.placeSprite(1, 8 + s, 260 - split_screen_offset, 66)
end
--If Dragon coins, then load dragon coin slot
if dragon_coins == true then
Graphics.loadImage("../HUD/dcslot.png", 6 + s, 0xdc00ff)
Graphics.placeSprite(1, 6 + s, 470 - split_screen_offset, 70)
end
--If Split Route, load second dragon coin slot
if split_route == true then
Graphics.loadImage("../HUD/dcslot2.png", 7 + s, 0xdc00ff)
Graphics.placeSprite(1, 7 + s, 528 - split_screen_offset, 68)
end
--Load indicator image
Graphics.loadImage("../HUD/ind.png", 8 + s, 0xdc00ff)
--Show obtained dragon coins; replace collected with grey dragon coin
if split_route == false then
if(saveData:get(level_code .. "-dc-1") == 1) then
Graphics.placeSprite(1, 8 + s, 472 - split_screen_offset, 72)
triggerEvent("dcc-1")
end
if(saveData:get(level_code .. "-dc-2") == 1) then
Graphics.placeSprite(1, 8 + s, 484 - split_screen_offset, 72)
triggerEvent("dcc-2")
end
if(saveData:get(level_code .. "-dc-3") == 1) then
Graphics.placeSprite(1, 8 + s, 496 - split_screen_offset, 72)
triggerEvent("dcc-3")
end
if(saveData:get(level_code .. "-dc-4") == 1) then
Graphics.placeSprite(1, 8 + s, 508 - split_screen_offset, 72)
triggerEvent("dcc-4")
end
if(saveData:get(level_code .. "-dc-5") == 1) then
Graphics.placeSprite(1, 8 + s, 520 - split_screen_offset, 72)
triggerEvent("dcc-5")
end
coin_switch = 1
else
if (saveData:get(level_code .. "-dc-1") == 1) then
Graphics.placeSprite(1, 8 + s, 534 - split_screen_offset, 72)
triggerEvent("dcc-1")
end
if (saveData:get(level_code .. "-dc-2") == 1) then
Graphics.placeSprite(1, 8 + s, 546 - split_screen_offset, 72)
triggerEvent("dcc-2")
end
if (saveData:get(level_code .. "-dc-3") == 1) then
Graphics.placeSprite(1, 8 + s, 558 - split_screen_offset, 72)
triggerEvent("dcc-3")
end
if (saveData:get(level_code .. "-dc-4") == 1) then
Graphics.placeSprite(1, 8 + s, 570 - split_screen_offset, 72)
triggerEvent("dcc-4")
end
if (saveData:get(level_code .. "-dc-5") == 1) then
Graphics.placeSprite(1, 8 + s, 582 - split_screen_offset, 72)
triggerEvent("dcc-5")
end
if (saveData:get(level_code .. "-dc-L1") == 1) then
Graphics.placeSprite(1, 8 + s, 520 - split_screen_offset, 72)
triggerEvent("dcc-L1")
end
if (saveData:get(level_code .. "-dc-L2") == 1) then
Graphics.placeSprite(1, 8 + s, 508 - split_screen_offset, 72)
triggerEvent("dcc-L2")
end
if (saveData:get(level_code .. "-dc-L3") == 1) then
Graphics.placeSprite(1, 8 + s, 496 - split_screen_offset, 72)
triggerEvent("dcc-L3")
end
if (saveData:get(level_code .. "-dc-L4") == 1) then
Graphics.placeSprite(1, 8 + s, 484 - split_screen_offset, 72)
triggerEvent("dcc-L4")
end
if (saveData:get(level_code .. "-dc-L5") == 1) then
Graphics.placeSprite(1, 8 + s, 472 - split_screen_offset, 72)
triggerEvent("dcc-L5")
end
end
end
--Show orbs that have been obtained
local orb = _G["saveData"]:get("orb_lb")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_lb.png", 9, 0xdc00ff)
Graphics.placeSprite (1, 9 + s, 186 - split_screen_offset, 10)
end
orb = _G["saveData"]:get("orb_p")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_p.png", 10, 0xdc00ff)
Graphics.placeSprite (1, 10 + s, 210 - split_screen_offset, 10)
end
orb = _G["saveData"]:get("orb_g")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_g.png", 11, 0xdc00ff)
Graphics.placeSprite (1, 11 + s, 174 - split_screen_offset, 32)
end
orb = _G["saveData"]:get("orb_w")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_w.png", 12, 0xdc00ff)
Graphics.placeSprite (1, 12 + s, 198 - split_screen_offset, 32)
end
orb = _G["saveData"]:get("orb_r")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_r.png", 13, 0xdc00ff)
Graphics.placeSprite (1, 13 + s, 222 - split_screen_offset, 32)
end
orb = _G["saveData"]:get("orb_y")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_y.png", 14, 0xdc00ff)
Graphics.placeSprite (1, 14 + s, 186 - split_screen_offset, 54)
end
orb = _G["saveData"]:get("orb_w")
if(orb == 1) then
Graphics.loadImage ("../HUD/orb_db.png", 15, 0xdc00ff)
Graphics.placeSprite (1, 15 + s, 210 - split_screen_offset, 54)
end
end
--Reserve Box (player 1)
if reserve ~= player:mem(0x158, FIELD_WORD) then
reserve = player:mem(0x158, FIELD_WORD)
if reserve == 0 then
Graphics.loadImage("NONE", 3 + s, 0xdc00ff)
elseif reserve == 184 then
Graphics.loadImage("../HUD/smb_shroom.png", 3 + s, 0xdc00ff)
elseif reserve == 182 then
Graphics.loadImage("../HUD/smb_flower.png", 3 + s, 0xdc00ff)
elseif reserve == 9 then
Graphics.loadImage("../HUD/smb3_shroom.png", 3 + s, 0xdc00ff)
elseif reserve == 14 then
Graphics.loadImage("../HUD/smb3_flower.png", 3 + s, 0xdc00ff)
elseif reserve == 34 then
Graphics.loadImage("../HUD/leaf.png", 3 + s, 0xdc00ff)
elseif reserve == 264 then
Graphics.loadImage("../HUD/smb3_iceflower.png", 3 + s, 0xdc00ff)
elseif reserve == 169 then
Graphics.loadImage("../HUD/tanooki_suit.png", 3 + s, 0xdc00ff)
elseif reserve == 170 then
Graphics.loadImage("../HUD/hammer_suit.png", 3 + s, 0xdc00ff)
elseif reserve == 248 then
Graphics.loadImage("../HUD/stopwatch.png", 3 + s, 0xdc00ff)
elseif reserve == 185 then
Graphics.loadImage("../HUD/smw_shroom.png", 3 + s, 0xdc00ff)
elseif reserve == 183 then
Graphics.loadImage("../HUD/smw_flower.png", 3 + s, 0xdc00ff)
elseif reserve == 277 then
Graphics.loadImage("../HUD/smw_iceflower.png", 3 + s, 0xdc00ff)
end
Graphics.placeSprite(1, 3 + s, 384 - reserve_offset_x - split_screen_offset, 30 - reserve_offset_y)
end
--Reserve Box (player 2)
if (player2 ~= nil) then
if reserve2 ~= player2:mem(0x158, FIELD_WORD) then
reserve2 = player2:mem(0x158, FIELD_WORD)
if reserve2 == 0 then
Graphics.loadImage("NONE", 4 + s, 0xdc00ff)
elseif reserve2 == 184 then
Graphics.loadImage("../HUD/smb_shroom.png", 4 + s, 0xdc00ff)
elseif reserve2 == 182 then
Graphics.loadImage("../HUD/smb_flower.png", 4 + s, 0xdc00ff)
elseif reserve2 == 9 then
Graphics.loadImage("../HUD/smb3_shroom.png", 4 + s, 0xdc00ff)
elseif reserve2 == 14 then
Graphics.loadImage("../HUD/smb3_flower.png", 4 + s, 0xdc00ff)
elseif reserve2 == 34 then
Graphics.loadImage("../HUD/leaf.png", 4 + s, 0xdc00ff)
elseif reserve2 == 264 then
Graphics.loadImage("../HUD/smb3_iceflower.png", 4 + s, 0xdc00ff)
elseif reserve2 == 169 then
Graphics.loadImage("../HUD/tanooki_suit.png", 4 + s, 0xdc00ff)
elseif reserve2 == 170 then
Graphics.loadImage("../HUD/hammer_suit.png", 4 + s, 0xdc00ff)
elseif reserve2 == 248 then
Graphics.loadImage("../HUD/stopwatch.png", 4 + s, 0xdc00ff)
elseif reserve2 == 185 then
Graphics.loadImage("../HUD/smw_shroom.png", 4 + s, 0xdc00ff)
elseif reserve2 == 183 then
Graphics.loadImage("../HUD/smw_flower.png", 4 + s, 0xdc00ff)
elseif reserve2 == 277 then
Graphics.loadImage("../HUD/smw_iceflower.png", 4 + s, 0xdc00ff)
end
Graphics.placeSprite(1, 4 + s, 406 - split_screen_offset, 26)
end
end
end
function onInputUpdate()
--Disable movement while shop screen is displayed
if show_shopHUD == true then
player.leftKeyPressing = false
player.rightKeyPressing = false
player.altJumpkeyPressing = false
player.runKeyPressing = false
player.altRunKeyPressing = false
if player.jumpKeyPressing == true then
player.jumpKeyPressing = false
player.runKeyPressing = true
end
if player.dropItemKeyPressing == true then
player.dropItemKeyPressing = false
player.altRunKeyPressing = true
end
--Disable P2 controls completely
if player2 ~= nil then
player2.upKeyPressing = false
player2.downKeyPressing = false
player2.leftKeyPressing = false
player2.rightKeyPressing = false
player2.jumpKeyPressing = false
player2.altJumpkeyPressing = false
player2.runKeyPressing = false
player2.altRunKeyPressing = false
player2.dropItemKeyPressing = false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment