LunaLua Offical Thread - SMBX Usermod Framework

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?

Shall I steam some LunaLua live development?

Yes
200
92%
No
17
8%
 
Total votes: 217
Rixitic
Spike
Spike
Posts: 250
Joined: Sat Dec 12, 2015 1:00 am
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Rixitic » Wed Apr 13, 2016 10:38 pm

Hey everyone! Creator of cinematX, textblox, paralX and other such infamous ambitious lua libraries here with a bit of a PSA about a problem that's recently come to my attention: selfish message parsing.

Back when cinematX was in its' early stages I decided to try and utilize npcs' message text to allow users to define unique properties for each npc in the editor in an effort to make the library a bit more user-friendly. Though getting the library to a stable release has been somewhat of an uphill battle since v0.7, the message tags still became a key feature of cinematX... and now, as I understand it, the feature seems to be catching on.

If I had the foresight to anticipate this I would've designed and implemented cinematX's message parsing differently, as the format of a cinematX message doesn't take into account other libraries that may want to use the npc message text as well. Any npcs that have cinematX properties in their message text can't have properties for any other library that uses this kind of system, and vice versa. And the more we use such "selfish" message parsing systems, the more libraries we'll have that are fundamentally incompatible with one another.

The folks behind Lunalua, SMBX 2.0 and the PGE are working on phasing out the .lvl format in favor of the more flexible .lvlx format, which would allow more unique data for npcs, but as I understand it there's a lot of work involved in that so it's a long-term goal. In the meantime, we need a standardized method of parsing message text that:
A) Allows for all libraries to store data in the message string without conflicting with one another,
B) Allows users to define both a regular message string and parsed data,
C) Has a clear syntax that makes it easy to differentiate between regular message text and extra data,
D) Is as user-friendly as possible

I'm working on a possible candidate for this, tentatively called npcParse. It parses lua tables from NPC message strings and copies the information to each npc's pnpc data. The library should satisfy criteria A through C, though I'm not so sure about D.

npcParse-standard message strings would be formatted as nested tables, with a "newMsg" key corresponding to the replacement message text and everything else being stored in the pnpc data as-is, like so:

Code: Select all

-- Message string
{newMsg="Hi there.", particles={spawnrate=5, name="robert", waffle=true}, cinematx={key="goopasib2", icon=1, scene="cutscene_TestQuest3"}, customlotus={bullets=999}, rinkas={and so on}}

-- Output
pnpcref.data.particles.spawnrate --> 5
pnpcref.data.particles.name --> "robert"
pnpcref.data.particles.waffle --> true
pnpcref.data.cinematx.key --> "goopasib2"
pnpcref.data.cinematx.icon --> 1
pnpcref.data.cinematx.scene --> "cutscene_TestQuest3"
pnpcref.data.cinematx.scene --> "cutscene_TestQuest3"
pnpcref.data.customlotus.bullets --> 999
If the library doesn't detect the initial "{", it treats the text like a regular message, and if newMsg isn't specified the npc will behave as if it has no message. But again, I don't know how readable this syntax is for most folks, so it may not be the best candidate.

But whether it be npcParse or some other system, the sooner we have a standard, the better. If too many libraries start using selfish parsing and then end up having to switch to standardized parsing for compatibility with other libraries, that will break levels that use those libraries.

Now, what if you don't want to use a standardized parsing system? Well, it's your library, you have the right to code it however you want. Just keep in mind that you'd be preventing users from combining your library with others' and you'd be perpetuating a bad programming practice for other potential lua devs. And maybe that's not so big an issue for smaller, more specialized projects, but it's probably not something we should use in official SMBX 2.0 code or other higher-profile libraries. As it is, I'll be switching cinematX over to the new system as soon as it's been established. This will break every cinematX level that uses npc message tags, but I don't see much of a way around that.

This has been rockythechao with the Super-Serious Alarmist Evening News Time Report Thingy. My deepest apologies for essentially starting the SMBX equivalent of Y2K, and I sincerely hope these concerns of mine end up being overblown.

EDIT: Another possible option is that we could have a system that's similar to npcParse but instead of keeping all the library properties in the message text they could be stored as JSON in an external file, and the message text would just have a reference key and replacement message:

Code: Select all

-- Message text in the editor
{id="boss", newMsg="Hi there."}

-- [level folder]/npcdata.json
{
  "boss": {
    "particles":  {
      "name": "robert"
    }
    "cinematX":  {
      "icon": 1
    }
    "customlotus": {
      "bullets": 999
    }
  }
}

lotus006
Spike
Spike
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Fri Apr 15, 2016 1:57 am

@ Kevsoft

I need to ask you if is possible to make SpriteOverride (class) with level priority like Graphics.drawImageWP ?
I have alot of idea if it can be possible sometime :D

Or the sprites of the player with level priority should be easier :D

thanks

Kevsoft
Flurry
Flurry
Posts: 374
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Fri Apr 15, 2016 2:12 am

lotus006 wrote: I need to ask you if is possible to make SpriteOverride (class) with level priority like Graphics.drawImageWP ?
SpriteOverride only represents the bridge between custom images and the images bound to items/npcs/...
You can grab the image of an NPC with:

Code: Select all

local npcImg = Graphics.sprites.npc[1].img
With this code you grab the image of NPC-id 1. This image-object can be used for Graphics.drawImageWP.

lotus006
Spike
Spike
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Fri Apr 15, 2016 2:17 am

Kevsoft wrote:
lotus006 wrote: I need to ask you if is possible to make SpriteOverride (class) with level priority like Graphics.drawImageWP ?
SpriteOverride only represents the bridge between custom images and the images bound to items/npcs/...
You can grab the image of an NPC with:

Code: Select all

local npcImg = Graphics.sprites.npc[1].img
With this code you grab the image of NPC-id 1. This image-object can be used for Graphics.drawImageWP.
oh ok, sorry I did a mistake, I mean more if we can override any NPC-id 1 to level priority only without using drawImageWP then. like make passing an npc behind other sprite.

Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Quantumenace » Fri May 27, 2016 7:33 pm

Particles.lua 1.2.5 still has a critical bug on lines 140 and 193:

Code: Select all

local mag = self.falloff(1-d)*self.strength;
Trying to use a particle force field with a falloff crashes Lua because it interprets that as trying to call self.falloff as a function. Even if you add a * there, the math doesn't make sense.

If the falloff is the fraction of the full strength that the field has at its edge, shouldn't it be:

Code: Select all

local mag = (1-d*(1-self.falloff))*self.strength;
Is there a newer version than 1.2.5?
Also:
Kevsoft wrote: You can grab the image of an NPC with:

Code: Select all

local npcImg = Graphics.sprites.npc[1].img
With this code you grab the image of NPC-id 1. This image-object can be used for Graphics.drawImageWP.
Trying to use that variable as an image in Graphics.drawImageToSceneWP causes a "no matching overload" error. Would updating Lua help?

Hoeloe
Foo
Foo
Posts: 1463
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Hoeloe » Sat May 28, 2016 5:37 am

Quantumenace wrote: Trying to use a particle force field with a falloff crashes Lua because it interprets that as trying to call self.falloff as a function. Even if you add a * there, the math doesn't make sense.
Uhhh... self.falloff IS a function. That's the point. It's the falloff function for the field. Of course it's not going to work if you put a number there.

Take a look at the documentation:
falloff
Grad/function:optional

The falloff function of the field. 1 maps to the centre of the field, 0 maps to the edge of the field. Defaults to squared falloff.
It's designed to allow you to determine how your field falls off, giving you a lot of control over the behaviour of the field.

Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Quantumenace » Sat May 28, 2016 2:37 pm

Ugh... sorry. I wasn't used to being able to put functions in tables. Thanks.

Edit: the "split" function in particles.lua writes to the global variable "i" instead of a local one. Is that intended? I had inconsistent bugs with other things because I accidentally was reading from that, and if it was nil the problem would have been obvious right away.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9722
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Emral » Thu Jun 02, 2016 3:14 pm

so we got a new official mascot of lunalua
Image
which leads me to believe we need a new logo?!?!?!?!?
Image

(rip copyright)

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Fri Jun 03, 2016 7:11 am

Enjl wrote:so we got a new official mascot of lunalua
Image
which leads me to believe we need a new logo?!?!?!?!?
Image

(rip copyright)
Yes. Yes. Yes

Wohlstand
Van De Graf
Van De Graf
Posts: 2005
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Wohlstand » Fri Jun 03, 2016 7:42 am

PixelPest wrote:
Enjl wrote:so we got a new official mascot of lunalua
Image
which leads me to believe we need a new logo?!?!?!?!?
Image

(rip copyright)
Yes. Yes. Yes
Nice dragon (or who is this creature?), but SVG vector graphics required (Inkscape program suggested) (current logo in SVG is here)

From my side I suggesting wolf, bat or other creature which compatible with night and moon.
Anyway, we would have a collect some sort of logos from different people and let's vote for best variant?

Quantix
Ripper II
Ripper II
Posts: 333
Joined: Tue Jan 26, 2016 5:04 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Quantix » Fri Jun 03, 2016 8:19 am

Wohlstand wrote:Nice dragon (or who is this creature?)?
One of the new legendaries from Pokemon Sun & Moon. It's a bat.

Wohlstand
Van De Graf
Van De Graf
Posts: 2005
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Wohlstand » Fri Jun 03, 2016 8:23 am

Quantix wrote:
Wohlstand wrote:Nice dragon (or who is this creature?)?
One of the new legendaries from Pokemon Sun & Moon. It's a bat.
Okay, Enjl told me that in chat too, so, I remembered that ;-)

Hoeloe
Foo
Foo
Posts: 1463
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Hoeloe » Fri Jun 03, 2016 2:40 pm

Wohlstand wrote:
Quantix wrote:
Wohlstand wrote:Nice dragon (or who is this creature?)?
One of the new legendaries from Pokemon Sun & Moon. It's a bat.
Okay, Enjl told me that in chat too, so, I remembered that ;-)
The reason it's come up is that the English name of that Pokemon is "Lunala", which you can see bears a striking resemblance to "LunaLua".

Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Quantumenace » Sat Jun 04, 2016 8:40 pm

I was able to find the array of block frame values. I haven't tested it with many block types yet, but it looks like you can force non-animated blocks to animate by changing the frame index value for that block type.

Code: Select all

	blockframepointer=mem(0xB2BEA0,FIELD_DWORD)
	blockid = 1
	blockframe = mem(blockframepointer+(blockid-1)*2,FIELD_WORD)
	mem(blockframepointer+(blockid-1)*2,FIELD_WORD,(blockframe+1)%4)
For example, running that with onCameraUpdate makes block type 1 flash through a 4-frame image very quickly (it just flickers if you don't give it a 4-frame image). Giving it a loop with a frame speed of your choice would be easy.

ivanmegafanboy
Blooper
Blooper
Posts: 175
Joined: Wed Aug 12, 2015 11:47 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby ivanmegafanboy » Tue Jun 14, 2016 10:42 am

What is the difference between these both "target base game" choices and which should I download? :
-SMBX 1.3.0.2 hexed
-SMBX 1.3.0.2 vanilla+launcher
I chosed the vanilla one, but it didn't work. Probably because I don't know how to properly install it. The SMBX version I have is the one that you can download in the front page of this site: the 1.3.1.0 version
By the way, does LunaLua support the lunadll.txt files? Because that is the only "luna" thing I know how to use. I know it's deprecated, but it is simple enough for me to semi-comprehend.
And also, what are those things called source codes, as a casual SMBX user should I download them?

Thanks a lot for your kindness and keep with the good work :)

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Tue Jun 14, 2016 10:26 pm

I would try the hexed version, but make a backup of your current smbx.exe in case the new one gets deleted. If it is deleted, put back your old smbx.exe and try the vanilla + launcher version. To install you just extract the files and drop them in your SMBX root (the folder with worlds, graphics, music, smbx.exe, etc.). LunaLua does kinda support the lunadll.txt files, though I've had minor issues with them in the past. You're way better off learning Lua, because it's much more powerful, easier to use, less complicated, not depreciated, and also actually used by some professional companies (and very similar to others), so you can actually make money in the future with Lua. Finally, source code is the raw, uncompiled data of LunaLua and can't be used unless you compile it. As a casual user you definitely don't need it, and even more serious users don't need it unless theywant to add some function to LunaLua and somewhat know how to.

ivanmegafanboy
Blooper
Blooper
Posts: 175
Joined: Wed Aug 12, 2015 11:47 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby ivanmegafanboy » Sat Jun 18, 2016 3:46 am

HenryRichard wrote:I would try the hexed version, but make a backup of your current smbx.exe in case the new one gets deleted. If it is deleted, put back your old smbx.exe and try the vanilla + launcher version. To install you just extract the files and drop them in your SMBX root (the folder with worlds, graphics, music, smbx.exe, etc.). LunaLua does kinda support the lunadll.txt files, though I've had minor issues with them in the past. You're way better off learning Lua, because it's much more powerful, easier to use, less complicated, not depreciated, and also actually used by some professional companies (and very similar to others), so you can actually make money in the future with Lua. Finally, source code is the raw, uncompiled data of LunaLua and can't be used unless you compile it. As a casual user you definitely don't need it, and even more serious users don't need it unless theywant to add some function to LunaLua and somewhat know how to.
Thanks a lot for your help, and also for the information:
1.- I better tried to download the hexed version with the complete game, so now i have two SMBX :)
2.- I don't think I will have the time and patience to learn some LUA, I don't even study programming or something related to computers :/ Just one question: how do you make a Lua file? Wich program do you use to create that type of file?
3.- Ok, so I better not care about the source code, thanks again, and have a nice day. :D

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Jun 18, 2016 2:09 pm

ivanmegafanboy wrote:
Create a text file --> Right click (not on the file though) --> Select "Show File Extensions" (may be in Settings, Details, Properties, or on the immediate menu) --> Right click on your text file --> Select "Rename" --> Change .txt to .lua --> Open with Notepad, Notepad++, or a similar program to modify.

HVMetal
Snifit
Snifit
Posts: 234
Joined: Tue Dec 29, 2015 9:44 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HVMetal » Mon Jun 27, 2016 6:47 am

My LunaLua is not working for some reason. It says that MSVCP140.dll can't be found and to re-install the whole thing but I get the same error all over the time even after the re-instalation.

S1eth
Swooper
Swooper
Posts: 54
Joined: Sat Apr 23, 2016 10:44 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby S1eth » Mon Jun 27, 2016 6:51 am

HVMetal wrote:My LunaLua is not working for some reason. It says that MSVCP140.dll can't be found and to re-install the whole thing but I get the same error all over the time even after the re-instalation.
Try executing vcredist_x86.exe in your SMBX directory.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari