Page 1 of 1

Event equivalents in Lua?

Posted: Sun Dec 11, 2016 9:37 am
by darkhog
Does anyone have an example that shows Lua equivalents of events? Basically Lua code that does what each and every event does. Would help me greatly learning SMBX-specific stuff (no problem with learning Lua itself as I've used it previously, but need some examples and time to become accustomed with smbx-specific stuff)

Re: Event equivalents in Lua?

Posted: Sun Dec 11, 2016 12:13 pm
by PixelPest
I'd recommend taking a look at these:

http://wohlsoft.ru/pgewiki/Section_(class)
http://wohlsoft.ru/pgewiki/Layer_(class)
http://wohlsoft.ru/pgewiki/LunaLua_glob ... _functions

These classes can basically cover most of the event stuff.

And then there's also:

Code: Select all

triggerEvent(string eventname)

Re: Event equivalents in Lua?

Posted: Sun Dec 11, 2016 10:24 pm
by MECHDRAGON777
PixelPest wrote:I'd recommend taking a look at these:

http://wohlsoft.ru/pgewiki/Section_(class)
http://wohlsoft.ru/pgewiki/Layer_(class)
http://wohlsoft.ru/pgewiki/LunaLua_glob ... _functions

These classes can basically cover most of the event stuff.

And then there's also:

Code: Select all

triggerEvent(string eventname)
In theory, could you construct a 22nd section with the constructure?

Re: Event equivalents in Lua?

Posted: Sun Dec 11, 2016 10:26 pm
by PixelPest
I don't think so. It's not really a "constructor", it's more acts as a lasso I guess you could say. It returns the object of something already existing

Re: Event equivalents in Lua?

Posted: Mon Dec 12, 2016 9:12 pm
by darkhog
I was more talking about Lua equivalents to actual event commands, e.g. showing text box in Lua or changing section settings/moving layers. So I can code in Lua nice cutscenes without the need to "chain" events just to show few text messages one after another, then move a layer (maybe it was an option in the old editor, but in the new one, you can only set one message per event, it seems).

Re: Event equivalents in Lua?

Posted: Mon Dec 12, 2016 9:14 pm
by PixelPest
Read what I said above. That's all there except for showing the message box which you can find in LunaLua Global Functions if you search PGE Wiki. I think it's Text.messageBox() but don't call me on it

Re: Event equivalents in Lua?

Posted: Tue Dec 13, 2016 4:53 am
by Kevsoft
darkhog wrote:I was more talking about Lua equivalents to actual event commands, e.g. showing text box in Lua or changing section settings/moving layers. So I can code in Lua nice cutscenes without the need to "chain" events just to show few text messages one after another, then move a layer (maybe it was an option in the old editor, but in the new one, you can only set one message per event, it seems).
Most of them are global functions like
  • Text.showMessageBox(string)
  • Layer.get(string layerName)
  • Player.keyPressing*****
to name a few. I recommend using the search-function at the wiki. Almost all of the event functionalities are implemented and available in lua.

Re: Event equivalents in Lua?

Posted: Thu Dec 15, 2016 7:30 pm
by darkhog
I see, thanks. Maybe I'll do such index on the wiki listing each event command and how to do it in Lua for anyone in future who might want to know it, once I'll figure it out myself. Thank you.