Page 1 of 1

Looking for a Script

Posted: Thu Apr 21, 2022 1:22 pm
by Alfur
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.

Re: Looking for a Script

Posted: Thu Apr 21, 2022 1:52 pm
by deice
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

Re: Looking for a Script

Posted: Thu Apr 21, 2022 2:57 pm
by Alfur
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!