Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --**********
- --|INCLUDES|
- --**********
- world_raocoin_lib = loadSharedAPI("raocoin2");
- world_raocoin_currency = world_raocoin_lib.registerCurrency(274, true, 480, 66);
- local eventu = loadAPI("eventu");
- local encrypt = loadSharedAPI("encrypt");
- local multipoints = loadSharedAPI("multipoints");
- local pnpc = loadSharedAPI("pnpc");
- --******
- --|VARS|
- --******
- local levelFinished = false;
- ShowInputs = false
- musichudfile = Misc.resolveFile("musichud.png");
- local demosgraphic= Graphics.loadImage(Misc.resolveFile("demos.png"));
- local musichud = Graphics.loadImage(Misc.resolveFile("musichud.png"));
- local localraocoin = Graphics.loadImage(Misc.resolveFile("raocoin.png"));
- local raocoin_taken = Graphics.loadImage(Misc.resolveFile("raocoin_taken.png"));
- showmusic = false
- musicwait = false
- local hasDied = false;
- local local_raocoin_counter = 0;
- --***************
- --|SAVE SETTINGS|
- --***************
- Settings = encrypt.Data(Data.DATA_WORLD, "ConfigData", true)
- TextSettings = Data(Data.DATA_WORLD, "TextConfigData", true)
- if Settings:get("DemoCounter") == nil then
- Settings:set("ShowInputsConfig", 0)
- Settings:set("MusicComboConfig", 0)
- Settings:set("DemoCounter", 1)
- Settings:set("Raocoin1", 0)
- Settings:set("Raocoin2", 0)
- Settings:set("Raocoin3", 0)
- Settings:set("Raocoin4", 0)
- Settings:set("Raocoin5", 0)
- Settings:save()
- end
- if TextSettings:get("CurrentLevel") == "" then
- TextSettings:set("CurrentLevel","none");
- TextSettings:save();
- end
- local raocoinnpcs = {};
- local raocoin_empty = {};
- local ranInitialCheck = false;
- local midpointLoaded = false;
- InputConfig = Settings:get("ShowInputsConfig");
- MusicCombo = Settings:get("MusicComboConfig");
- UseDemos = Settings:get("DemoCounter");
- function world_raocoin_currency:onCollect(increment, npc)
- local_raocoin_counter = local_raocoin_counter + increment;
- table.insert(raocoin_empty, {x=npc.x, y=npc.y});
- local n = pnpc.wrap(npc);
- n.data.collected = true;
- end
- --*************************
- --|SAVE COLLECTED RAOCOINS|
- --*************************
- function multipoints:onCollected(id)
- world_raocoin_currency:save();
- TextSettings:set("CurrentLevel", tostring(mem(0x00B250B0, FIELD_STRING)));
- for k,v in ipairs(raocoinnpcs) do
- if(not v.isValid and v.data.collected == true) then
- Settings:set("Raocoin"..k, 1);
- end
- end
- Settings:save()
- TextSettings:save();
- end
- function onNPCKill(event, npc, reason)
- if(midpointLoaded and npc.id == 192) then
- multipoints.onCollected(npc,0);
- end
- end
- function multipoints.onLevelStart()
- midpointLoaded = true;
- end
- function onEvent(eventname)
- if eventname == "ShowInputsConfig" then
- if InputConfig == 0 then
- Settings:set("ShowInputsConfig", 1)
- else
- Settings:set("ShowInputsConfig", 0)
- end
- Settings:save()
- InputConfig = Settings:get("ShowInputsConfig");
- end
- if eventname == "MusicComboConfig" then
- if MusicCombo == 0 then
- Settings:set("MusicComboConfig", 1)
- else
- Settings:set("MusicComboConfig", 0)
- Misc.cheatBuffer("")
- end
- Settings:save()
- MusicCombo = Settings:get("MusicComboConfig");
- end
- if eventname == "DemoCounter" then
- if UseDemos == 0 then
- Settings:set("DemoCounter", 1)
- else
- Settings:set("DemoCounter", 0)
- end
- Settings:save()
- UseDemos = Settings:get("DemoCounter");
- end
- end
- function onLoop()
- --**************
- --|RAOCOIN CODE|
- --**************
- if(mem(0x00B2C59E,FIELD_WORD) ~= 0 and not levelFinished) then --level is ending
- levelFinished = true;
- world_raocoin_currency:save();
- end
- musicCode() --Music Code
- --*******************
- --|FILE-SAVING STUFF|
- --*******************
- if ranInitialCheck == false then
- if ShowInputsConfig == tostring(1) then
- -- ShowInputs = true
- end
- if MusicComboConfig == tostring(1) then
- --MusicCombo = true
- end
- --**************************************
- --|DELETE PREVIOUSLY COLLECTED RAOCOINS|
- --**************************************
- if(tostring(mem(0x00B250B0, FIELD_STRING)) ~= TextSettings:get("CurrentLevel")) then
- Settings:set("Raocoin1", 0)
- Settings:set("Raocoin2", 0)
- Settings:set("Raocoin3", 0)
- Settings:set("Raocoin4", 0)
- Settings:set("Raocoin5", 0)
- Settings:save();
- TextSettings:set("CurrentLevel", "none")
- TextSettings:save();
- end
- for k,v in ipairs(NPC.get(274,-1)) do
- raocoinnpcs[k] = pnpc.wrap(v);
- if(Settings:get("Raocoin"..k) == 1) then
- v:mem(0x3C,FIELD_STRING,""); --Remove from layer (allows hidden raocoins to not be displayed) - work around for kill() not working on hidden NPCs
- local_raocoin_counter = local_raocoin_counter + 1;
- table.insert(raocoin_empty, {x=v.x, y=v.y});
- v:kill();
- end
- end
- if #raocoinnpcs < 5 then --Search container NPCs such as grass, bubbles and yoshis.
- for k,v in ipairs(NPC.get({283,91,263,96},-1)) do
- if v:mem(0xF0,FIELD_DFLOAT) == 274 then
- table.insert(raocoinnpcs, pnpc.wrap(v));
- if(Settings:get("Raocoin"..#raocoinnpcs) == 1) then
- local_raocoin_counter = local_raocoin_counter + 1;
- local yoffset = 0;
- if(v.id == 91) then
- yoffset = -64;
- elseif(v.id == 96) then
- yoffset = -32;
- end
- table.insert(raocoin_empty, {x=v.x, y=v.y+yoffset});
- v:mem(0xF0,FIELD_DFLOAT,0)
- end
- end
- end
- end
- ranInitialCheck = true;
- end
- for k,v in ipairs(raocoin_empty) do
- Graphics.drawImageToScene(raocoin_taken,v.x,v.y)
- end
- end
- function onInputUpdate()
- --*****************************
- --|START + SELECT BUTTON COMBO|
- --*****************************
- if (player.dropItemKeyPressing and player.pauseKeyPressing) then
- Level.exit()
- --mem(0x00B250E2,FIELD_FLOAT,0)
- player.dropItemKeyPressing = false
- player.pauseKeyPressing = false
- end
- --****************************
- --|SNES9X-STYLE INPUT DISPLAY|
- --| CUSTOM SETTING |
- --****************************
- if (InputConfig == 1) then
- if (player.upKeyPressing) then
- Text.print("U",460,584)
- end
- if (player.downKeyPressing) then
- Text.print("D",480,584)
- end
- if (player.leftKeyPressing) then
- Text.print("L",500,584)
- end
- if (player.rightKeyPressing) then
- Text.print("R",520,584)
- end
- if (player.pauseKeyPressing) then
- Text.print("RUN",600,584)
- end
- if (player.dropItemKeyPressing) then
- Text.print("SEL",540,584)
- end
- if (player.runKeyPressing == true and player.altRunKeyPressing == false) then
- Text.print("IV",760,584)
- end
- if (player.jumpKeyPressing) then
- Text.print("II",680,584)
- end
- if (player.altRunKeyPressing) then
- Text.print("III",700,584)
- end
- if (player.altJumpKeyPressing) then
- Text.print("I",640,584)
- end
- end
- if (MusicCombo == 1) then
- if (player.upKeyPressing and player.pauseKeyPressing) then
- showmusic = true
- player.pauseKeyPressing = false
- end
- end
- end
- function onLoad()
- --*************************************
- --|REMOVE ANY BLUE SACKS ON LEVEL LOAD|
- --*************************************
- if (player.isValid) then
- if (player:mem(0x108,FIELD_WORD) == 1 and player:mem(0x10A,FIELD_WORD) == 3) then
- player:mem(0x108,FIELD_WORD, 0)
- end
- end
- --*************************
- --|DEMO COUNTER INIT STUFF|
- --*************************
- if (Settings:get(Level.filename() .. "-deaths") == nil) then
- Settings:set(Level.filename() .. "-deaths", 0)
- end
- if (Settings:get("totalDeaths") == nil) then
- Settings:set("totalDeaths", 0)
- end
- Settings:save()
- end
- --******************
- --|MUSIC CHEAT CODE|
- --******************
- function musicCode()
- if (MusicCombo == 0) then
- musiccheatcode = Misc.cheatBuffer()
- musiccheat = string.find(musiccheatcode, "music", 1)
- if (musiccheat ~= 0 and musiccheat ~= nil) then
- showmusic = true
- Misc.cheatBuffer("")
- end
- end
- if (showmusic == true) then
- Graphics.drawImage(musichud,0,515,50);
- if (Audio.MusicTitleTag() ~= "") then
- Text.print(Audio.MusicTitleTag(),50,550)
- Text.print(Audio.MusicArtistTag(),50,525)
- Text.print(Audio.MusicAlbumTag(),50,575)
- else
- Text.print(ManualTitle,50,550)
- Text.print(ManualArtist,50,525)
- Text.print(ManualAlbum,50,575)
- end
- if (musicwait == false) then
- musicwait = true
- eventu.setTimer(5, hidecredits, false);
- end
- end
- end
- function hidecredits()
- musicwait = false
- showmusic = false
- end
- --**************
- --|DEMO COUNTER|
- --**************
- function onHUDDraw()
- if player:mem(0x13C, FIELD_DWORD) ~= 0 and not hasDied then
- Settings:set(Level.filename() .. "-deaths", Settings:get(Level.filename() .. "-deaths") + 1)
- Settings:set("totalDeaths", Settings:get("totalDeaths") + 1)
- Settings:save()
- hasDied = true
- end
- if (UseDemos == 1 and Graphics.isHudActivated()) then
- Graphics.drawImage(demosgraphic,56,26);
- Text.print(tostring(Settings:get("totalDeaths")), 1, 128, 27)
- for i=1,math.min(5,local_raocoin_counter),1 do
- Graphics.drawImage(localraocoin,234+12*i,66);
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement