LunaDLL/LunaLUA help thread
- CloudyCloud
- Posts: 234
- Joined: 11 years ago
Maybe it is an old question that is asked before
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...?)
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...?)
Re: Maybe it is an old question that is asked before
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.
- Courtesy of viewtopic.php?f=36&t=14271&start=1150#p298814
Put this script as "lunadll.lua" in your custom level folder.
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
Put this script as "lunadll.lua" in your custom level folder.
- CloudyCloud
- Posts: 234
- Joined: 11 years ago
Re: Maybe it is an old question that is asked before
Regarding spin-jump thing...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.- Courtesy of viewtopic.php?f=36&t=14271&start=1150#p298814Code: 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
Put this script as "lunadll.lua" in your custom level folder.
Wait, so I need to use lunalua?
I am kinda hoping to ignore the need of lunalua.
- 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
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.CloudyCloud wrote:Regarding spin-jump thing...
Wait, so I need to use lunalua?
I am kinda hoping to ignore the need of lunalua.
Re: LunaDLL help thread
I want to make it so you can't move if you are standing on the ground, How do I do that?
- CloudyCloud
- Posts: 234
- Joined: 11 years ago
Re: Maybe it is an old question that is asked before
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.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.
But, it doesn't work.
Re: Maybe it is an old question that is asked before
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.CloudyCloud wrote: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.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.
But, it doesn't work.
- snoruntpyro
- cutest girl 2023
- Posts: 884
- Joined: 9 years ago
- Pronouns: she/her
- Contact:
Re: LunaDLL help thread
PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
Re: LunaDLL help thread
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).Pyro wrote:PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
Last edited by S1eth 8 years ago, edited 1 time in total.
- snoruntpyro
- cutest girl 2023
- Posts: 884
- Joined: 9 years ago
- Pronouns: she/her
- Contact:
Re: LunaDLL help thread
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?
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?
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: LunaDLL help thread
A consequence of moving to LuaJIT, interacting with some of the error handling of Luabind.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?
I've have a fix in mind for a but need to test it.
-
- Lua squad
- Posts: 2
- Joined: 9 years ago
- First name: Mike
- Pronouns: he/him/his
- Location: United States
Re: LunaDLL help thread
FIELD_DWORD worksS1eth wrote: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).Pyro wrote:PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
also, kevsoft has pushed out a fix to those having issues with Text.showMessageBox();
http://engine.wohlnet.ru/LunaLua/
- SAJewers
- ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
- Posts: 4199
- Joined: 11 years ago
- Location: Nova Scotia
Re: LunaDLL/LunLUA help thread
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?
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?
-
- "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
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?
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)
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: LunaDLL/LunLUA help thread
I'll answer what your paragraphs in reverse order, because I think it'll make the most sense that way...
Usage example:(put the above in some Lua code that runs in onLoop or something)
Usage example:
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 triggerEventJayoshi 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?
Usage example:
Code: Select all
-- This next line causes the SMBX event named "toad" to be triggered
triggerEvent("toad")
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.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?
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
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: LunaDLL/LunLUA help thread
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: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.
I don't think level.exit triggers any overworld activity, just as exiting to overworld via death doesn't.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?
-
- "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
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)
Re: LunaDLL/LunLUA help thread
Hey, is there a way to disable Alt run using lua?
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: LunaDLL/LunLUA help thread
Untested, but you can try this out. It should do the trick.7NameSam wrote:Hey, is there a way to disable Alt run using lua?
Code: Select all
function onInputUpdate()
player.altRunKeyPressing = false
end
Re: LunaDLL/LunLUA help thread
It didn't disable running with alt run, but it did fix an issue I was having with my level, so thank you.Rednaxela wrote:Untested, but you can try this out. It should do the trick.7NameSam wrote:Hey, is there a way to disable Alt run using lua?Code: Select all
function onInputUpdate() player.altRunKeyPressing = false end
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: LunaDLL/LunLUA help thread
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:7NameSam wrote:It didn't disable running with alt run, but it did fix an issue I was having with my level, so thank you.Rednaxela wrote:Code: Select all
function onInputUpdate() player.altRunKeyPressing = false end
Code: Select all
function onInputUpdate()
if player.altRunKeyPressing then
player.runKeyPressing = false
player.altRunKeyPressing = false
end
end
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.
Re: LunaDLL help thread
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.Pyro wrote:PGE Wiki says that the star counter's memory type is "Short" - how would I type this in the "mem" function?
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Re: LunaDLL/LunLUA help thread
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.
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.
- SAJewers
- ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
- Posts: 4199
- Joined: 11 years ago
- Location: Nova Scotia
Re: LunaDLL/LunLUA help thread
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?
EDIT: Also, Is it possible to have no P-Switch music, like in ASMT/A2MT?