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
darkhog
Dolphin
Dolphin
Posts: 87
Joined: Sat Dec 10, 2016 11:17 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby darkhog » Mon Dec 26, 2016 5:37 pm

Yeah, maybe. But that's awful lot of code to write, code that should be part of LunaLua to begin with, either as core or as API to make coder's life maximally easy. Remember, not being able to move a layer by specific amount of pixels/blocks on the first try made Little Joe quit SMBX.

When designing a tool or API we always need to think about Little Joe, an imaginative ten year old boy who just want to create cool stuff. He doesn't want dumbed down tools, but he doesn't want overly complicated either, when the same thing can be made more accessible with a bit of work on tool creator's/API designer side. Little Joe wants to be able to do cool things fast, while making ceiling of the tool so high that he'll won't feel constrained in what he can do.

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 » Mon Dec 26, 2016 5:45 pm

"Little Joe" can divide by 65 and use layers and events to move his blocks. And it would literally be maybe 20 lines of code to write

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PersonNamedUser » Fri Jan 06, 2017 1:44 pm

I know i'm bringing this up again after over a year, but does anyone know how to make a currency system that
increases you money count anytime you pick up coins, blue coins, red coins, dragon coins, rupees, sonic rings,
etc.? I'd really appreciate it.

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 Jan 06, 2017 1:59 pm

MosaicMario wrote:I know i'm bringing this up again after over a year, but does anyone know how to make a currency system that
increases you money count anytime you pick up coins, blue coins, red coins, dragon coins, rupees, sonic rings,
etc.? I'd really appreciate it.
There's actually a library in 2.0 that will do this pretty much for you. Take a look at raocoin2.lua. You probably want a mem currency.

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PersonNamedUser » Fri Jan 06, 2017 2:39 pm

Hoeloe wrote:
MosaicMario wrote:I know i'm bringing this up again after over a year, but does anyone know how to make a currency system that
increases you money count anytime you pick up coins, blue coins, red coins, dragon coins, rupees, sonic rings,
etc.? I'd really appreciate it.
There's actually a library in 2.0 that will do this pretty much for you. Take a look at raocoin2.lua. You probably want a mem currency.
Well, how do mem currencies work? like how do i know what to put in to the mem?

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 Jan 06, 2017 2:57 pm

MosaicMario wrote: Well, how do mem currencies work? like how do i know what to put in to the mem?
They read off memory locations. If you take a look here, you can see a list of memory locations, and one of those is the coin counter.

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PersonNamedUser » Fri Jan 06, 2017 2:59 pm

Hoeloe wrote:
MosaicMario wrote: Well, how do mem currencies work? like how do i know what to put in to the mem?
They read off memory locations. If you take a look here, you can see a list of memory locations, and one of those is the coin counter.
Yeah, i see it, but when i inserted these 2 codes:

Code: Select all

raocoin = loadSharedAPI("raocoin2");
dragoncoins = raocoin.registerCurrency(274, true, 472, 66);
I got an error message, what do i add to the script for it to work in a project?

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 Jan 06, 2017 3:47 pm

MosaicMario wrote:

Code: Select all

raocoin = loadSharedAPI("raocoin2");
dragoncoins = raocoin.registerCurrency(274, true, 472, 66);
I got an error message, what do i add to the script for it to work in a project?
What was your error message?

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PersonNamedUser » Fri Jan 06, 2017 3:56 pm

Hoeloe wrote:
MosaicMario wrote:

Code: Select all

raocoin = loadSharedAPI("raocoin2");
dragoncoins = raocoin.registerCurrency(274, true, 472, 66);
I got an error message, what do i add to the script for it to work in a project?
What was your error message?
Actually, i think i was just doing something wrong, it's working correctly now. but i want to know how to do this with regular coins
and for the value to be carried over to other stages.

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 Jan 06, 2017 4:08 pm

The link Hoeloe posted tells exactly how to do 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 Jan 06, 2017 4:10 pm

MosaicMario wrote: Actually, i think i was just doing something wrong, it's working correctly now. but i want to know how to do this with regular coins
and for the value to be carried over to other stages.
If you read the wiki page just one line further, the code to do it for regular coins is literally right there.

As for getting it to save between levels, you need to use either the onExitLevel event or the coins:onCollect event. These will allow you to save the currency value either when you exit the level, or when you collect a coin.

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PersonNamedUser » Fri Jan 06, 2017 4:20 pm

Hoeloe wrote:
MosaicMario wrote: Actually, i think i was just doing something wrong, it's working correctly now. but i want to know how to do this with regular coins
and for the value to be carried over to other stages.
If you read the wiki page just one line further, the code to do it for regular coins is literally right there.

As for getting it to save between levels, you need to use either the onExitLevel event or the coins:onCollect event. These will allow you to save the currency value either when you exit the level, or when you collect a coin.
The Counter is there, but it won't go past 100 and resets whenever it reaches 100. How do i make it go past that?
where do you insert onCollect?

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PersonNamedUser » Fri Jan 06, 2017 7:14 pm

I actually have a question unrelated to the currency system, how can you make a hammer bro throw hammers more rapidly?
does someone know how to make a script for that?

xXAndytubeXx
Bit
Bit
Posts: 76
Joined: Wed Aug 16, 2017 5:50 pm
Flair: luigi is numero uno

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby xXAndytubeXx » Thu Dec 07, 2017 2:07 pm

Kevsoft wrote:I recently had the idea if I should stream some LunaLua live development. Just say if you would be interested or not.
Because I get often ask where you can download LunaLua, I make a own topic about it.

LunaLua is a addition to lunadll which adds the script language lua. The problem with Autocode (the lunadll-language) is the lack of flexibility that it has (such as the way it lacks custom functions, variables,... etc). With this we don't need any hardcoded code for complex ideas anymore.

So first of all: What is lua?
Lua is an actual script language, which supports custom functions, variables and much more. The script type is something like JavaScript + Visual Basic



Download
Most recent Documentation
Source Code
LunaDLL for lua reference & example page (outdated since v0.2.7, but the examples still working)
LunaLua Tutorial
You might want to google other lua tutorials too.

How to install:
1. Check "Full Installation", check all checkboxes and download the most recent package.
2. Extract the package and profit!

How to update:
1. Check "Only Update" and replace the LuaScriptLib and lunadll.dll in your existing installation.

Example to see if LunaLua is working:
Spoiler: show

Code: Select all

function onLoop()
  printText("PLAYER x="..tostring(player.x).." y="..tostring(player.y), 30, 60)
end
Video Showcase:
Spoiler: show




Which lua-libs can I access?

Code: Select all

string.*
math.*
table.*
debug.*
os.* --Limited (only time/date works), because of security reasons
Reference to the lua libs:
string.*
math.*
table.*
debug.* (probably not needed)
os.* Note: Only os.clock, os.time and os.date works. The rest is limited due security reasons.
1. Sorry for quoting, I just wanted help with something.
2. How do I use LunaLUA in SMBX 1.4.4?

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 » Thu Dec 07, 2017 2:53 pm

You don't 1.4.4 isn't technically a version of SMBX and uses a very poorly-made language called Teascript-VB. LunaLua is only for 1.3.0.2 and SMBX2

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

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Quantumenace » Mon Jan 08, 2018 4:23 am

What is it about colliders.Poly that takes up so much CPU time? Do all the nested functions and vector methods contribute lots of overhead compared to the actal math? I had to make my own polygon-circle collision function to minimize chances of lag.

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 » Mon Jan 08, 2018 12:22 pm

Quantumenace wrote:What is it about colliders.Poly that takes up so much CPU time? Do all the nested functions and vector methods contribute lots of overhead compared to the actal math? I had to make my own polygon-circle collision function to minimize chances of lag.
I highly doubt yours is more efficient. Either that or it's not actually working like you think it is.

The problem is that there really isn't a good solution to the problem of arbitrary polygon collision detection. There ARE reasonable solutions to the slightly more constrained problem of convex polygon collisions.

The reason colliders.Poly takes up a lot of CPU time is that it, at construction time, triangulates the polygon. This allows any arbitrary polygon (as long as its edges don't cross over) to be split into a set of convex polygons which can be used for collision detection.

The downside to this is that calling "colliders.Poly" every frame is very slow (but note that's the construction function, not the collision functions).

That's why you're not encouraged to do that.

Instead, you're encouraged to use colliders.Poly once, store the result, and then transform it by moving, rotating, scaling, etc.

The only reason you'd need to call colliders.Poly again would be if the shape were changing in real-time in a non-simple way - at which point you'd be better off either using your own function, or managing a set of triangle colliders yourself.

In short, it's very likely you're just using it wrong.

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

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Quantumenace » Mon Jan 08, 2018 6:54 pm

I should have clarified that I meant the collision algorithm rather than the definining of the collider. Weirdly the profiler lag graph seems to spike the first time the other collider gets close, and it isn't as bad afterwards, but all those tests can still take a decent amount of CPU power afterwards.

Yes, my method is limited to convex polygons, but it appears to work perfectly. It uses a variant of the line-point distance problem to check if the circle intersects an edge instead of turning both objects into triangles.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 4 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari