Page 1 of 1

Inspirited's code requests

Posted: Thu Aug 17, 2017 11:29 am
by Inspirited
Hey, I'd like to use this thread to request simple lunalua codes. I could learn to code myself and browse documentations, but aaaah. I admit, I'm lazy.

I use Mario and 1-player only.

Special Star Exit
edit: nevermind

Disable HUD, coins and lives

This goes into my lunaworld.lua file too.

I'd like to
- completely hide the HUD in levels
- disable Mario from having an inventory item in the inventory box (or from using it)
- coins constantly set to 0
- lives constantly set to 3
- don't show lives when restarting a level
- don't show lives and coins in the worldmap (if possible?)

That's all :O


EDIT: Nevermind, I managed to do it myself :D

In case you're interested, here's the code.

Code: Select all

local WhiteImage = Graphics.loadImage(Misc.resolveFile("whitescreen.png"))
local WhiteOut = 0
local MarioFreezeX
local MarioFreezeY

function onStart()
	Graphics.activateHud(false)
end

function onTick()	
	if Level.winState() ~= 0 and WhiteOut == 0 then
		WhiteOut = 0.004
		MarioFreezeX = player.x
		MarioFreezeY = player.y
	end
	if WhiteOut > 0 then
		Graphics.drawImage(WhiteImage, 0, 0, WhiteOut)
		WhiteOut = WhiteOut + 0.004
		if WhiteOut > 1 then
			WhiteOut = 1
		end
	end
end

function onTickEnd()
	mem(0x00B2C5A8, FIELD_WORD, 0) --coins
	mem(0x00B2C5AC, FIELD_FLOAT, 3) --lives
	player.reservePowerup = 0
	
	if WhiteOut > 0 then
		player.x = MarioFreezeX
		player.y = MarioFreezeY
	end
end