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?
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.
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.
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.
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?
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.
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.
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?
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?
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
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.
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.
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.