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?
underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: Need help with lua? - LunaLua General Help

Postby underFlo » Sun Apr 17, 2016 3:14 pm

zlakergirl357 wrote:
FanofSMBX wrote:
Mario_and_Luigi_55 wrote:Can I somehow change npc health? For example if I want goomba to die on 3 hits instead of one.
I found a api on the PGEwiki that does this.
then...why are you not telling him what the API is called?
http://wohlsoft.ru/pgewiki/HealthPoint

here's the link for that btw

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 » Sun Apr 17, 2016 3:24 pm

This: http://hastebin.com/iwoyozegal.lua
Causes this:
Image
What's wrong?

cramps-man
Koopa
Koopa
Posts: 15
Joined: Tue Dec 24, 2013 1:13 pm

Re: Need help with lua? - LunaLua General Help

Postby cramps-man » Sun Apr 17, 2016 11:07 pm

PixelPest wrote:This: http://hastebin.com/iwoyozegal.lua
Causes this:
What's wrong?
Well perhaps you should look at the error message? It clearly says the get() function doesn't have a matching overload. AKA, one of the get() functions ur calling has incorrect parameters.

But then how would you double check which one is wrong? A good look at the docs would help you very much.

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

Re: Need help with lua? - LunaLua General Help

Postby lotus006 » Mon Apr 18, 2016 12:08 am

PixelPest wrote:This: http://hastebin.com/iwoyozegal.lua
Causes this:
Image
What's wrong?
You have an error with an lunadll.lua on line 12 in conflict with an callEvent located in the SMW Borderlands folder.
I dont think it's with "iwoyozegal.lua" file.

and why are you using colliders ? you can do it with
Block:collidesWith(Player player)

Returns a number with the side of the collision.
0 = no collision,
1 = Player on top of block,
2 = Player touching right side,
3 = Player touching bottom,
4 = Player touching left side.

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 » Mon Apr 18, 2016 3:10 am

lotus006 wrote: I dont think it's with "iwoyozegal.lua" file.
This is wrong. The error is in that file. That file is a lunadll.lua file, hastebin just gave it a unique ID for hosting.

The problem is that Block.get doesn't work like that. You can't specify a section number for Block.get, so the "-1" there is invalid.

That aside, if you're using colliders you shouldn't be doing it that way. There is a function called "collideBlock" which will be a lot faster and neater. Instead of using a for loop and looping over all the blocks you might want to test against, you can just do:

Code: Select all

if(colliders.collideBlock(colliders.BLOCK_HURT, player)) then
Which will account for every "hurt" block. If you want lava as well you can do this:

Code: Select all

if(colliders.collideBlock(colliders.BLOCK_HURT..colliders.BLOCK_LAVA, player)) then

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon Apr 18, 2016 6:10 am

cramps-man wrote:
PixelPest wrote:This: http://hastebin.com/iwoyozegal.lua
Causes this:
What's wrong?
But then how would you double check which one is wrong? A good look at the docs would help you very much.
You can take a look at the stacktrace which will trace the origin of the error. In this case:
mainV2.lua line 301 called in..
lunadll.lua line 12 in function..
lunadll.lua line 11.

You want to look at the first reference of the file you are currently modifying, which in this case will let you know that the error is a wrong overload in Block.get() in line 12. A quick look at the wiki reveals that Block.get doesn't have a section parameter, like hoeloe said.

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 Apr 18, 2016 6:41 am

Okay. Thanks Hoeloe and Enjl. So if I can't specify the parameters of Block.get(), should I just implement w.id or is there a better way I should do it?

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon Apr 18, 2016 6:51 am

PixelPest wrote:Okay. Thanks Hoeloe and Enjl. So if I can't specify the parameters of Block.get(), should I just implement w.id or is there a better way I should do it?
You misunderstand. Take a look:
http://wohlsoft.ru/pgewiki/LunaLua_glob ... _functions

You can grab by ID, but there's no section parameter.

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 Apr 18, 2016 6:53 am

Enjl wrote:
PixelPest wrote:Okay. Thanks Hoeloe and Enjl. So if I can't specify the parameters of Block.get(), should I just implement w.id or is there a better way I should do it?
You misunderstand. Take a look:
http://wohlsoft.ru/pgewiki/LunaLua_glob ... _functions

You can grab by ID, but there's no section parameter.
Okay. That makes sense. Only saw the first one. Thanks again

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 Apr 18, 2016 4:34 pm

Okay. I'm stumped again. I have a stable code, but it doesn't do what I want it to: http://hastebin.com/dacahiyute.lua

My intention is for the player to be killed any time they touch one of the listed blocks, however they're not. It does work though if they are riding the airship piece. Any ideas?

Nerx
Swooper
Swooper
Posts: 75
Joined: Thu Apr 14, 2016 12:57 pm

Re: Need help with lua? - LunaLua General Help

Postby Nerx » Mon Apr 18, 2016 4:38 pm

PixelPest wrote:Okay. I'm stumped again. I have a stable code, but it doesn't do what I want it to: http://hastebin.com/dacahiyute.lua

My intention is for the player to be killed any time they touch one of the listed blocks, however they're not. It does work though if they are riding the airship piece. Any ideas?
Fixed! Don't use colliders, just use the native Block:collidesWith(player)
Fixed version: http://hastebin.com/wohayehofi.lua

By the way, you don't need to use semicolons in Lua :)

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: Need help with lua? - LunaLua General Help

Postby underFlo » Mon Apr 18, 2016 5:41 pm

There's no problem with using them though.

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 Apr 18, 2016 9:55 pm

Nerx wrote:
Thanks for the help but I already got it fixed up and should have taken it down. The issue was with the hitboxes anyway. I'm going to keep using colliders.lua and my semicolons

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

Re: Need help with lua? - LunaLua General Help

Postby lotus006 » Tue Apr 19, 2016 2:59 am

Nerx wrote:
PixelPest wrote:Okay. I'm stumped again. I have a stable code, but it doesn't do what I want it to: http://hastebin.com/dacahiyute.lua

My intention is for the player to be killed any time they touch one of the listed blocks, however they're not. It does work though if they are riding the airship piece. Any ideas?
Fixed! Don't use colliders, just use the native Block:collidesWith(player)
Fixed version: http://hastebin.com/wohayehofi.lua

By the way, you don't need to use semicolons in Lua :)
Nice some one finally listen me :D thanks Nerx !, I knew it, it will work :P
Earlier quote from me :D :
Block:collidesWith(Player player)

Returns a number with the side of the collision.
0 = no collision,
1 = Player on top of block,
2 = Player touching right side,
3 = Player touching bottom,
4 = Player touching left side.
I have a question about boundaries, is there a way to add a square and create it from a Rectd class and adding more boundaries than 1 at at time ?
thanks, I hope yes because I have few many ideas with this :D

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 » Tue Apr 19, 2016 6:38 am

lotus006 wrote:
Nerx wrote:
PixelPest wrote:Okay. I'm stumped again. I have a stable code, but it doesn't do what I want it to: http://hastebin.com/dacahiyute.lua

My intention is for the player to be killed any time they touch one of the listed blocks, however they're not. It does work though if they are riding the airship piece. Any ideas?
Fixed! Don't use colliders, just use the native Block:collidesWith(player)
Fixed version: http://hastebin.com/wohayehofi.lua

By the way, you don't need to use semicolons in Lua :)
Nice some one finally listen me :D thanks Nerx !, I knew it, it will work :P
Earlier quote from me :D :
Block:collidesWith(Player player)

Returns a number with the side of the collision.
0 = no collision,
1 = Player on top of block,
2 = Player touching right side,
3 = Player touching bottom,
4 = Player touching left side.
collidesWith and colliders are two different things. I'm using colliders.lua, the API, and colliders.collide(obj1, obj2)

Nerx
Swooper
Swooper
Posts: 75
Joined: Thu Apr 14, 2016 12:57 pm

Re: Need help with lua? - LunaLua General Help

Postby Nerx » Tue Apr 19, 2016 8:04 am

PixelPest wrote:
lotus006 wrote:
Nerx wrote: Fixed! Don't use colliders, just use the native Block:collidesWith(player)
Fixed version: http://hastebin.com/wohayehofi.lua

By the way, you don't need to use semicolons in Lua :)
Nice some one finally listen me :D thanks Nerx !, I knew it, it will work :P
Earlier quote from me :D :
Block:collidesWith(Player player)

Returns a number with the side of the collision.
0 = no collision,
1 = Player on top of block,
2 = Player touching right side,
3 = Player touching bottom,
4 = Player touching left side.
collidesWith and colliders are two different things. I'm using colliders.lua, the API, and colliders.collide(obj1, obj2)
Why use a library when there are built in functions to help you?
Glad to see you fixed your problem though.

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 » Tue Apr 19, 2016 8:16 am

Nerx wrote:Why use a library when there are built in functions to help you?
Glad to see you fixed your problem though.
It's simpler and I'm already using colliders to make custom hitboxes anyway

pal4
Swooper
Swooper
Posts: 63
Joined: Wed Dec 23, 2015 7:57 pm

Re: Need help with lua? - LunaLua General Help

Postby pal4 » Tue Apr 19, 2016 6:59 pm

Enjl wrote:
pal4 wrote:Image
local hasGenerated = false;
local ran;

function onLoop()
tableOfBirdo = NPC.get(39, -1);
tableOfBirdoEggs = NPC.get(40, -1);
Text.print(tostring(ran),0,0)

if(tableOfBirdo[1] ~= nil) then
if(tonumber(tableOfBirdo[1]:mem(0xF0, FIELD_DFLOAT)) = 1) then
if(hasGenerated ~= true) then
ran = math.random(0, 2);
hasGenerated = true;
end
if(ran == 2) then
if(table.getn(tableOfBirdoEggs) > 0) then
tableOfBirdoEggs[table.getn(tableOfBirdoEggs)].id = 282;
playSFX(42);
end
end
end
if(tonumber(tableOfBirdo[1]:mem(0xF8, FIELD_DFLOAT)) == 280) then
hasGenerated = false;
end
end
end
http://hastebin.com
How do I use it, and how is it supposed to help?

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Tue Apr 19, 2016 7:19 pm

It's so your code is actually formatted well. You can also use the

Code: Select all

 bbcode but that's limited to like 6 lines at a time. Just pasting it to the page makes it unreadable.

Alagirez
Ludwig von Koopa
Ludwig von Koopa
Posts: 3617
Joined: Tue Dec 02, 2014 2:28 am
Flair: Legalize Awooo!
Pronouns: He/Him/That wolf
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Alagirez » Wed Apr 20, 2016 1:21 am

Is that possible if i add an image into the default HUD with Lunalua?
if yes tell me how to do it pls.....


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 4 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari