Page 25 of 47
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 1:12 am
by lotus006
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

Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 4:04 am
by Kevsoft
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 4:50 am
by lotus006
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 4:53 am
by Emral
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
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:05 am
by lotus006
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
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:11 am
by Emral
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:13 am
by lotus006
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
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:20 am
by Emral
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
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 4:20 pm
by Bibifoc
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 ?

Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 4:49 pm
by HenryRichard
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
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 4:53 pm
by Emral
HenryRichard wrote: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
Can't you directly change the ID depending on the msg string, rather than fiddling about a lot with unused AI offsets?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:02 pm
by HenryRichard
I could, but then a ! would show up when you're near the bro.
Also, is there something wrong with messing with unused AI slots? I don't want to break the game or anything, so I could try to find a workaround if that would happen.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:43 pm
by Emral
There's nothing wrong with it, it just seems like an overly complex way to handle it. Also, wouldn't the "!" appear near the NPC either way?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:44 pm
by HenryRichard
Enjl wrote:There's nothing wrong with it, it just seems like an overly complex way to handle it. Also, wouldn't the "!" appear near the NPC either way?
No, as I'm removing the message.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 5:55 pm
by Emral
Oh, I must've overlooked that line.
Looking over the code a second time, I can't see anything which would cause any issues. I don't know if I'm spouting some nonsense right here, but maybe it's because the key for the hammers is "k", which is also the key for the hammer brothers? Try changing one of the "k"s to "k1" or something.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 6:00 pm
by HenryRichard
Enjl wrote:Oh, I must've overlooked that line.
Looking over the code a second time, I can't see anything which would cause any issues. I don't know if I'm spouting some nonsense right here, but maybe it's because the key for the hammers is "k", which is also the key for the hammer brothers? Try changing one of the "k"s to "k1" or something.
Did that, but they're still not changing their graphics right. What's supposed to happen is, based on the value of ai4, the graphics change. 0 is default, 1 is brown (goomba), and 2 is yellow-orange (rinka).
Here's my graphic file, in case you need to see it:
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 6:06 pm
by Emral
OH I thought you were having trouble changing the npc ID. DERP, sorry. I don't know how I missed that. >.<
What exactly IS it doing that you're displeased with? It looks like it should work just fine.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 6:09 pm
by HenryRichard
Enjl wrote:OH I thought you were having trouble changing the npc ID. DERP, sorry. I don't know how I missed that. >.<
What exactly IS it doing that you're displeased with? It looks like it should work just fine.
It's fine, I've made much bigger mistakes.
This is the problem. A rinka bro (which works perfectly fine) looks like this:
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 6:16 pm
by Emral
My best guess is that the Hammer Bro AI overrides your changes made to animationTimer. I kind of expected a rainbow flashing hammer brother, since he doesn't change his animationFrame every frame normally, but you're setting him to do so.
You could override the hammer bro animation with your own completely, but that seems kind of last-resort-ish.
E: I think I figured it out:
SMBX thinks your hammer brother has 3 frames for each direction, and doesn't load any beyond that, because they "don't exist".
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 09, 2015 6:21 pm
by HenryRichard
Enjl wrote:My best guess is that the Hammer Bro AI overrides your changes made to animationTimer. I kind of expected a rainbow flashing hammer brother, since he doesn't change his animationFrame every frame normally, but you're setting him to do so.
You could override the hammer bro animation with your own completely, but that seems kind of last-resort-ish.
It seems I can't even set the Hammer Bro's animation at all; I'm trying to force it to be 8 and it's not working.
Code: Select all
v.animationTimer = 2;
v.animationFrame = 8;
...any ideas?