Page 14 of 76
Re: Need help with lua? - LunaLua General Help
Posted: Sun Apr 17, 2016 3:14 pm
by underFlo
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
Re: Need help with lua? - LunaLua General Help
Posted: Sun Apr 17, 2016 3:24 pm
by PixelPest
Re: Need help with lua? - LunaLua General Help
Posted: Sun Apr 17, 2016 11:07 pm
by cramps-man
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.
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 12:08 am
by lotus006
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.
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 3:10 am
by Hoeloe
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
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 6:10 am
by Emral
cramps-man wrote:
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.
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 6:41 am
by PixelPest
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?
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 6:51 am
by Emral
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.
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 6:53 am
by PixelPest
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
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 4:34 pm
by PixelPest
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?
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 4:38 pm
by Nerx
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

Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 5:41 pm
by underFlo
There's no problem with using them though.
Re: Need help with lua? - LunaLua General Help
Posted: Mon Apr 18, 2016 9:55 pm
by PixelPest
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
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 19, 2016 2:59 am
by lotus006
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

thanks Nerx !, I knew it, it will work

Earlier quote from me

:
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

Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 19, 2016 6:38 am
by PixelPest
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

thanks Nerx !, I knew it, it will work

Earlier quote from me

:
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)
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 19, 2016 8:04 am
by Nerx
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

thanks Nerx !, I knew it, it will work

Earlier quote from me

:
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.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 19, 2016 8:16 am
by PixelPest
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
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 19, 2016 6:59 pm
by pal4
Enjl wrote:pal4 wrote:
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?
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 19, 2016 7:19 pm
by Emral
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.
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 20, 2016 1:21 am
by Alagirez
Is that possible if i add an image into the default HUD with Lunalua?
if yes tell me how to do it pls.....