Need help with lua? - LunaLua General Help

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Thu Jan 11, 2018 6:35 pm

What do you mean it needs to be within onJumpEnd? How are you using onTick?

The game engine does something like this:

Code: Select all

runs onTick()
does everything for physics and ai for this tick (I think onJumpEnd will be run some time in here)
runs onDraw()
draws graphics
start over at onTick() again
That is to say, it cannot continue until the code in those functions is finished. If you have an infinite loop, it will freeze.

Novarender
Tweeter
Tweeter
Posts: 145
Joined: Sat Aug 06, 2016 6:59 pm
Flair: Whoa

Re: Need help with lua? - LunaLua General Help

Postby Novarender » Thu Jan 11, 2018 6:48 pm

But if I use onJumpEnd in a loop, will it detect it at all? Doesn't it trigger in an instance, too short to detect? Or will it wait for the jump to end?

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Thu Jan 11, 2018 7:39 pm

You don't need a loop. The game itself runs in a loop similar to what I described. It will run everything in onTick() once every tick. It will run onJumpEnd() at some point during the tick if applicable.

Edit: You don't use onJumpEnd(), onTick() etc in other functions, they are automatically run by the game.
Last edited by Quantumenace on Thu Jan 11, 2018 7:45 pm, edited 1 time in total.

Novarender
Tweeter
Tweeter
Posts: 145
Joined: Sat Aug 06, 2016 6:59 pm
Flair: Whoa

Re: Need help with lua? - LunaLua General Help

Postby Novarender » Thu Jan 11, 2018 7:42 pm

I think I get what you mean. Everything in onTick() is a loop, and if I use onJumpEnd() in said loop, then it will still detect it. Right?

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Thu Jan 11, 2018 7:49 pm

Notxarb wrote:I think I get what you mean. Everything in onTick() is a loop, and if I use onJumpEnd() in said loop, then it will still detect it. Right?
Sort of, onTick is part of the game loop. (A similar, older function is called onLoop().) You don't want to use Lunalua event functions inside anything else, they will be run by the game automatically.

Novarender
Tweeter
Tweeter
Posts: 145
Joined: Sat Aug 06, 2016 6:59 pm
Flair: Whoa

Re: Need help with lua? - LunaLua General Help

Postby Novarender » Thu Jan 11, 2018 7:55 pm

Ah, I get what you mean now.

I think this should be right, but it seems like LunaLua is turned off or something. Nothing is working; not even the player.speed displays that are printed on the screen (not included).

Code: Select all

local loop = 0

function onTick()
	
loop = loop + 1

end

function onJumpEnd()
	
		if loop < 64 then
			if player.speedX > 4 or player.speedX < -4 then
			Defines.jumpheight = 50
			else
			Defines.jumpheight = 20
			end
		else
		loop = 0
		end
	
	end
EDIT: Wait. I tried this again, and somehow, it works now. Do you think it's inconsistent, or was I maybe just testing it wrong?
EDIT AGAIN: No, I tried it again and it won't work. What's going on?

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Thu Jan 11, 2018 8:07 pm

That's kind of backwards. You want to check the timer and correct the jump height every tick, right? You need to put most of that in onTick.

Novarender
Tweeter
Tweeter
Posts: 145
Joined: Sat Aug 06, 2016 6:59 pm
Flair: Whoa

Re: Need help with lua? - LunaLua General Help

Postby Novarender » Thu Jan 11, 2018 8:21 pm

Oh, you're right. But the problem is, I need to do most of it every tick, but I need to initiate all of that at the end of a jump. Should I trigger it via a variable?

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Thu Jan 11, 2018 9:04 pm

Notxarb wrote:Oh, you're right. But the problem is, I need to do most of it every tick, but I need to initiate all of that at the end of a jump. Should I trigger it via a variable?
Yes, that's what I'd recommend.

Novarender
Tweeter
Tweeter
Posts: 145
Joined: Sat Aug 06, 2016 6:59 pm
Flair: Whoa

Re: Need help with lua? - LunaLua General Help

Postby Novarender » Mon Jan 15, 2018 8:49 pm

Is there any way to have a dark level as shown in the pictures of the SMBX2 website?
http://horikawaotane.com/smbx

Novarender
Tweeter
Tweeter
Posts: 145
Joined: Sat Aug 06, 2016 6:59 pm
Flair: Whoa

Re: Need help with lua? - LunaLua General Help

Postby Novarender » Mon Jan 15, 2018 9:01 pm

How can I check whether the player is alive?

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Mon Jan 15, 2018 9:58 pm

Notxarb wrote:Is there any way to have a dark level as shown in the pictures of the SMBX2 website?
http://horikawaotane.com/smbx
Honestly that's just the brightness being changed on the images to make them be more fitting for the background of the page, however the easiest way to achieve this is to draw a screenshade over everything but the HUD via Graphics.glDraw. (Just draw a rectangle covering the whole screen at priority 4).
Notxarb wrote:How can I check whether the player is alive?

Code: Select all

player:mem(0x13A, FIELD_WORD) == 0

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon Jan 15, 2018 10:11 pm

PixelPest wrote:
Notxarb wrote:Is there any way to have a dark level as shown in the pictures of the SMBX2 website?
http://horikawaotane.com/smbx
Honestly that's just the brightness being changed on the images to make them be more fitting for the background of the page, however the easiest way to achieve this is to draw a screenshade over everything but the HUD via Graphics.glDraw. (Just draw a rectangle covering the whole screen at priority 4).
https://youtu.be/feVUxOmN7mk?t=70
Not perfectly, currently. The footage here uses pre-baked geometry, so it wouldn't respond to moving objects. Admittedly, it was put in here for showoff. But I THINK there's a shader hoeloe made which does this that can be made publically available with beta 4 or when we get plugin support (required for making it an editor feature).

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Mon Jan 15, 2018 10:25 pm

I completely misinterpreted that question

Taycamgame
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 1483
Joined: Mon Jun 19, 2017 11:35 am
Flair: Stargard
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Taycamgame » Tue Jan 16, 2018 3:36 am

Enjl wrote:
PixelPest wrote:
Notxarb wrote:Is there any way to have a dark level as shown in the pictures of the SMBX2 website?
http://horikawaotane.com/smbx
Honestly that's just the brightness being changed on the images to make them be more fitting for the background of the page, however the easiest way to achieve this is to draw a screenshade over everything but the HUD via Graphics.glDraw. (Just draw a rectangle covering the whole screen at priority 4).
https://youtu.be/feVUxOmN7mk?t=70
Not perfectly, currently. The footage here uses pre-baked geometry, so it wouldn't respond to moving objects. Admittedly, it was put in here for showoff. But I THINK there's a shader hoeloe made which does this that can be made publically available with beta 4 or when we get plugin support (required for making it an editor feature).
That's something I always wanted to use, glad it may come in beta 4.
What do you mean by screenshade and how do you give it priority 4?
Realistically you can do this by using a black background, but it's just not the same...

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Tue Jan 16, 2018 7:57 am

Taycamgame wrote:What do you mean by screenshade and how do you give it priority 4?
What pixelpest described just makes everything darker. You can use Graphics.drawImage, Graphics.draw (both require a texture) or Graphics.glDraw (doesn't require a texture but is more complex) to get this effect:
https://wohlsoft.ru/pgewiki/LunaLua_glo ... _functions

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Jan 16, 2018 8:10 am

Enjl wrote: Not perfectly, currently. The footage here uses pre-baked geometry, so it wouldn't respond to moving objects.
What's shown in the trailer is actually a huge hack that just uses a capture buffer to draw circles around light sources. The one planned for beta 4 is a bit more dynamic, but still doesn't yet respond to geometry for shadows. There's some more tech necessary before that becomes an option.

Taycamgame
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 1483
Joined: Mon Jun 19, 2017 11:35 am
Flair: Stargard
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Taycamgame » Tue Jan 16, 2018 11:13 am

Hoeloe wrote:The one planned for beta 4 is a bit more dynamic, but still doesn't yet respond to geometry for shadows.
And that means what exactly? What shadow geometry?
Let me give an example: Will we be able to create a dark cave with torches that make the room brighter?
Will we be able to use those on/off light blocks like in NSMB to brighten a dark cave?

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Jan 16, 2018 12:08 pm

Taycamgame wrote:
Hoeloe wrote:The one planned for beta 4 is a bit more dynamic, but still doesn't yet respond to geometry for shadows.
And that means what exactly? What shadow geometry?
Let me give an example: Will we be able to create a dark cave with torches that make the room brighter?
Will we be able to use those on/off light blocks like in NSMB to brighten a dark cave?
I mean this: Image

And yes, this system allows all of that.

Taycamgame
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 1483
Joined: Mon Jun 19, 2017 11:35 am
Flair: Stargard
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Taycamgame » Tue Jan 16, 2018 12:37 pm

I still don't understand it completely; why is it called shadow "geometry" and not just "shadows"?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari