Looking for a Script

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Alfur
Shy Guy
Shy Guy
Posts: 6
Joined: Thu Dec 16, 2021 2:21 pm
Pronouns: she/her

Looking for a Script

Postby Alfur » Thu Apr 21, 2022 1:22 pm

Apologies if this is not the right forum for this post, but I’ve been searching around for a script that removes lives.
I’m looking for one of 2 things.
1. A Life system like Odyssey’; coins are used as your lives and you get coins deducted for dying.
Or,
2. Removing lives entirely.

Help is most appreciated. Again, sorry if this is not the right forum for this post.

deice
Volcano Lotus
Volcano Lotus
Posts: 596
Joined: Fri Jul 23, 2021 7:35 am

Re: Looking for a Script

Postby deice » Thu Apr 21, 2022 1:52 pm

if you want to remove lives as a factor entirely, create a file called "luna.lua" inside your episode directory and copy the following code inside:

Code: Select all

function onStart()
	mem(0x00B2C5AC, FIELD_FLOAT, 99)
end
as for the other script you've mentioned, that's a bit more complex as smbx doesn't keep track of a total collected coin count throughout the episode. you'd have to make your own place to keep track of it. i've put together a quick and rough way to implement this (as i don't know of an existing one either), but i'd advise against using it if you don't know how you'd expand on it (once again place it inside the episode's "luna.lua" file):

Code: Select all

local coinLossOnDeath = 20 -- change this number to set how many coins are lost on death
local prevCoins = mem(0x00B2C5A8, FIELD_WORD)

function onStart()
	SaveData._totalCoins = SaveData._totalCoins or 0
end

function onTick()
	local currCoins = mem(0x00B2C5A8, FIELD_WORD)
	mem(0x00B2C5AC, FIELD_FLOAT, 98)
	if(currCoins > prevCoins) then
		SaveData._totalCoins = SaveData._totalCoins + (currCoins - prevCoins)
	elseif(currCoins < prevCoins) then
		SaveData._totalCoins = SaveData._totalCoins + (currCoins + 100 - prevCoins)
	end
	
	prevCoins = currCoins
end

function onPostPlayerKill(harmedPlayer)
	SaveData._totalCoins = math.max(0, SaveData._totalCoins - coinLossOnDeath)
end

Alfur
Shy Guy
Shy Guy
Posts: 6
Joined: Thu Dec 16, 2021 2:21 pm
Pronouns: she/her

Re: Looking for a Script

Postby Alfur » Thu Apr 21, 2022 2:57 pm

deice wrote:
Thu Apr 21, 2022 1:52 pm
if you want to remove lives as a factor entirely, create a file called "luna.lua" inside your episode directory and copy the following code inside:

Code: Select all

function onStart()
	mem(0x00B2C5AC, FIELD_FLOAT, 99)
end
as for the other script you've mentioned, that's a bit more complex as smbx doesn't keep track of a total collected coin count throughout the episode. you'd have to make your own place to keep track of it. i've put together a quick and rough way to implement this (as i don't know of an existing one either), but i'd advise against using it if you don't know how you'd expand on it (once again place it inside the episode's "luna.lua" file):

Code: Select all

local coinLossOnDeath = 20 -- change this number to set how many coins are lost on death
local prevCoins = mem(0x00B2C5A8, FIELD_WORD)

function onStart()
	SaveData._totalCoins = SaveData._totalCoins or 0
end

function onTick()
	local currCoins = mem(0x00B2C5A8, FIELD_WORD)
	mem(0x00B2C5AC, FIELD_FLOAT, 98)
	if(currCoins > prevCoins) then
		SaveData._totalCoins = SaveData._totalCoins + (currCoins - prevCoins)
	elseif(currCoins < prevCoins) then
		SaveData._totalCoins = SaveData._totalCoins + (currCoins + 100 - prevCoins)
	end
	
	prevCoins = currCoins
end

function onPostPlayerKill(harmedPlayer)
	SaveData._totalCoins = math.max(0, SaveData._totalCoins - coinLossOnDeath)
end
Ah, I was expecting for the odyssey-esque style of lives to be more of a challenge. I’ll try and mess around a bit and see which one I like more. Thanks for the help!


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari