LunaLua Offical Thread - SMBX Usermod Framework

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?

Shall I steam some LunaLua live development?

Yes
200
92%
No
17
8%
 
Total votes: 217
Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Tue Apr 07, 2015 12:59 pm

Sure, backwards compatbility will always be.

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Sat May 02, 2015 2:58 pm

Is there a way to trigger events when you collide with a block? I know there is if you use autocode, but I'd rather use Lua if it's possible.

EDIT: Also, is there any way to scale/transform images that are displayed? We could do a ton of cool things if that's possible...

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Sat May 02, 2015 4:39 pm

HenryRichard wrote:Is there a way to trigger events when you collide with a block? I know there is if you use autocode, but I'd rather use Lua if it's possible.
Yes there is. You can use the Block:collidesWith function + triggerEvent function. But I don't have a sample code at the moment.

HenryRichard wrote:EDIT: Also, is there any way to scale/transform images that are displayed? We could do a ton of cool things if that's possible...
not yet, but with the new opengl render coming, we will see what is possible :P

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Sat May 02, 2015 5:30 pm

Kevsoft wrote:
HenryRichard wrote:Is there a way to trigger events when you collide with a block? I know there is if you use autocode, but I'd rather use Lua if it's possible.
Yes there is. You can use the Block:collidesWith function + triggerEvent function. But I don't have a sample code at the moment.
That's good to know - to bad I can't figure out how to get it to work since I'm a complete l=Lua noob and all I know is based off of Java and C. If you do happen to make an example at some point, I'd like to see it.
Kevsoft wrote:
HenryRichard wrote:EDIT: Also, is there any way to scale/transform images that are displayed? We could do a ton of cool things if that's possible...
not yet, but with the new opengl render coming, we will see what is possible :P
Let's hope for the best - even if we can't scale or rotate, we're still gonna be able to do great things!

Also, I can't seem to get a line of text that displays your current star count. I tried to use this -

Code: Select all

Text.print(mem(0x00B251E0,FIELD_WORD),48,16);
but I get an error every time I test -
Image

Any idea what I'm doing wrong?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Sun May 03, 2015 12:58 am

LunaLua 0.7 is still not released yet. That's why Text.print doesn't work.

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Fri May 15, 2015 9:37 am

Any estimate on 0.7's release date? Been skimming through the talkhaus thread and you've guys been working on a opengl renderer? Sounds awesome.

Also, is it possible to make it so while holding down a key, it adds +1 to a variable?

Wohlstand
Van De Graf
Van De Graf
Posts: 2008
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Wohlstand » Fri May 15, 2015 2:10 pm

Onule wrote:Also, is it possible to make it so while holding down a key, it adds +1 to a variable?
Use on key event (look at documentation) and var=var+1
Last edited by Wohlstand on Fri May 15, 2015 6:13 pm, edited 1 time in total.

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Fri May 15, 2015 4:08 pm

Tried messing with that, only managed to make it add +1 every time I pressed the key.

When I tried something like this, the game freezes.

Code: Select all

function onKeyDown(keycode)
	while keycode == KEY_DOWN do
		a = a + 1
	end
end

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Fri May 15, 2015 4:44 pm

That's because you are in a endless loop.
You have to do this like that:

Code: Select all

local a = 0
function onKeyDown(keycode)
   if(keycode == KEY_DOWN) do
      a = a + 1
   end
end

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Fri May 15, 2015 6:22 pm

I did that before, only adds 1 every time the key is pressed, I want to make it so that while I'm holding down the key, it would add 1, so I could use it like a timer.

Example would be this


I tried to mess with this, but couldn't get it to work.
Image

also if do :roll:

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Sat May 16, 2015 1:22 am

Try:

Code: Select all

if(player:mem(0xF4, FIELD_WORD) == -1)then
a = a + 1
end

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Sat May 16, 2015 8:57 pm

Oh it's -1? I tried that before but with 1 instead.

Just making sure, if it perfectly fine to have something like this on a loop?

Code: Select all

if (player.x > -200000) then
		triggerEvent("ShowLayer")
	  else	
		triggerEvent("HideLayer")
	end
end
Would it be constantly triggering an event or only when possible?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Sun May 17, 2015 1:45 am

It would constantly trigger the event. The trick is using a local variable in the gloal scope:

Code: Select all

local isLayerShown = false
function onLoop()
    if (player.x > -200000 and isLayerShown == false) then
        triggerEvent("ShowLayer")
        isLayerShown = true
    else
        if(isLayerShown == true)then
              triggerEvent("HideLayer")
        end
   end
end

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Sun May 17, 2015 5:08 pm

Wouldn't that cause the layer to show for just a frame?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Mon May 18, 2015 12:43 am

Oh, yea, you right. You have to check also in the other direction.

Here:

Code: Select all

local isLayerShown = false
function onLoop()
    if (player.x > -200000 and isLayerShown == false) then
        triggerEvent("ShowLayer")
        isLayerShown = true
    elseif(player.x <= -200000 and isLayerShown == true)then
        triggerEvent("HideLayer")
        isLayerShown = false
   end
end

lighthouse64
Charged Spiny
Charged Spiny
Posts: 1804
Joined: Sat Apr 26, 2014 6:28 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby lighthouse64 » Mon May 18, 2015 10:18 am

I have a problem :/

Code: Select all

local g = 3
gravity = g
onJump(gravity = g*-1)
It seems that line 3 has an error, but I don't see anything wrong with the code. :/

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Mon May 18, 2015 12:27 pm

1.) You need to work with defines, see here:
http://engine.wohlnet.ru/pgewiki/SMBX_Fields
2.) You calling the function onJump, rather than defining as a event.

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Tue May 19, 2015 5:19 pm

I'm having a big problem. I'm using this code:

Code: Select all

function onLoop()
	cannonBlocks = findblocks(34);
	for k,v in pairs(cannonBlocks) do
      if(v:collidesWith(player) == 1) then
			cannon(player);
		elseif(v:collidesWith(player2) == 1) then
			cannon(player2);
		end
    end
end

function cannon(thePlayer)
	thePlayer.x = thePlayer.x + 240;
	thePlayer.y = thePlayer.y - 256;
	thePlayer.speedX = 12;
	thePlayer.speedY = -12;
	thePlayer.HasJumped = -1;
	thePlayer.FacingDirection = 1;
	--playSFXSDL("SM64-cannonfire.wav");
end
The level loads fine, but the game freezes when I test, and I get a "SuperMarioBrosX.org has stopped working" window. Is this a problem with my installation or my code or my computer or something else?

What really frustrates me is that it was working just fine but then just stopped working...

EDIT: I just tried re-installing lunalua, and I think it was a bit outdated. However, it's still freezing.

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Wed May 20, 2015 4:04 am

Overall it looks fine to me. I will test it, when I am back home.

EDIT: Uhm one note here. Maybe try:

Code: Select all

function onLoop()
   cannonBlocks = findblocks(34);
   for k,v in pairs(cannonBlocks) do
      if(v:collidesWith(player) == 1) then
         cannon(player);
      if(player2) then
         if(v:collidesWith(player2) == 1) then
            cannon(player2);
         end
      end
    end
end

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Wed May 20, 2015 1:21 pm

Thanks, it's working perfectly now!
I'll remember to check if player2 exists next time.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari