(shouting)

LunaDLL/LunaLUA help thread

The second SMBX collab!
User avatar
CloudyCloud
Posts: 234
Joined: 11 years ago

Maybe it is an old question that is asked before

Post by CloudyCloud »

So, let's say I have set up a midpoint, but I want a separate room to be where you respawned if you died after midpoint, instead of the same location where the midpoint is.

How can I do it?


(One extra question: How to keep "spin-jump" even after portal teleportation? So seemingly it is possible in SMW as one of the entries in MAGL2 has shown such. https://www.youtube.com/watch?v=C8mKo0pnuVw )
(As in, you teleport due to the warp at the bottom, and thus you are warped up just like portal, but even though you spin-jump down, you lose the spinning as soon as you teleport to the above.)

(I guess it is possible in SMBX also, but how...?)
koplje
Posts: 10
Joined: 9 years ago

Re: Maybe it is an old question that is asked before

Post by koplje »

The first is easy. Simply put a midpoint in your level and put another one in the room you want to end up in. It acts just like those midpoint rooms in SMW hacks usually do.

For your second request you have to use LunaLua. Luckily somebody already made a script for something like this. I've tested it and it works just like it does in the video so you should be good.

Code: Select all

function onLoop()
local sectBottom = player.sectionObj.boundary.bottom
local sectTop = player.sectionObj.boundary.top
-- If the top of the player is below the bottom of the section...
if (player.y > sectBottom ) then
-- Move the (top of the) player 48px above the top of the screen
player.y = sectTop - 48
end
end
- Courtesy of viewtopic.php?f=36&t=14271&start=1150#p298814

Put this script as "lunadll.lua" in your custom level folder.
Image
User avatar
CloudyCloud
Posts: 234
Joined: 11 years ago

Re: Maybe it is an old question that is asked before

Post by CloudyCloud »

koplje wrote:The first is easy. Simply put a midpoint in your level and put another one in the room you want to end up in. It acts just like those midpoint rooms in SMW hacks usually do.

For your second request you have to use LunaLua. Luckily somebody already made a script for something like this. I've tested it and it works just like it does in the video so you should be good.

Code: Select all

function onLoop()
local sectBottom = player.sectionObj.boundary.bottom
local sectTop = player.sectionObj.boundary.top
-- If the top of the player is below the bottom of the section...
if (player.y > sectBottom ) then
-- Move the (top of the) player 48px above the top of the screen
player.y = sectTop - 48
end
end
- Courtesy of viewtopic.php?f=36&t=14271&start=1150#p298814

Put this script as "lunadll.lua" in your custom level folder.
Regarding spin-jump thing...

Wait, so I need to use lunalua?

I am kinda hoping to ignore the need of lunalua.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Maybe it is an old question that is asked before

Post by Rednaxela »

CloudyCloud wrote:Regarding spin-jump thing...

Wait, so I need to use lunalua?

I am kinda hoping to ignore the need of lunalua.
I mean, without LunaLua you can place some warps for wraping from the bottom of screen to top, but 1) there's no possible way to preserve spin-jump state through the normal instant warps, 2) you also lose momentum and get shifted horizontally to match the position of the warp you hit more exactly, which is awkward for this purpose.
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL help thread

Post by 7NameSam »

I want to make it so you can't move if you are standing on the ground, How do I do that?
User avatar
CloudyCloud
Posts: 234
Joined: 11 years ago

Re: Maybe it is an old question that is asked before

Post by CloudyCloud »

koplje wrote:The first is easy. Simply put a midpoint in your level and put another one in the room you want to end up in. It acts just like those midpoint rooms in SMW hacks usually do.
Wait a minute, so I tested with my own level to test what you said: put one midpoint on section 3 to touch, and another midpoint on section 4 since I want to end up there.

But, it doesn't work.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Maybe it is an old question that is asked before

Post by Hoeloe »

CloudyCloud wrote:
koplje wrote:The first is easy. Simply put a midpoint in your level and put another one in the room you want to end up in. It acts just like those midpoint rooms in SMW hacks usually do.
Wait a minute, so I tested with my own level to test what you said: put one midpoint on section 3 to touch, and another midpoint on section 4 since I want to end up there.

But, it doesn't work.
Midpoints are dodgy. You spawn on the first one in the level, regardless of which you touched. If you want to do this more reliably, you should use the Multipoints Lua library.
Image
Image
Image
Image
Image
User avatar
snoruntpyro
cutest girl 2023
Posts: 884
Joined: 9 years ago
Pronouns: she/her
Contact:

Re: LunaDLL help thread

Post by snoruntpyro »

PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
Image
Image
Image
Image
Image
S1eth
Posts: 291
Joined: 9 years ago

Re: LunaDLL help thread

Post by S1eth »

Pyro wrote:PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
I don't know if there's a constant for it, but Short has 16 bit and WORD also has 16 bit, so FIELD_WORD should work. (or just 1, assuming that parameter is word size; edit: I believe it's number of bytes, so 2).
Last edited by S1eth 8 years ago, edited 1 time in total.
Image
User avatar
snoruntpyro
cutest girl 2023
Posts: 884
Joined: 9 years ago
Pronouns: she/her
Contact:

Re: LunaDLL help thread

Post by snoruntpyro »

That seems to have worked! Thanks!
Image
Image
Image
Image
Image
S1eth
Posts: 291
Joined: 9 years ago

Re: LunaDLL help thread

Post by S1eth »

When I used the old 6.1.1 Lua+SMBX, when some lua code crashed, the game just continued normally after the error message.

Since I've downloaded 7.0.1 (vanilla+launcher, full installation), every time lua code crashes, the whole game crashes with it (SMBX has stopped working).

Any idea why that is?
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL help thread

Post by Rednaxela »

S1eth wrote:Since I've downloaded 7.0.1 (vanilla+launcher, full installation), every time lua code crashes, the whole game crashes with it (SMBX has stopped working).

Any idea why that is?
A consequence of moving to LuaJIT, interacting with some of the error handling of Luabind.

I've have a fix in mind for a but need to test it.
Luigifan2010
Lua squad
Posts: 2
Joined: 9 years ago
First name: Mike
Pronouns: he/him/his
Location: United States

Re: LunaDLL help thread

Post by Luigifan2010 »

S1eth wrote:
Pyro wrote:PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
I don't know if there's a constant for it, but Short has 16 bit and WORD also has 16 bit, so FIELD_WORD should work. (or just 1, assuming that parameter is word size; edit: I believe it's number of bytes, so 2).
FIELD_DWORD works

also, kevsoft has pushed out a fix to those having issues with Text.showMessageBox();

http://engine.wohlnet.ru/LunaLua/
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4199
Joined: 11 years ago
Location: Nova Scotia

Re: LunaDLL/LunLUA help thread

Post by SAJewers »

I'm thinking of trying to code out SMW's Start+Select level end code, but I have a few questions:

1) Is there a way to determine if the level has been previously cleared? If not, I'd be fine with allowing it at any time.
2) If you can't determine if a level was cleared, then how does level.exit() play with the OW? in A2XT Ep1, I think all 1-exit levels had the path unlocks set to "Any". Will level.exit() cause any OW paths marked "any" to unlock?
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
Zha Hong Lang
"HTMI - Hyper Text Markup Interface"
Posts: 1496
Joined: 10 years ago
First name: ZHL
Pronouns: Male
Location: United States of America

Re: LunaDLL/LunLUA help thread

Post by Zha Hong Lang »

Maybe it's just me, but I feel like the functions onEvent() and onEventDirect() are not given enough clarity. What type of situation would I use for each?

As an example, say that I want to show layer "toad" via an SMBX event, (which is also named "toad") but the event itself is activated by LunaLua. (because I want to use conditions only LunaLua can detect and utilize, such as the player using a certain character) What would be the function used for that situation?
(Formerly Jayoshi)
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunLUA help thread

Post by Rednaxela »

I'll answer what your paragraphs in reverse order, because I think it'll make the most sense that way...
Jayoshi wrote:As an example, say that I want to show layer "toad" via an SMBX event, (which is also named "toad") but the event itself is activated by LunaLua. (because I want to use conditions only LunaLua can detect and utilize, such as the player using a certain character) What would be the function used for that situation?
Neither of the ones you mentioned. onEvent and onEventDirect are for when you want Lua code to be triggered by an event, not the other way around. What you want for your example is triggerEvent

Usage example:

Code: Select all

	-- This next line causes the SMBX event named "toad" to be triggered
	triggerEvent("toad")
(put the above in some Lua code that runs in onLoop or something)

Jayoshi wrote:Maybe it's just me, but I feel like the functions onEvent() and onEventDirect() are not given enough clarity. What type of situation would I use for each?
onEvent is a Lua event that runs right before onLoop, in response to some SMBX event occuring. onEventDirect is the same except it doesn't wait until right before onLoop in the game's programming, which can potentially have uses, but is usually not what you want. If in doubt, use onEvent and not onEventDirect.

Usage example:

Code: Select all

function onEvent(eventname)
	if eventname == "toad" then
		-- Lua code inside this if statement runs in response to the SMBX event named "toad" being run
	end
end
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunLUA help thread

Post by Rednaxela »

SAJewers wrote:1) Is there a way to determine if the level has been previously cleared? If not, I'd be fine with allowing it at any time.
if the level ends in a star, I think so yes (I think you can read some of the NPC AI memory to detect if the star is in an already-gotten state). More generally though, could be more difficult without a currently known way to do it.
SAJewers wrote:2) If you can't determine if a level was cleared, then how does level.exit() play with the OW? in A2XT Ep1, I think all 1-exit levels had the path unlocks set to "Any". Will level.exit() cause any OW paths marked "any" to unlock?
I don't think level.exit triggers any overworld activity, just as exiting to overworld via death doesn't.
Zha Hong Lang
"HTMI - Hyper Text Markup Interface"
Posts: 1496
Joined: 10 years ago
First name: ZHL
Pronouns: Male
Location: United States of America

Re: LunaDLL/LunLUA help thread

Post by Zha Hong Lang »

Okay. Thanks for answering my questions! I found out that I was looking on the wrong page for code, too. Should've been looking in Global functions when I was instead looking in Lua events.
(Formerly Jayoshi)
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunLUA help thread

Post by 7NameSam »

Hey, is there a way to disable Alt run using lua?
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunLUA help thread

Post by Rednaxela »

7NameSam wrote:Hey, is there a way to disable Alt run using lua?
Untested, but you can try this out. It should do the trick.

Code: Select all

function onInputUpdate()
	player.altRunKeyPressing = false
end
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunLUA help thread

Post by 7NameSam »

Rednaxela wrote:
7NameSam wrote:Hey, is there a way to disable Alt run using lua?
Untested, but you can try this out. It should do the trick.

Code: Select all

function onInputUpdate()
	player.altRunKeyPressing = false
end
It didn't disable running with alt run, but it did fix an issue I was having with my level, so thank you.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunLUA help thread

Post by Rednaxela »

7NameSam wrote:
Rednaxela wrote:

Code: Select all

function onInputUpdate()
	player.altRunKeyPressing = false
end
It didn't disable running with alt run, but it did fix an issue I was having with my level, so thank you.
SMBX is funny about run vs alt-run. See, the thing is, the run and alt-run keys both cause "player.runKeyPressing" to be set to true, but alt-run also causes "player.altRunKeyPressing" to be set to true. The former affects actually running, the latter affects the other consequences of the alt-run key. Technically in order to disable running via the alt-run key, you'd have to disable running via the run key too. The closest that could be done (without getting into more experimental stuff like rebinding keys on the fly) is something like:

Code: Select all

function onInputUpdate()
	if player.altRunKeyPressing then
		player.runKeyPressing = false
		player.altRunKeyPressing = false
	end
end
But it would have the side effect that while the alt-run key is pressed the normal run key won't work.

Since my original code fixed the issue you were having with your level, I suspect you probably still just want the original code though. Just wanting to explain why it didn't disable running via alt-run.
Kil
Posts: 13
Joined: 14 years ago

Re: LunaDLL help thread

Post by Kil »

Pyro wrote:PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
You should beware of changing the internal SMBX star counter by the way. Currently luna will delete your saved variables for that world if it detects that the star count has gone down from what it previously was because it thinks you deleted your SMBX save and wants to also delete your luna save.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
User avatar
Ittababy
Posts: 13
Joined: 10 years ago

Re: LunaDLL/LunLUA help thread

Post by Ittababy »

:oops: So I never actually got an answer for the code needed to make a horizontal boo.
I got a vague kind of answer, but I'm no coder, and I'm not sure how I'd do what I'm told.
A very shy ghost.
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4199
Joined: 11 years ago
Location: Nova Scotia

Re: LunaDLL/LunLUA help thread

Post by SAJewers »

Is there a way to fix "A World 1 Level" From Episode 1 by disallowing the player from entering the pause menu?

EDIT: Also, Is it possible to have no P-Switch music, like in ASMT/A2MT?
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
Post Reply