Page 18 of 76
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 2:51 pm
by pal4
Enjl wrote:pal4 wrote:S1eth wrote:
What's the problem? Your code works.
An issue I see with it is that it only works if there is only a single birdo egg in the world at one time.
You are selecting the last index from tableOfBirdoEggs, which does not guarantee that you will get the most recently spawned egg.
For example, if you pick up an egg, your code will turn that egg in your hand into a fireball.
If you want to keep track of bird eggs' livetime, I suggest using pnpc and giving them a tick counter or something.
Another issue is that you're playing two sound effects at the same time, but I haven't played with lua Sound functions enough to know if there is a way to disable the Birdo's sound effect, or swap it out for the fireball sound effect for that one tick only.
Try this:
http://hastebin.com/lujebotuku.lua
This code ignores birdos completely. It only checks if a new birdo egg has been spawned, and 33% of the time, it turns that egg into a Ludwig fireball.
In other words, it even works with multiple birdos at the same time.
Tried it. no luck.
I'm pretty sure that's not how you get an npc id.
npcID.lua includes a bunch of constants for easy use.
NPCID.BIRDOEGG = 40
I'm starting to think your lunadll.lua file is in the wrong directory. Is it one folder down from where the level file is located?
It is. Folder named 29. I'm naming levels by the order I made them (which is also the order I set them up to play in my world).
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 2:53 pm
by S1eth
pal4 wrote:Enjl wrote:pal4 wrote:
Tried it. no luck.
I'm pretty sure that's not how you get an npc id.
npcID.lua includes a bunch of constants for easy use.
NPCID.BIRDOEGG = 40
I'm starting to think your lunadll.lua file is in the wrong directory. Is it one folder down from where the level file is located?
It is. Folder named 29. I'm naming levels by the order I made them (which is also the order I set them up to play in my world).
Can you post an image of your folder hierarchy? (episode, level, level folder, lunadll file)
What error are you getting? Can you also post an image of the error message?
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 3:08 pm
by pal4
My world folder, as of this morning:

and folder 29:

No error messages. Birdo simply shoots nothing but eggs. Also, I'm having problems displaying the images without bringing them up.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 3:10 pm
by Emral
http://windows.microsoft.com/en-us/wind ... extensions
You lunadll.lua file is named lunadll.lua.txt, but the extension is hidden.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 3:15 pm
by pal4
actually it came out lunadll.lua.lua. If I renamed it at any point is that bad? 'Cause that was my first attempt to show the file extension.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 3:21 pm
by Emral
pal4 wrote:
actually it came out lunadll.lua.lua. If I renamed it at any point is that bad? 'Cause that was my first attempt to show the file extension.
It absolutely needs to be called "lunadll.lua", where ".lua" is the file extension.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Apr 26, 2016 7:12 pm
by pal4
Hey, thank you! after so long, it finally works!

Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 2:37 am
by RhysOwens
S1eth wrote:Mario_and_Luigi_55 wrote:RhysOwens wrote:Has anyone forgotten about me?
I'm not really making levels with LunaLua right now.
I'm messing around with it and experimenting with it so I can get used to it.
The NPCs all take more hits even when I've set the ID to 1 NPC with HealthPoint.lua.
I have same problem.
It's not you. HealthPoint is bugged.
First of all, when you load the API, it automatically sets all NPCs to 3 health. (the creator apparently thought that was a good idea...)
If you don't want that, you'd want to iterate over all NPC ids and call healthPoint.makeNPCNormal(id), but that doesn't work either.
healthPoint.makeNPCNormal is supposed to remove the entry for a specific NPC id from a table, but instead, it removes the value with the
index of the npc id, and then pushes all other indexes in the table forward to fill in the gap.
It's pretty broken.
Here is a fix:
http://hastebin.com/anerequxef.lua
Create a new text file inside your level folder. Copy and paste the hastebin text in there. Rename the file to HealthPoint.lua (remove the .txt extension)
Test it by having the following code in your lunadll.lua file for your level:
Code: Select all
local healthPoint = API.load("HealthPoint");
--healthPoint.healthbar = true; -- optional, use to activate healthbars above NPCs
for _,id in pairs(healthPoint.allNPCs) do
healthPoint.makeNPCNormal(id);
end
healthPoint.setNPCHealth(1, 3);
This makes a goomba (ID 1) take 3 hits to kill. All other enemies are unaffected.
Your code doesn't work mate.
I tested it and I've edited it a few times and no hope.
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 2:38 am
by Mario_and_Luigi_55
RhysOwens wrote:S1eth wrote:Mario_and_Luigi_55 wrote:
I have same problem.
It's not you. HealthPoint is bugged.
First of all, when you load the API, it automatically sets all NPCs to 3 health. (the creator apparently thought that was a good idea...)
If you don't want that, you'd want to iterate over all NPC ids and call healthPoint.makeNPCNormal(id), but that doesn't work either.
healthPoint.makeNPCNormal is supposed to remove the entry for a specific NPC id from a table, but instead, it removes the value with the
index of the npc id, and then pushes all other indexes in the table forward to fill in the gap.
It's pretty broken.
Here is a fix:
http://hastebin.com/anerequxef.lua
Create a new text file inside your level folder. Copy and paste the hastebin text in there. Rename the file to HealthPoint.lua (remove the .txt extension)
Test it by having the following code in your lunadll.lua file for your level:
Code: Select all
local healthPoint = API.load("HealthPoint");
--healthPoint.healthbar = true; -- optional, use to activate healthbars above NPCs
for _,id in pairs(healthPoint.allNPCs) do
healthPoint.makeNPCNormal(id);
end
healthPoint.setNPCHealth(1, 3);
This makes a goomba (ID 1) take 3 hits to kill. All other enemies are unaffected.
Your code doesn't work mate.
I tested it and I've edited it a few times and no hope.
Because api has to be in a LuaScriptsLib folder
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 2:40 am
by RhysOwens
Mario_and_Luigi_55 wrote:RhysOwens wrote:S1eth wrote:
It's not you. HealthPoint is bugged.
First of all, when you load the API, it automatically sets all NPCs to 3 health. (the creator apparently thought that was a good idea...)
If you don't want that, you'd want to iterate over all NPC ids and call healthPoint.makeNPCNormal(id), but that doesn't work either.
healthPoint.makeNPCNormal is supposed to remove the entry for a specific NPC id from a table, but instead, it removes the value with the
index of the npc id, and then pushes all other indexes in the table forward to fill in the gap.
It's pretty broken.
Here is a fix:
http://hastebin.com/anerequxef.lua
Create a new text file inside your level folder. Copy and paste the hastebin text in there. Rename the file to HealthPoint.lua (remove the .txt extension)
Test it by having the following code in your lunadll.lua file for your level:
Code: Select all
local healthPoint = API.load("HealthPoint");
--healthPoint.healthbar = true; -- optional, use to activate healthbars above NPCs
for _,id in pairs(healthPoint.allNPCs) do
healthPoint.makeNPCNormal(id);
end
healthPoint.setNPCHealth(1, 3);
This makes a goomba (ID 1) take 3 hits to kill. All other enemies are unaffected.
Your code doesn't work mate.
I tested it and I've edited it a few times and no hope.
Because api has to be in a LuaScriptsLib folder
It was in the LuaScriptsLib folder but the code he gave us still didn't work.

Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 6:26 am
by S1eth
RhysOwens wrote:Mario_and_Luigi_55 wrote:RhysOwens wrote:
Your code doesn't work mate.
I tested it and I've edited it a few times and no hope.
Because api has to be in a LuaScriptsLib folder
It was in the LuaScriptsLib folder but the code he gave us still didn't work.

It works for me. And I assume it works for Mario_and_Luigi_55 as well?
RhysOwens wrote:It was in the LuaScriptsLib folder but the code he gave us still didn't work.

Why did you put it there? Those were not the instructions I gave you. If you didn't do that, how will I know if you followed all the other steps correctly?
You can put the file either in your level folder, or the LuaScriptsLib folder.
API.load will prioritize local files in the level folder, and if it doesn't find the API there, it'll look in the LuaScriptsLib folder.
It would be nice if you could tell me what error you're getting. I can't do much with "doesn't work".
Make sure the file is called "HealthPoint.lua".
Enable file extensions. Maybe your file is called "HealthPoint.lua.txt".
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 12:14 pm
by TurtleJosh52
When I open it, it says
"The program can't start because MSVCP140.dll is missing from your
computer. Try reinstalling the program to fix this problem."
Help!
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 12:15 pm
by Emral
run the vredist.exe in your smbx folder
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 1:33 pm
by RhysOwens
S1eth wrote:RhysOwens wrote:Mario_and_Luigi_55 wrote:
Because api has to be in a LuaScriptsLib folder
It was in the LuaScriptsLib folder but the code he gave us still didn't work.

It works for me. And I assume it works for Mario_and_Luigi_55 as well?
RhysOwens wrote:It was in the LuaScriptsLib folder but the code he gave us still didn't work.

Why did you put it there? Those were not the instructions I gave you. If you didn't do that, how will I know if you followed all the other steps correctly?
You can put the file either in your level folder, or the LuaScriptsLib folder.
API.load will prioritize local files in the level folder, and if it doesn't find the API there, it'll look in the LuaScriptsLib folder.
It would be nice if you could tell me what error you're getting. I can't do much with "doesn't work".
Make sure the file is called "HealthPoint.lua".
Enable file extensions. Maybe your file is called "HealthPoint.lua.txt".
I loaded HealthPoint.lua and my code worked
but your fixing code didn't.
The error I get is: bad argument #1 to 'pairs' (table expected, got nil)
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 27, 2016 1:50 pm
by S1eth
RhysOwens wrote:
I loaded HealthPoint.lua and my code worked
but your fixing code didn't.
The error I get is: bad argument #1 to 'pairs' (table expected, got nil)
That means you are not using the updated HealthPoint.lua file I provided you with.
You have to load the api I uploaded or it's not going to work.
I am working on an API that requires starman.lua, and I noticed that starman saves the state "inStar" inside a global variable and only works for player 1. Both of these are rather inconvenient to say the least.
In regards to SMBX2.0, will I still be using starman.lua or will that be part of the global lua API functions. (or included in the game itself like in 1.4.x ?)
Or should I update starman.lua myself to work for 2-player mode (and maybe upload it somewhere?)
Help!
Posted: Thu Apr 28, 2016 2:52 pm
by TurtleJosh52
When I open up LunaLua this appears:
"Using GDI renderer. so some advanced LunaDLL effects may not be present in
some levels.
Could not use OpenGL Renderer because:
Missing EXT_framebuffer_object"
Halp
Re: Help!
Posted: Thu Apr 28, 2016 3:41 pm
by Kevsoft
TurtleJosh52 wrote:When I open up LunaLua this appears:
"Using GDI renderer. so some advanced LunaDLL effects may not be present in
some levels.
Could not use OpenGL Renderer because:
Missing EXT_framebuffer_object"
Halp
This basically means that your graphics card is too old, or your graphics driver is not properly installed.
Try updating/repairing your graphics card driver installation.
Re: Need help with lua? - LunaLua General Help
Posted: Fri Apr 29, 2016 12:18 pm
by pal4
Not really a problem, just a quick question. If I wanted to make my own Lua file, how do I do so?
Re: Need help with lua? - LunaLua General Help
Posted: Fri Apr 29, 2016 12:20 pm
by Emral
You make a file with the extension .lua
Re: Need help with lua? - LunaLua General Help
Posted: Fri Apr 29, 2016 12:43 pm
by Zant
Is it possible to create a portal system(like in Mari0)with LunaLua?