Page 10 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Tue Apr 05, 2016 1:20 am
by underFlo
API.load is pretty much the same as loadSharedAPI afaik, except you can also make it work like loadAPI if you set a bool as the argument (even though I don't recall what it was exactly).

The main reason API.load is preferred is cleaner code - optimally, all the functions should either be methods, defined in the script itself or inside of a table that is loaded by default. That's why functions likely getNPC are deprecated.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Apr 05, 2016 2:34 pm
by Zeus guy
Ok so it's me again yay.
After some hours of frustration and not getting anything done, I decided to stop coding and start... coding something else. So I remembered something I read on this thread:
Hoeloe wrote:3) When in the reversed section, apply some code using LunaLua's Capture Buffers to flip the screen upside down.
Now I've spent some time searching on google and the only thing I've found is that it wasn't possible 5 months ago. So, is it possible now? And if that's the case, how?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Apr 05, 2016 10:40 pm
by PixelPest
Zeus guy wrote:Ok so it's me again yay.
After some hours of frustration and not getting anything done, I decided to stop coding and start... coding something else. So I remembered something I read on this thread:
Hoeloe wrote:3) When in the reversed section, apply some code using LunaLua's Capture Buffers to flip the screen upside down.
Now I've spent some time searching on google and the only thing I've found is that it wasn't possible 5 months ago. So, is it possible now? And if that's the case, how?
Have you tried searching the documentation?

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 2:11 am
by Zeus guy
PixelPest wrote:
Zeus guy wrote:Ok so it's me again yay.
After some hours of frustration and not getting anything done, I decided to stop coding and start... coding something else. So I remembered something I read on this thread:
Hoeloe wrote:3) When in the reversed section, apply some code using LunaLua's Capture Buffers to flip the screen upside down.
Now I've spent some time searching on google and the only thing I've found is that it wasn't possible 5 months ago. So, is it possible now? And if that's the case, how?
Have you tried searching the documentation?
Yeah, but I didn't find anything.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 3:45 am
by Kevsoft
Zeus guy wrote:
PixelPest wrote:
Zeus guy wrote:Ok so it's me again yay.
After some hours of frustration and not getting anything done, I decided to stop coding and start... coding something else. So I remembered something I read on this thread:

Now I've spent some time searching on google and the only thing I've found is that it wasn't possible 5 months ago. So, is it possible now? And if that's the case, how?
Have you tried searching the documentation?
Yeah, but I didn't find anything.
CaputureBuffer API is not in the latest release build. It is only available in the dev-builds.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 5:27 pm
by pal4
Quantumenace wrote:You have a LunaSavedVars file almost as new as the lunadll file, which implies that the script is being run and saving that.

Do you happen to have more than one onLoop() function? I think they will overwrite each other if you try to make more than one with the same name.


Edit: General question: What's the difference between API.load and the other API loading functions? API.load isn't mentioned at all on the wiki.
Just one such function. So what you're saying is it should work if I remove the LunaSavedVars file from the folder?

Do lulalua codes only function in an actual game? so far I've only tried it in the editor and the menu screen indicates compatibility with the included lunalua set.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 5:41 pm
by PixelPest
pal4 wrote:Do lulalua codes only function in an actual game? so far I've only tried it in the editor and the menu screen indicates compatibility with the included lunalua set.
All Lua codes will work for both the editor and episodes

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 5:51 pm
by lotus006
Kevsoft wrote:
Zeus guy wrote:
PixelPest wrote: Have you tried searching the documentation?
Yeah, but I didn't find anything.
CaputureBuffer API is not in the latest release build. It is only available in the dev-builds.
this ?

Code: Select all

   LUAHELPER_DEF_CLASS_SMART_PTR_SHARED(CaptureBuffer, std::shared_ptr)
                    .def(constructor<int, int>())
                    .def("__eq", &LuaProxy::luaUserdataCompare<LuaProxy::Graphics::LuaImageResource>)
                    .def("captureAt", &CaptureBuffer::captureAt),

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 6:00 pm
by Quantumenace
pal4 wrote:
Quantumenace wrote:You have a LunaSavedVars file almost as new as the lunadll file, which implies that the script is being run and saving that.

Do you happen to have more than one onLoop() function? I think they will overwrite each other if you try to make more than one with the same name.


Edit: General question: What's the difference between API.load and the other API loading functions? API.load isn't mentioned at all on the wiki.
Just one such function. So what you're saying is it should work if I remove the LunaSavedVars file from the folder?

Do lulalua codes only function in an actual game? so far I've only tried it in the editor and the menu screen indicates compatibility with the included lunalua set.
No, I didn't say that at all. My point is that something saved that file there, presumably a lunalua script.

You can test if lunadll.lua loads by putting

Text.print()

as the first line. If it loads the script at all it will immediately error out because of incorrect arguments.

The legacy editor should use lunalua scripts. I've never gotten the new editor to test correctly. Is the folder you posted the folder for the level? If so, why are there .lvl files in there?

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 6:34 pm
by Nat The Porcupine
Does anyone know how to use the onEvent function properly? It doesn't seem to be working for me.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 06, 2016 6:51 pm
by Hoeloe
Nat The Porcupine wrote:Does anyone know how to use the onEvent function properly? It doesn't seem to be working for me.
You're likely making the mistake of using the argument as a constant, like this:

Code: Select all

function onEvent("Level - Start")
  --Do something
end
This is incorrect and will not work.

Arguments to functions are like local variables. They essentially are variables, that only exist inside that function, so to use onEvent properly, you need to treat the argument as a variable containing the name of the event that just fired, for example:

Code: Select all

function onEvent(eventName)
  if(eventName == "Level - Start") then
    --Do something
  end
end
This is correct and will work. It's also important to know that you cannot have multiple copies of the same event, so you should instead make use of if and elseif statements to account for different events.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 9:02 am
by Mario_and_Luigi_55
How can I set Birdo's life from 3 to different level? For example if I would want to make Birdo take 5 hits to die instead of 3.

I tried this in lunadll.txt (I took it from this page: http://wohlsoft.ru/pgewiki/LunaDLL_Tutorial)

Code: Select all

#1
AT_SetHits,39,1,9,0,-2,0
#END
That's what the page says about this code:
NPCs in this game don't have health. They have a hit counter. So a mother brain with 9 hits has 1 hit left. A birdo with 1 hit has 2 hits left. A mother brain with -10 hits has 20 hits left. Only NPCs that can normally get hit more than once can have their hit counts manipulated. To find the NPC ID of an NPC, check the graphics folder or a list of NPC IDs. Currently there's no way to specify one single NPC among many that may be in your level. The command runs for every NPC of the type you specify. This goes for all NPC and block commands actually.
What it gives me? Syntax error. Pretty helpful description btw (irony).

And I did try text file with a lot of different numbers, but still Birdo needs 3 hits to die.

Is it just me or Lua is annoying with it's perfect descriptions of errors?

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 9:36 am
by Hoeloe
Mario_and_Luigi_55 wrote: I tried this in lunadll.txt (I took it from this page: http://wohlsoft.ru/pgewiki/LunaDLL_Tutorial)

Code: Select all

#1
AT_SetHits,39,1,9,0,-2,0
#END

This isn't Lua. This is LunaDLL Autocode, which is totally unsupported and highly recommended that you avoid.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 9:52 am
by Nat The Porcupine
Hoeloe wrote:
Mario_and_Luigi_55 wrote: I tried this in lunadll.txt (I took it from this page: http://wohlsoft.ru/pgewiki/LunaDLL_Tutorial)

Code: Select all

#1
AT_SetHits,39,1,9,0,-2,0
#END

This isn't Lua. This is LunaDLL Autocode, which is totally unsupported and highly recommended that you avoid.
I agree with HoeLoe. Stay away from autocode. However, seeing as you probably lack the necessary knowledge to recode this in lua from scratch, I would recommend checking out the How To: Autocode to LunaLua tutorial on the PGE wiki. That should help you convert most autocode into useable LunaLua, but I can't exactly guarantee you that it will always work.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 8:22 pm
by Circle Guy
Hey, how come my episode names won't show up in play mode? :?: :?

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 8:46 pm
by PixelPest
Circle Guy wrote:Hey, how come my episode names won't show up in play mode? :?: :?
How is this a LunaLua issue? Unless you have code to show the episode's names during gameplay they won't. If you've tried, seeing the code you have would really help

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 10:25 pm
by Circle Guy
PixelPest wrote:
Circle Guy wrote:Hey, how come my episode names won't show up in play mode? :?: :?
How is this a LunaLua issue? Unless you have code to show the episode's names during gameplay they won't. If you've tried, seeing the code you have would really help
It's a lua issue because I'm using the Lua version and it only has this issue.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 07, 2016 10:29 pm
by HenryRichard
Did you set the .wld file's name in the editor?

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 08, 2016 6:21 am
by Circle Guy
HenryRichard wrote:Did you set the .wld file's name in the editor?
Yeah, but I mean NO world names are showing up. Even the Invasion 2!

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 08, 2016 6:52 am
by PixelPest
Circle Guy wrote:
HenryRichard wrote:Did you set the .wld file's name in the editor?
Yeah, but I mean NO world names are showing up. Even the Invasion 2!
Oh. You mean on the main screen. I don't think you could really fix that easily. Have you actually checked to see if the .wld files have names inside the file?