Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
User avatar
Ninji2701
Bob-omb
Bob-omb
Posts: 37
Joined: Fri Mar 27, 2020 10:12 pm
Current Project: Mario's Quest

Re: Need help with lua? - LunaLua General Help

Postby Ninji2701 » Thu Apr 16, 2020 9:56 pm

Actually, I've decided to cancel this project for now, as the bug is planned to eventually be fixed, and I have a specialized solution for what I'm doing right now. Thanks for the help though!
(BTW I couldn't get it to work)
<p>Does this support HTML markup?</p>
<!--It probably doesn't-->

Mʏ Pʀᴏᴊᴇᴄᴛ
Image

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1210
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Apr 17, 2020 7:08 am

Ninji2701 wrote:
Thu Apr 16, 2020 9:56 pm
(BTW I couldn't get it to work)
Because you gave up immediately, despite me telling you what the problem was in this case: Your function needed to be "function libraryName.functionName", not just "function functionName".

User avatar
Ninji2701
Bob-omb
Bob-omb
Posts: 37
Joined: Fri Mar 27, 2020 10:12 pm
Current Project: Mario's Quest

Re: Need help with lua? - LunaLua General Help

Postby Ninji2701 » Fri Apr 17, 2020 10:36 am

Hoeloe wrote:
Fri Apr 17, 2020 7:08 am
Ninji2701 wrote:
Thu Apr 16, 2020 9:56 pm
(BTW I couldn't get it to work)
Because you gave up immediately, despite me telling you what the problem was in this case: Your function needed to be "function libraryName.functionName", not just "function functionName".
Actually, turns out I was being a big dummy and for some reason thought that you were referring to the table on line 1. I have no idea what I was thinking. But, as I would soon learn, there were a few other issues. Those have been dealt though. One thing that I'm unclear on is how to add customization options to libraries.

Added in 40 minutes 37 seconds:
Just figured it out by analyzing others' code. No need to respond.
<p>Does this support HTML markup?</p>
<!--It probably doesn't-->

Mʏ Pʀᴏᴊᴇᴄᴛ
Image

chasey1237
Shy Guy
Shy Guy
Posts: 9
Joined: Sat Nov 03, 2018 4:02 pm
Chat Username: chasey_epic

Re: Need help with lua? - LunaLua General Help

Postby chasey1237 » Fri Apr 24, 2020 3:40 pm

>:(
Enjl wrote:
Tue Mar 31, 2020 3:55 am
Murphmario wrote:
Fri Mar 27, 2020 1:50 pm

Code: Select all

function onTick()
	for k,v in ipairs(NPC.get(210)) do
		v.hp = v:mem(0x148, FIELD_FLOAT)
		Text.print(v.hp, 100, 100)
		if v.hp == 6 then
			triggerEvent(Halfway)
		end
	end
end
Not sure what I'm missing here. Probably something dumb.
Not sure what you're trying to do. Rinkas don't have HP and triggering an event that isn't even a string every frame sounds like a silly thing to do.
chasey1237 wrote:
Mon Mar 30, 2020 11:15 pm
is it possible to lock a character to have a powerup in a level so they start with it and not lose it? if so, tell me how!
Just use the Beta 4 powerup filter blocks in the Misc. tab by sprinkling them throughout your level where players can get hit.
CrazyMew37 wrote:
Fri Mar 27, 2020 1:03 pm
Hello! I want to create a stage effect in one of the sections of my stage where the lighting of the level goes down and then goes up again in a repeating manner. Perhaps this could be for both the backgrounds, blocks, and NPCs (If Possible), to make it a bit of a challenge. The Speed of the Light fading away and fading back should be quick, but not too quick. How could I possibly do this? (Also, this is just for one entire section of the level. Not the whole thing or a part of a section.)
Are you looking for something like the editor darkness setting (with light sources) or a semitransparent black overlay over everything?
Added in 3 minutes 14 seconds:
is there a way to lock a powerup with actuly using lunalua and not making the level to easy by spaming powerup filters! (ur useless enjl! ur method is useless and makes the level to easy! so dont reply if ur enjl unless u have a method that actuly uses lunalua)

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8453
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Fri Apr 24, 2020 4:10 pm

chasey1237 wrote:
Fri Apr 24, 2020 3:44 pm
Added in 3 minutes 14 seconds:
is there a way to lock a powerup with actuly using lunalua and not making the level to easy by spaming powerup filters! (ur useless enjl! ur method is useless and makes the level to easy! so dont reply if ur enjl unless u have a method that actuly uses lunalua)
Aside from the fact that your concept of difficulty in levels is woefully wrong and saddening...

Of course there is. Program your own HP system.
You can find the relevant player offsets here:
https://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Have fun!
The ABC of Creation
________________________________________________________
Image

User avatar
Electriking
Posts: 4462
Joined: Mon Jun 06, 2016 4:32 pm
Flair: I have NO idea what to put here
Current Project: Something
Chat Username: ElectriKing
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Electriking » Fri Apr 24, 2020 4:23 pm

chasey1237 wrote:
Fri Apr 24, 2020 3:44 pm
(ur useless enjl! ur method is useless and makes the level to easy! so dont reply if ur enjl unless u have a method that actuly uses lunalua)
Please be more respectful to others.
SMM2 ID: JJF-P7G-FSF

chasey1237
Shy Guy
Shy Guy
Posts: 9
Joined: Sat Nov 03, 2018 4:02 pm
Chat Username: chasey_epic

Re: Need help with lua? - LunaLua General Help

Postby chasey1237 » Fri Apr 24, 2020 7:24 pm

Electriking wrote:
Fri Apr 24, 2020 4:23 pm
chasey1237 wrote:
Fri Apr 24, 2020 3:44 pm
(ur useless enjl! ur method is useless and makes the level to easy! so dont reply if ur enjl unless u have a method that actuly uses lunalua)
Please be more respectful to others.
jeez i only asked for lunalua help!

MarioLover64
Hoopster
Hoopster
Posts: 165
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Tue May 05, 2020 9:35 am

How do I send data (like health) to a transformed npc?

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8453
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Tue May 05, 2020 10:06 am

MarioLover64 wrote:
Tue May 05, 2020 9:35 am
How do I send data (like health) to a transformed npc?
Please elaborate. Not sure what your situation is exactly.
The ABC of Creation
________________________________________________________
Image

MarioLover64
Hoopster
Hoopster
Posts: 165
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Tue May 05, 2020 10:12 am

nvmd figured it out

Added in 6 minutes 41 seconds:
how much damage does the harmtypes do to larry?

User avatar
cato
Ripper II
Ripper II
Posts: 377
Joined: Thu Aug 24, 2017 3:06 am
Flair: Creative, opinionated, but poor expression
Current Project: https://docs.google.com/spreadsheets/d/ ... sp=sharing
Chat Username: Cato
Contact:

Re: Need help with lua? - LunaLua General Help

Postby cato » Sun May 24, 2020 5:43 am

How would you use Section:drawScreenEffect(id, camera)?

I get you are supposed to substitute screen effect constant into the "id", but what do I substitute into "camera", and at a certain time disable the screen effect?

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8453
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sun May 24, 2020 6:44 am

cato wrote:
Sun May 24, 2020 5:43 am
How would you use Section:drawScreenEffect(id, camera)?

I get you are supposed to substitute screen effect constant into the "id", but what do I substitute into "camera", and at a certain time disable the screen effect?
Camera would be a camera object (for example, the variable 'camera'. The camera of player 1.
To disable it, just stop drawing it. It works like Graphics.drawImage which you also invoke every frame.
The ABC of Creation
________________________________________________________
Image

TheTrueMarioMaster
Bit
Bit
Posts: 149
Joined: Mon Mar 19, 2018 11:58 pm
Chat Username: TheTrueMarioMaster

Re: Need help with lua? - LunaLua General Help

Postby TheTrueMarioMaster » Fri May 29, 2020 8:00 pm

Anyone know how to disable shell grabbing since I hear it hardcoded so just disabling grabbing in general won't work.
Other places to find me at.
PureZC
MarioFanGameGalaxy

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8453
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sat May 30, 2020 3:00 am

TheTrueMarioMaster wrote:
Fri May 29, 2020 8:00 pm
Anyone know how to disable shell grabbing since I hear it hardcoded so just disabling grabbing in general won't work.
https://wohlsoft.ru/pgewiki/SMBX_Fields

Defines.player_grabShellEnabled = false
The ABC of Creation
________________________________________________________
Image

Graham
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 08, 2014 3:10 pm

Re: Need help with lua? - LunaLua General Help

Postby Graham » Wed Jun 03, 2020 11:54 pm

So, uh... I'm going to ask something a little bit wacky. Is there any known way to keep an NPC in an active, functioning state if the player is not present in the same section?

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8453
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Thu Jun 04, 2020 12:48 am

Graham wrote:
Wed Jun 03, 2020 11:54 pm
So, uh... I'm going to ask something a little bit wacky. Is there any known way to keep an NPC in an active, functioning state if the player is not present in the same section?
It's tricky, given that the game unloads a section once you leave it. What are you trying to do, exactly?
The ABC of Creation
________________________________________________________
Image

User avatar
Lithobraker
Bob-omb
Bob-omb
Posts: 30
Joined: Sat Mar 09, 2019 1:41 am
Current Project: My first SMBX Episode

Re: Need help with lua? - LunaLua General Help

Postby Lithobraker » Sun Jun 28, 2020 1:58 pm

So I'm trying to do a check if the player is mounted or not in an OnEvent function. If the player has a mount, trigger "Event A", and if they are not, trigger "Event B". But all the information I could find on how to detect mounts seems to be outdated (I think I've gotten event triggering via lunalua right). Char.itemSlot seems not to apply anymore, so I've been trying to detect all the NPCs in the section so I can play it if there's any mount NPC present, but I'm not quite sure how to do that either.

I've already tried to look this up- examples of npc.get in use, mount detection, etc- but I can't search "npc.get" since "npc" and "get" are too common, and trying to find anything related to mounts just brought me back to Char.itemSlot.
I thought maybe the player class would have something relating to mounts, but it seems it doesn't, unless the wiki is incomplete.

Edit: Nevermind, I found it. "player.mount" is a variable, it's just not documented... <.>
For those like me who want to make a 'dismount Yoshi' cutscene, here's what I put in my luna.lua:
Spoiler: show

Code: Select all

function onStart()
    if player.section == 0 then
		triggerEvent("Castle Cutscene 1")
	end
end

function onEvent(eventname, x)
	if (eventname == "Castle Cutscene Yoshicheck") then 
				if player.mount ~= 0 then
					triggerEvent("Castle Cutscene 4 Yoshi")
				else
					triggerEvent("Castle Cutscene 4 Noyoshi")
		end
	end
end
Added in 4 hours 46 minutes 31 seconds:
Now I have a new problem: Triggering an event on load does not appear to work correctly for input locking- if a button is held during loading, the player can move before the event triggers and locks input.
This is different from autostart event, which will successfully lock input.
The reason why I only want it to trigger on section 0 is because that's the entry cutscene- but it shouldn't happen when respawning at a checkpoint, for example.

onStart is supposed to run on the very first frame the level is loaded, but you get several frames of input here before it seems to kick in. Why is this?

Edit: Figured it out again. I'm not sure why this is happening, but you need to manually lock input until an event involving movement first occurs.
FOR SOME REASON, setting lockInput to true with onStart here does work to prevent input, but the event itself is delayed when triggered the same way.

So I manually restrict inputs until Castle Cutscene 2 begins, which is when it starts holding right.
This is still very odd, though. Why does Castle Cutscene 1 laze around for a few frames before starting? Freeloader.
Spoiler: show

Code: Select all

local lockInput = false

function onStart()
    if player.section == 0 then
		triggerEvent("Castle Cutscene 1")
		lockInput = true
	end
end

function onInputUpdate()
	if lockInput == true then
		player.upKeyPressing = false;
		player.leftKeyPressing = false;
		player.rightKeyPressing = false;
		player.downKeyPressing = false;
		player.jumpKeyPressing = false;
		player.altJumpKeyPressing = false;
		player.runKeyPressing = false;
		player.altRunKeyPressing = false;
		player.dropItemKeyPressing = false;
		player.pauseKeyPressing = false;
	end
end

function onEvent(eventname, x)
	if (eventname == "Castle Cutscene 2") then 
		lockInput = false
	end
	if (eventname == "Castle Cutscene Yoshicheck") then 
				if player.mount ~= 0 then
					triggerEvent("Castle Cutscene 3 Yoshi")
				else
					triggerEvent("Castle Cutscene 3 Noyoshi")
		end
	end
	if (eventname == "bossroomenter Check") then 
				if player.character == 1 then
					triggerEvent("bossmsg Mario")
				else
					triggerEvent("bossmsg Luigi")
		end
	end
end

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8453
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Mon Jun 29, 2020 4:27 am

Lithobraker wrote:
Sun Jun 28, 2020 6:45 pm
Char.itemSlot
Was this ever a thing? That sounds like 38A code. 38A code is unrelated to SMBX2.
Lithobraker wrote:
Sun Jun 28, 2020 6:45 pm
npc.get
NPC.get. Capitalisation! Clever idea that wouldn't have worked though because yoshi ridden by the player is not actually an npc.
Lithobraker wrote:
Sun Jun 28, 2020 6:45 pm
player.mount" is a variable, it's just not documented
We're working on it.
https://docs.codehaus.moe/#/reference/player
Lithobraker wrote:
Sun Jun 28, 2020 6:45 pm
Triggering an event on load does not appear to work correctly for input locking-
The event trigger may not be registered until the next frame. You could work around it by foregoing events entirely:

Code: Select all

local inputLocked = false
function onStart()
	if player.section == 0 then
		inputLocked = true
		-- Trigger your event here or start a routine that handles the cutscene in lua.
	end
end

function onTick()
	if inputLocked then
		for k,v in pairs(player.keys) do
			player.keys[k] = false
		end
	end
end

Oh i read onwards and you figured that out too. Take a peek at my code though for a potentially more compact solution.
The ABC of Creation
________________________________________________________
Image

User avatar
Lithobraker
Bob-omb
Bob-omb
Posts: 30
Joined: Sat Mar 09, 2019 1:41 am
Current Project: My first SMBX Episode

Re: Need help with lua? - LunaLua General Help

Postby Lithobraker » Mon Jun 29, 2020 1:01 pm

Enjl wrote:
Mon Jun 29, 2020 4:27 am
-snip-
Char.ItemSlot was part of Teascript, which does appear to be a 38A thing.
And yeah, I knew NPC.get was supposed to be capitalized- I just didn't write it that way here.
I'll give your method a shot. Thanks!

User avatar
Goldenemerl64
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Jul 07, 2020 3:50 pm
Current Project: Super Mario Adventure (not the best, but fun to make)

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Tue Jul 07, 2020 7:16 pm

:| Having problems Understanding what to do,
Image
I Didn't change anything in that code, And it's Kinda strange when I play a level not saved, It Works Fine, But when it's saved, It Shows This Message,
I tried To figure out what's wrong but i can't figure it up, I need help please :(


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests