Page 23 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Sat May 14, 2016 6:27 pm
by PixelPest
MECHDRAGON777 wrote:I should learn more about tables.
http://lua-users.org/wiki/StringsTutorial
http://lua-users.org/wiki/TablesTutorial

Re: Need help with lua? - LunaLua General Help

Posted: Sat May 14, 2016 8:31 pm
by Emral
HenryRichard wrote:Is there a way to use multi-channel music?
No. You can try playing one of the tracks through a sound channel, but sound tends to cut off and loading such a big sound effect can cause the game to hiccup for a second.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 16, 2016 7:55 am
by NoodlesButt
I downloaded LunaLua, full installation, vanilla+launcher but when I try to run the smbx application I get an application error.
"The application was unable to start correctly (0xc000007b). Click OK to close the application."

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 16, 2016 8:09 am
by Mario_and_Luigi_55
NoodlesButt wrote:I downloaded LunaLua, full installation, vanilla+launcher but when I try to run the smbx application I get an application error.
"The application was unable to start correctly (0xc000007b). Click OK to close the application."
The error appears if you haven't got C++ configuration package. There should be file named something like vcredist.exe or something like that. Run it.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 16, 2016 8:11 am
by NoodlesButt
Mario_and_Luigi_55 wrote: The error appears if you haven't got C++ configuration package. There should be file named something like vcredist.exe or something like that. Run it.
Oh, that simple. :)
Thanks!

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 16, 2016 10:15 pm
by Ghostly_Guy
Is there a code you can use to trigger a cheat when you collect [npc]?
As in, can you make an item that, after you collect it, triggers supermario4 and then immediately redigitiscool?

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 16, 2016 10:22 pm
by PixelPest
Ghostly_Guy wrote:Is there a code you can use to trigger a cheat when you collect [npc]?
As in, can you make an item that, after you collect it, triggers supermario4 and then immediately --?
http://wohlsoft.ru/pgewiki/SMBX_Fields

I'm also working on an API for cheats that in the future will make this even simpler

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 16, 2016 11:58 pm
by Ghostly_Guy
PixelPest wrote:
Ghostly_Guy wrote:Is there a code you can use to trigger a cheat when you collect [npc]?
As in, can you make an item that, after you collect it, triggers supermario4 and then immediately --?
http://wohlsoft.ru/pgewiki/SMBX_Fields

I'm also working on an API for cheats that in the future will make this even simpler
Sorry, but that didn't really work for me. I entered this as a test:

Code: Select all

function onStart()
  Defines.cheat_supermario4 = TRUE
  Defines.player_hasCheated = FALSE
end
Correct me if I'm wrong, but I thought that this would, when I started the level, activate the supermario4 cheat.
But nothing happened.
Am I doing something wrong? The code Defines.cheat_supermario4 wasn't one of the Defines listed in the website your link went to.

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 1:09 am
by Emral
If it's not on the list you can't activate it. The hook just doesn't exist yet.

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 3:24 am
by Hoeloe
Enjl wrote:If it's not on the list you can't activate it. The hook just doesn't exist yet.
Not just that, but "TRUE" is not the same thing as "true". When programming, case matters.

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 10:44 am
by Ghostly_Guy
Enjl wrote:If it's not on the list you can't activate it. The hook just doesn't exist yet.
However, is there a way to activate cheats not on the list?
Hoeloe wrote:Not just that, but "TRUE" is not the same thing as "true". When programming, case matters.
Okay, that was absolutely my fault. I changed it.

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 10:55 am
by S1eth
Ghostly_Guy wrote:
Enjl wrote:If it's not on the list you can't activate it. The hook just doesn't exist yet.
However, is there a way to activate cheats not on the list?
Hoeloe wrote:Not just that, but "TRUE" is not the same thing as "true". When programming, case matters.
Okay, that was absolutely my fault. I changed it.
You can use

Code: Select all

Misc.cheatBuffer("moneytree"); -- example cheat


to activate cheats.
But be careful.

Setting the cheatBuffer makes the game think you were typing for example "moneytre" and exactly this frame, you type the last "e".

So you can not just type:

Code: Select all

Misc.cheatBuffer("myCheat1");
Misc.cheatBuffer("myCheat2");


If you do that, you overwrite the cheatBuffer before the game has a chance to execute your first cheat, so only the second cheat will be activated. You can only execute one cheat per frame this way.
You could use eventu to schedule another cheat exactly 1 frame later if you want.

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 6:01 pm
by PixelPest
How do I get the event I want to use in Event.cancelled?

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 6:41 pm
by HenryRichard
It should be in the function's arguments.

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 6:53 pm
by PixelPest
HenryRichard wrote:It should be in the function's arguments.
Wait. Is event referring to, like, function onTick(), function onLoop(), etc.?! If so nm my question

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 7:11 pm
by Ghostly_Guy
Well, now that my first question is answered (thank you S1eth, Enjl, Hoeloe, and Pixelpest), I have a second, follow-up question.
Is it possible to make it so that consuming a power-up that came from a ?-Block triggers Lua code?

Re: Need help with lua? - LunaLua General Help

Posted: Tue May 17, 2016 11:47 pm
by HenryRichard
PixelPest wrote:
HenryRichard wrote:It should be in the function's arguments.
Wait. Is event referring to, like, function onTick(), function onLoop(), etc.?! If so nm my question
the event refers to the thing that's happening in SMBX, i.e. an enemy being killed. But you can only get them in a few LunaLua events, like onNPCKill and onEventDirect. (At least, I'm pretty sure that's how it works)

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 18, 2016 3:53 am
by Emral
eventObj in the arguments for onNPCKill and onEventDirect refers to the killing of the NPC and execution of the event respectively. They're cancellable through lua with eventObj.cancelled = true

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 18, 2016 6:38 am
by PixelPest
Enjl wrote:eventObj in the arguments for onNPCKill and onEventDirect refers to the killing of the NPC and execution of the event respectively. They're cancellable through lua with eventObj.cancelled = true
Oh. That makes sense. Thanks

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 18, 2016 8:37 pm
by NoodlesButt
Is there a method to activate the yellow yoshi stomp when the player isn't on the mount?
So for example when the player lands the thwomp sound is played and nearby enemies are killed.