LunaLua Offical Thread - SMBX Usermod Framework

This is the place for discussion and support for LunaLua and related modifications and libraries.
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
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8723
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Enjl » Wed Dec 02, 2015 8:12 pm

Kyoya wrote: Yes and storing the code required there caused the whole game to crash as I just said.
What you said is that you used the PC+ code. Did you actually type

Code: Select all

player:mem(PC+0x158, FIELD_WORD, itemid)
or type

Code: Select all

player:mem(0x158, FIELD_WORD, itemid)
Cause only the latter will work. Your first post wasn't very clear about this, and this is probably your problem. I just tested it. It works fine for me. Here's some code I used to put a goomba into my reserve item box:

Code: Select all

function onLoad()
	if player.isValid then
		player:mem(0x158, FIELD_WORD, 1)
	end
end
Ideas are useless if you can't make them real.
Image

Kyoya
Cheep-Cheep
Cheep-Cheep
Posts: 12
Joined: Sun Nov 15, 2015 2:35 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kyoya » Wed Dec 02, 2015 9:45 pm

Thank you... I used the first way and it killed it all.
Question now is, is there a quick way of telling what value each power up has? Or do I go to test ever single one to get the values using Text.print?

Edit: didn't help, I think u misunderstood I dont want to assign the reserve item I want to obtain the value of the reserve item box with the item in it so I can display the item on screen.

Sort of like (I know this isn't code):
reservedItemBox = Code for the item box contents in memory.
if reservedItemBox = 0
end
if reservedItemBox = the value for mushroom
place a mushroom sprite on the screen at a certain point
end

^ Get it?
I try to use the memory code and it causes it to crash when I try to capture the value.

Horikawa Otane
Lakitu
Lakitu
Posts: 485
Joined: Sun Jan 05, 2014 2:02 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Horikawa Otane » Thu Dec 03, 2015 3:06 am

Kyoya wrote:Thank you... I used the first way and it killed it all.
Question now is, is there a quick way of telling what value each power up has? Or do I go to test ever single one to get the values using Text.print?

Edit: didn't help, I think u misunderstood I dont want to assign the reserve item I want to obtain the value of the reserve item box with the item in it so I can display the item on screen.

Sort of like (I know this isn't code):
reservedItemBox = Code for the item box contents in memory.
if reservedItemBox = 0
end
if reservedItemBox = the value for mushroom
place a mushroom sprite on the screen at a certain point
end
Well I mean... The proper way to do that is load the graphics into a table whose index is the id of the power up (which is easily obtainable through PGE) and whose value is the loadImage of the relevant image.

Then simply use graphics.placeSprite when you need to with tableName[player:mem(0x158, FIELD_WORD)]

Assuming the indexes line up with their Sprite ID, and I am 99% sure that is the case, you could even automate loading of the files from the graphics folder in a big for loop.

Horikawa Otane
Lakitu
Lakitu
Posts: 485
Joined: Sun Jan 05, 2014 2:02 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Horikawa Otane » Thu Dec 03, 2015 3:20 am

Enjl wrote:You're trying to define player values outside of functions. These are also checked when the level is loaded in the editor. When you're in the editor, no player exists, and therefore the pointer is invalid.

You can circumvent this by replacing the first three lines with this:

Code: Select all

local PreviousPowerup
local PreviousPlayerY
local DoTurnBig = false

function onLoad()
  if player.isValid then
    PreviousPowerup = PLAYER_SMALL
    PreviousPlayerY = player.y
  end
end
What I'm essentially doing is a check for whether the player exists, and only set the initial variables if he does.
This is no longer necessary. And you should avoid onLoad in general forever.

Code: Select all

local PreviousPowerup
local PreviousPlayerY
local DoTurnBig = false

function onStart()
    PreviousPowerup = PLAYER_SMALL
    PreviousPlayerY = player.y
end
onStart runs the first frame and that's it. onLoad runs in a weird bizarre state while items are loading before the first frame, so it can be inconsistent.

User avatar
Kevsoft
Ripper II
Ripper II
Posts: 374
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Thu Dec 03, 2015 6:50 am

I just want to note, that onStart is currently in the dev-version and not in the current released one yet.
Last edited by Kevsoft on Thu Dec 03, 2015 7:16 am, edited 1 time in total.

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

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Enjl » Thu Dec 03, 2015 6:57 am

Yeah, I know about onStart, but I used the onLoad code as an example because of what Kevsoft just said.
Ideas are useless if you can't make them real.
Image

Horikawa Otane
Lakitu
Lakitu
Posts: 485
Joined: Sun Jan 05, 2014 2:02 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Horikawa Otane » Thu Dec 03, 2015 9:23 pm

Enjl wrote:Yeah, I know about onStart, but I used the onLoad code as an example because of what Kevsoft just said.
Oh, well even so you should avoid using onLoad. It's much safer to do:

Code: Select all

local firstRun = true
local PreviousPowerup
local PreviousPlayerY

function onLoop()
	if firstRun then
		PreviousPowerup = PLAYER_SMALL
		PreviousPlayerY = player.y
		firstRun = false
	end
end

Mable
Peach
Peach
Posts: 5835
Joined: Sat Dec 21, 2013 4:23 am
Current Project: Account soon to be deleted
Chat Username: Account soon to be d
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Mable » Sat Dec 05, 2015 10:54 am

When i downloaded the a2xt lunalua one. Is it normal for the furba to do the moonwalk?

User avatar
TheSaturnyoshi
Swooper
Swooper
Posts: 108
Joined: Tue Dec 01, 2015 9:46 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby TheSaturnyoshi » Sat Dec 05, 2015 7:21 pm

That's because the Furbas replace Goombas, so they need the npc-.txt to animate properly.
Who even uses siignatures these days?

User avatar
HenryRichard
Ludwig von Koopa
Ludwig von Koopa
Posts: 2846
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Tue Dec 08, 2015 11:23 pm

So I'm trying to make this really cool x Bro api where you can have multiple different kinds of bros in a level (hammer bros, goomba bros, and rinka bros in this code). The functionality is there (type what you want them to throw in the message box, disable friendly, and they throw it), but I'd like to give them all different graphics (because I have a feeling that some people will be annoyed when enemies that look the same throw different things). I've tried setting v.animationFrame, but that's not working the way I want. Here's my code:

Code: Select all

function onLoop()
	for k, v in pairs(NPC.get(29, -1)) do
		if(not v.friendly) then
			if(v.msg.str ~= "") then
				if(v.msg.str == "goomba") then
					v.ai4 = 1;
					v.ai5 = 89;
				elseif(v.msg.str == "rinka") then
					v.ai4 = 2;
					v.ai5 = 210;
				end
				v.msg = "";
			end
			v.animationFrame = v.animationFrame + 6 * v.ai4;
			for k,v1 in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do
				if(v1.id == 30 and v1.ai1 == 0) then
					if(v.ai4 == 0) then
						v1.ai1 = 1;
					else
						v1.id = v.ai5;
					end
				end
			end
		end
	end
end
Jesus is my savior.

lotus006
Mega Mole
Mega Mole
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Wed Dec 09, 2015 1:12 am

Hi, I have a question about "Graphics.drawImage" I try to re-create chest from toad house but when I place with this
the player is walking behind the graphic, is there a way to make the player walk in front of the graphic ?

P.S. :
I'm surprised there is no one have done the Whistler in the 2.0 hehe :( , this one should be easy to do now with Lua :)

User avatar
Kevsoft
Ripper II
Ripper II
Posts: 374
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Wed Dec 09, 2015 4:04 am

lotus006 wrote:is there a way to make the player walk in front of the graphic ?
Render priority currently only applies to custom lua sprites. But it is planned to also apply it to internal rendering.

lotus006
Mega Mole
Mega Mole
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Wed Dec 09, 2015 4:50 am

Kevsoft wrote:
lotus006 wrote:is there a way to make the player walk in front of the graphic ?
Render priority currently only applies to custom lua sprites. But it is planned to also apply it to internal rendering.
Thanks For the info, for now i'll will use the same chest npc as (A SMB3 Thing)
:(

Also how to make an npc hurting npc ? I'll try to make bullet to go in a right line but I use birdo's eggs but it wont kill npc just
players.

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

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Enjl » Wed Dec 09, 2015 4:53 am

lotus006 wrote:
Kevsoft wrote:
lotus006 wrote:is there a way to make the player walk in front of the graphic ?
Render priority currently only applies to custom lua sprites. But it is planned to also apply it to internal rendering.
Thanks For the info, for now i'll will use the same chest npc as (A SMB3 Thing)
:(

Also how to make an npc hurting npc ? I'll try to make bullet to go in a right line but I use birdo's eggs but it wont kill npc just
players.

Code: Select all

tableOfBirdoEggs = NPC.get(40, -1) -- I think 40 was the birdo egg
for _, v in pairs (tableOfBirdoEggs) do
  tableOfDeath = NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)
  for k, w in pairs (tableOfDeath) do
    if not w.id == --[[use this line to add exceptions to the npc ids you want to kill]] then
      w:kill()
    end
  end
end
Ideas are useless if you can't make them real.
Image

lotus006
Mega Mole
Mega Mole
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Wed Dec 09, 2015 5:05 am

Code: Select all

tableOfBirdoEggs = NPC.get(40, -1) -- I think 40 was the birdo egg
for _, v in pairs (tableOfBirdoEggs) do
  tableOfDeath = NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)
  for k, w in pairs (tableOfDeath) do
    if not w.id == --[[use this line to add exceptions to the npc ids you want to kill]] then
      w:kill()
    end
  end
end
yup 40 is the id for the eggs , but with your code a green koopas wont die or just green shell also :(
but the exception to not kill the npc I want, work but only for the eggs weird,
maybe the eggs can only kill the players.

I have a plan also maybe with trying colliders lua stuff, when the colliders of the eggs touch a npc is dying !
but not sure with colliders

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

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Enjl » Wed Dec 09, 2015 5:11 am

lotus006 wrote:

Code: Select all

tableOfBirdoEggs = NPC.get(40, -1) -- I think 40 was the birdo egg
for _, v in pairs (tableOfBirdoEggs) do
  tableOfDeath = NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)
  for k, w in pairs (tableOfDeath) do
    if not w.id == --[[use this line to add exceptions to the npc ids you want to kill]] then
      w:kill()
    end
  end
end
yup 40 is the id for the eggs , but with your code a green koopas wont die or just green shell also :(
but the exception to not kill the npc I want, work but only for the eggs weird,
maybe the eggs can only kill the players.

I have a plan also maybe with trying colliders lua stuff, when the colliders of the eggs touch a npc is dying !
but not sure with colliders
If you want to test it with any npc, remove the if clause.
Ideas are useless if you can't make them real.
Image

lotus006
Mega Mole
Mega Mole
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Wed Dec 09, 2015 5:13 am

Enjl wrote:
lotus006 wrote:

Code: Select all

tableOfBirdoEggs = NPC.get(40, -1) -- I think 40 was the birdo egg
for _, v in pairs (tableOfBirdoEggs) do
  tableOfDeath = NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)
  for k, w in pairs (tableOfDeath) do
    if not w.id == --[[use this line to add exceptions to the npc ids you want to kill]] then
      w:kill()
    end
  end
end
yup 40 is the id for the eggs , but with your code a green koopas wont die or just green shell also :(
but the exception to not kill the npc I want, work but only for the eggs weird,
maybe the eggs can only kill the players.

I have a plan also maybe with trying colliders lua stuff, when the colliders of the eggs touch a npc is dying !
but not sure with colliders
If you want to test it with any npc, remove the if clause.
it work but only the eggs is killed then it cannot reach else where

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

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Enjl » Wed Dec 09, 2015 5:20 am

lotus006 wrote:
Enjl wrote:

Code: Select all

tableOfBirdoEggs = NPC.get(40, -1) -- I think 40 was the birdo egg
for _, v in pairs (tableOfBirdoEggs) do
  tableOfDeath = NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)
  for k, w in pairs (tableOfDeath) do
    if not w.id == --[[use this line to add exceptions to the npc ids you want to kill]] then
      w:kill()
    end
  end
end
yup 40 is the id for the eggs , but with your code a green koopas wont die or just green shell also :(
but the exception to not kill the npc I want, work but only for the eggs weird,
maybe the eggs can only kill the players.

I have a plan also maybe with trying colliders lua stuff, when the colliders of the eggs touch a npc is dying !
but not sure with colliders
If you want to test it with any npc, remove the if clause.[/quote]

it work but only the eggs is killed then it cannot reach else where[/quote]

OH! Duh, silly me. Add this around w:kill():
if not w.id == 40 then

end
Ideas are useless if you can't make them real.
Image

User avatar
Bibifoc
Cheep-Cheep
Cheep-Cheep
Posts: 17
Joined: Tue Dec 01, 2015 3:05 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Bibifoc » Wed Dec 09, 2015 4:20 pm

Hello !
So I implemented the lua code of the double jump made by tb1024 ( http://engine.wohlnet.ru/forum/viewtopic.php?f=26&t=338 ) in SMBX.
First It was satisfying to see Mario do a double jump, then I saw this double jump was not perfect since you couldn't do a drop jump (I mean : running toward a pit without jumping, falling and then do the jump in the air).
I tried to correct that, it worked, but then there was a problem with vertically moving layers and NPCs which wouldn't allow this drop jump (because I made a condition based on the Y speed of the player). At this point I was blocked, trying random stuff, and I finally decided to delete all the mess I did in the code and go on this topic to ask for help. :)
How are you supposed to make a double jump with the drop jump ? :|
My latest episode Super Blanchon X is available on this topic, check it out : http://www.supermariobrosx.org/forums/v ... 36&t=12412

User avatar
HenryRichard
Ludwig von Koopa
Ludwig von Koopa
Posts: 2846
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Wed Dec 09, 2015 4:49 pm

Still can't figure this out.
HenryRichard wrote:So I'm trying to make this really cool x Bro api where you can have multiple different kinds of bros in a level (hammer bros, goomba bros, and rinka bros in this code). The functionality is there (type what you want them to throw in the message box, disable friendly, and they throw it), but I'd like to give them all different graphics (because I have a feeling that some people will be annoyed when enemies that look the same throw different things). I've tried setting v.animationFrame, but that's not working the way I want. Here's my code:

Code: Select all

function onLoop()
	for k, v in pairs(NPC.get(29, -1)) do
		if(not v.friendly) then
			if(v.msg.str ~= "") then
				if(v.msg.str == "goomba") then
					v.ai4 = 1;
					v.ai5 = 89;
				elseif(v.msg.str == "rinka") then
					v.ai4 = 2;
					v.ai5 = 210;
				end
				v.msg = "";
			end
			v.animationFrame = v.animationFrame + 6 * v.ai4;
			for k,v1 in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do
				if(v1.id == 30 and v1.ai1 == 0) then
					if(v.ai4 == 0) then
						v1.ai1 = 1;
					else
						v1.id = v.ai5;
					end
				end
			end
		end
	end
end
Jesus is my savior.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests