Need help with lua? - LunaLua General Help

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?
User avatar
Nat The Porcupine
Swooper
Swooper
Posts: 122
Joined: Tue Nov 10, 2015 2:55 pm
Current Project: Nothing ATM

Re: Need help with lua? - LunaLua General Help

Postby Nat The Porcupine » Mon Mar 21, 2016 4:27 pm

Silly question but... How does one remove a collider from existence? I have an API for a custom enemy that I'm working on and I can't figure out how to remove the colliders I attached to it after it dies.

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1210
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Mon Mar 21, 2016 4:28 pm

Mario_and_Luigi_55 wrote: Why? The / is flipped it should be \
This is incorrect. Both / and \ will work, but \ is also the escape character (allowing characters like \n for newline), so to use it as a string it needs to be a double slash: \\. It's also worth noting that particles.lua is NOT included in the SMBX 2.0 beta by default (the update will, however, include it) because it was developed after the beta was released. It is likely that you simply do not have the "particles" folder included in your LuaScriptsLib folder.
Nat The Porcupine wrote:Silly question but... How does one remove a collider from existence? I have an API for a custom enemy that I'm working on and I can't figure out how to remove the colliders I attached to it after it dies.
You simply stop referencing the collider. Once you have no more references to a collider, Lua will destroy it for you. All you need to do is stop testing it, and set all the variables storing the colliders to nil.

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: Need help with lua? - LunaLua General Help

Postby HenryRichard » Mon Mar 21, 2016 4:32 pm

@Mario_and_Luigi_55: Try putting Misc.resolveFile() around the path.
Last edited by HenryRichard on Mon Mar 21, 2016 5:58 pm, edited 1 time in total.
Jesus is my savior.

User avatar
Nat The Porcupine
Swooper
Swooper
Posts: 122
Joined: Tue Nov 10, 2015 2:55 pm
Current Project: Nothing ATM

Re: Need help with lua? - LunaLua General Help

Postby Nat The Porcupine » Mon Mar 21, 2016 5:14 pm

Hoeloe wrote: You simply stop referencing the collider. Once you have no more references to a collider, Lua will destroy it for you. All you need to do is stop testing it, and set all the variables storing the colliders to nil.
Thanks. That helped me track down the issue I was having.

P.S. This API of yours is simply brilliant!

User avatar
WerewolfGD
Wart
Wart
Posts: 3268
Joined: Tue Dec 02, 2014 2:28 am
Flair: Legalize Awooo!
Current Project: Howling
Chat Username: Alagirez
Contact:

Re: Need help with lua? - LunaLua General Help

Postby WerewolfGD » Mon Mar 21, 2016 11:36 pm

Pls tell me how to change the fog color... (the fog comes from Particles.lua)
Spoiler: show
I mean fog this
Image
Yea... I'm back, but with different view.

Known also as Camacho or Harvey36Dice.
Also a furry

Image
Awooo!
If you want to talk with me, go here : Alagirez#2056

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 1:39 am

Hoeloe wrote:
Mario_and_Luigi_55 wrote: Why? The / is flipped it should be \
This is incorrect. Both / and \ will work, but \ is also the escape character (allowing characters like \n for newline), so to use it as a string it needs to be a double slash: \\. It's also worth noting that particles.lua is NOT included in the SMBX 2.0 beta by default (the update will, however, include it) because it was developed after the beta was released. It is likely that you simply do not have the "particles" folder included in your LuaScriptsLib folder.
Nat The Porcupine wrote:Silly question but... How does one remove a collider from existence? I have an API for a custom enemy that I'm working on and I can't figure out how to remove the colliders I attached to it after it dies.
You simply stop referencing the collider. Once you have no more references to a collider, Lua will destroy it for you. All you need to do is stop testing it, and set all the variables storing the colliders to nil.

I have particles in LuaScriptsLib and when I use \\ it gives me :

Debug
C:\Programy\SMBX 2 Open Beta \ LuaScriptsLitAparticles.lua:574: Could not open particle descriptor file C:\Programy\SMBX 2 Open Beta\LuaScriptsLib\particles\p_snow.ini


(Path to p_snow.ini: "C:\Programy\SMBX 2 Open Beta\LuaScriptsLib\particles\p_snow.ini"


and // - Can't fint file
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1210
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Mar 22, 2016 4:39 am

Mario_and_Luigi_55 wrote: I have particles in LuaScriptsLib and when I use \\ it gives me :

Debug
C:\Programy\SMBX 2 Open Beta \ LuaScriptsLitAparticles.lua:574: Could not open particle descriptor file C:\Programy\SMBX 2 Open Beta\LuaScriptsLib\particles\p_snow.ini


(Path to p_snow.ini: "C:\Programy\SMBX 2 Open Beta\LuaScriptsLib\particles\p_snow.ini"


and // - Can't fint file
Please note that "particles.lua" is not the same thing as the "particles" folder. There should be a folder named "particles" in your LuaScriptsLib folder, with files such as "p_snow.ini" in it.

As I said before, \\ will give you the same result as /, but // makes no sense, as / isn't an escape character, which is why that doesn't work.

I suggest you try re-installing particles.
Camacho wrote:Pls tell me how to change the fog color... (the fog comes from Particles.lua)
Spoiler: show
I mean fog this
Image
You can do this by copying the ini file into your level folder (from LuaScriptsLib/Particles) and adding a line into it. You need the hexadecimal colour code for the colour you want to use, and then add this line to the ini file:

Code: Select all

col=0xFF0000FF
This will tint it red, but if you fill in the hexadecimal colour code like this:

Code: Select all

col=0x######FF
You will get any colour you like. It's also worth noting that when you copy the file into your level folder, you will need to change the path of the ini file in your code, as it will no longer be "particles/p_fog.ini", but just "p_fog.ini".

Alternatively, if you don't want to copy the ini file, you can do it from Lua too. When you create your fog particle system, just call:

Code: Select all

fogEmitter:SetParam("col",particles.ColFromHexRGB(0x######));
Which will do exactly the same thing, but without copying the ini file.

User avatar
Wohlstand
Boom Boom
Boom Boom
Posts: 1779
Joined: Tue Feb 11, 2014 4:44 pm
Flair: 狐エンジニア
Current Project: Moondust (PGE Project)
Chat Username: Wohlstand#4881
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Wohlstand » Tue Mar 22, 2016 5:29 am

HVMetal wrote:Hello!
So I decided to download LunaLua too... but when I wanted to test my level I got this error message:
Spoiler: show
Image
Version of PGE is 0.3.1.8

Thanks for the help!
I see you placed PGE into folder with non-ASCII path, so, I fixed that bug and PGE can be placed in any folder with no dependency.
https://github.com/Wohlhabend-Networks/ ... 15b3abe7f5
PGE Project, my Media and supported projects: show
Support me on the Patreon
Image

PGE Project
PGE Project SMBX Topic
PGE Project Official Site and forums
Download fresh experimental builds HERE!

I'm support:
Lowser's Conquest by Sednaiur

Image
P.S. I don't like huge signatures which would be annoying, therefore I put huge content into spoilers

Lukas Old Account
Pokey
Pokey
Posts: 229
Joined: Sat Mar 28, 2015 3:01 pm
Current Project: Expedition Neon

Re: Need help with lua? - LunaLua General Help

Postby Lukas Old Account » Tue Mar 22, 2016 5:54 am

Greetings, I was having the idea of having a boss with a hp bar, but unfortunatly, I have no clue where to start, not even the slightest idea of how making the npc react to the hp bar. I need some help.
bye

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 6:54 am

Hoeloe wrote:
Mario_and_Luigi_55 wrote: I have particles in LuaScriptsLib and when I use \\ it gives me :

Debug
C:\Programy\SMBX 2 Open Beta \ LuaScriptsLitAparticles.lua:574: Could not open particle descriptor file C:\Programy\SMBX 2 Open Beta\LuaScriptsLib\particles\p_snow.ini


(Path to p_snow.ini: "C:\Programy\SMBX 2 Open Beta\LuaScriptsLib\particles\p_snow.ini"


and // - Can't fint file
Please note that "particles.lua" is not the same thing as the "particles" folder. There should be a folder named "particles" in your LuaScriptsLib folder, with files such as "p_snow.ini" in it.

As I said before, \\ will give you the same result as /, but // makes no sense, as / isn't an escape character, which is why that doesn't work.

I suggest you try re-installing particles.



Still doesn't work i tried copying to level folder. Could not open particle descriptor file.

Code: Select all

local particles = loadAPI("particles");
 
local effect = particles.Emitter(0, 0, Misc.resolveFile("p_snow.ini"));
effect:AttachToCamera(Camera.get()[1]);
 
function onCameraUpdate()
    effect:Draw();
end
Lua file

Code: Select all

grad_1={0,0.2,1},{0,1,0}
colTime={0,0.5,1},{0xFFFFFF00,0xFFFFFF99,0xFFFFFF00}
limit=1000
rate=500:2000
xOffset=-800:800
yOffset=-600:600
rotation=40:45
speedX=-1:-200
speedY=1:250
texture=part_default.png
scale=0.25:0.5
lifetime=1

snow.ini (And yes, I copied texture file)
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Tue Mar 22, 2016 6:57 am

Also make sure that you're using API.load instead of loadAPI

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 7:08 am

PixelPest wrote:Also make sure that you're using API.load instead of loadAPI

Attempt to index global 'API' (a nil value)
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1210
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Mar 22, 2016 7:09 am

Mario_and_Luigi_55 wrote: Still doesn't work i tried copying to level folder. Could not open particle descriptor file.
Hoeloe wrote: I suggest you try re-installing particles.

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 7:13 am

Hoeloe wrote:
Mario_and_Luigi_55 wrote: Still doesn't work i tried copying to level folder. Could not open particle descriptor file.
Hoeloe wrote: I suggest you try re-installing particles.
I did that and still nothing...


It shows the error is in particles.lua in line 574 , so this:

Code: Select all

		p,s = parseFile(source);
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1210
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Mar 22, 2016 7:35 am

Mario_and_Luigi_55 wrote:
PixelPest wrote:Also make sure that you're using API.load instead of loadAPI

Attempt to index global 'API' (a nil value)
AH. If this is your issue you probably have an outdated LunaLua version. Update it.

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 7:41 am

Hoeloe wrote:
Mario_and_Luigi_55 wrote:
PixelPest wrote:Also make sure that you're using API.load instead of loadAPI

Attempt to index global 'API' (a nil value)
AH. If this is your issue you probably have an outdated LunaLua version. Update it.
Now it's fine. Well, SMBX 2.0 has outdated Lua apparently.
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1210
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Mar 22, 2016 7:44 am

Mario_and_Luigi_55 wrote: Now it's fine. Well, SMBX 2.0 has outdated Lua apparently.
Yes it does. There were a lot of changes made to LunaLua since the first beta was released. The updated version will have an up-to-date version.

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 11:20 am

Can I somehow save at the beggining of the level the powerup of the player and give it back to him after finishing the level?
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Tue Mar 22, 2016 11:31 am

Mario_and_Luigi_55 wrote:Can I somehow save at the beggining of the level the powerup of the player and give it back to him after finishing the level?
Use the parameter player.powerup

User avatar
Mario_and_Luigi_55
Mega Mole
Mega Mole
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm
Current Project: Super Mario Bros Adventure

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Mar 22, 2016 11:38 am

PixelPest wrote:
Mario_and_Luigi_55 wrote:Can I somehow save at the beggining of the level the powerup of the player and give it back to him after finishing the level?
Use the parameter player.powerup

Yes, but at the beggining I have to save the powerup. I made a custom powerup but the script is terrible I guess, because it uses powerup box. That's why I don't know how to save the powerup at the start of the level. Would that work

Code: Select all

function onStart()
local savedpowerup=player.powerup
player.powerup=0
END
Image
Image

My best levels:
Goomba Lands - 5/10
Stars of the trees - 5.5/10
Koopa Cave - 3.42
Green Grass Hill - 3.42
Grassy Valley - 5.47


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests