What is this?

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

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?
BananaCat
Bot
Bot
Posts: 50
Joined: Fri Dec 30, 2016 6:20 pm

What is this?

Postby BananaCat » Tue Feb 07, 2017 4:17 pm

So, I have a code which will make the background seem more alive, but, I cant get to using it because of the error
"unexpected symbol near '='"

Here is the code:

Code: Select all

move = Layer.get("BGOM")
function onLoop()
	if Layer.speedY(move) < 1 then
		Layer.speedY(move) = -1
	end
	if Layer.speedY(move) > 1 then
	    Layer.speedY(move) = move:Layer.speedY / 2
	end
	if Layer.speedY(move) < 0 then
		Layer.speedY(move) = move:Layer.speedY * 2
    end
    if Layer.speedY(move) < -5 then
        Layer.speedY(move) = 5
    end
end

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

Re: What is this?

Postby Emral » Tue Feb 07, 2017 4:26 pm

I'm not convinced the code you're presenting is even lua.

BananaCat
Bot
Bot
Posts: 50
Joined: Fri Dec 30, 2016 6:20 pm

Re: What is this?

Postby BananaCat » Tue Feb 07, 2017 5:39 pm

Enjl wrote:I'm not convinced the code you're presenting is even lua.
...

Im going to ignore that. Im a bit new (I just started a little while ago) so...

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

Re: What is this?

Postby PixelPest » Tue Feb 07, 2017 8:29 pm

You need to read the LunaLua documentation and follow it. Layer.get() returns a table of layers. To get that specific layer you can open the layers tab and start counting down through the list of layers (starting with Default as 0 and then count up by ones as you move down). Remember as well that when setting variables like this you'll want to put local before the variable name. So, your first line should look like this:

Code: Select all

local move = Layer(#); 
This actually sets move to the actual layer object.

In terms of using onLoop(), it's deprecated, so use onTick() instead.

Now with the weird part of your code. Layer.speedY has no arguments so no brackets should be there at all. Furthermore, Layer is a class, so in Layer.speedY you need to replace "Layer" with your layer object "move". Therefore, this should look like:

Code: Select all

if move.speedY < 1 then 
When setting the value later as well, change "move:Layer.speedY" to the same thing. Your code also might work better if you change the parts of this code where you have an "end" followed by an "if" to just "elseif". It will make sure that no more than one of those values is set to the speedY each tick (which is most likely what you want)

BananaCat
Bot
Bot
Posts: 50
Joined: Fri Dec 30, 2016 6:20 pm

Re: What is this?

Postby BananaCat » Wed Feb 08, 2017 4:39 pm

PixelPest wrote:-- snip --

Thanks!!!! You taught me alot of things that I didnt know about programming in SMBX! Thank you so much!

Im very new, so I couldnt comprehend what a "Field" was..

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

Re: What is this?

Postby Hoeloe » Wed Feb 08, 2017 7:01 pm

BananaCat wrote:
PixelPest wrote:-- snip --

Thanks!!!! You taught me alot of things that I didnt know about programming in SMBX! Thank you so much!

Im very new, so I couldnt comprehend what a "Field" was..
It also looks to me like you're getting confused by the version numbers.

SMBX 2.0 is an extension of SMBX 1.3. It's made by different developers from the original, but since it expands the original engine, it's as close to an "official" new version as you can get. SMBX 2.0 uses LunaLua as a scripting interface, which is where the bulk of its flexibility comes from.

There is also a program called SMBX38A, sometimes referred to as 1.4. This is NOT based on the original SMBX engine, and is in fact an entirely different game engine (which is why a lot of people prefer to call it SMBX38A or 38A, rather than 1.4, to avoid confusion). This has a bunch of new things, but the vast majority are hard-coded into the engine. It also has backwards compatibility issues, as it has different physics from SMBX. 38A also has a limited scripting interface, using a language called Teascript-vb. Teascript-vb is IN NO WAY related to LunaLua, and is substantially less powerful and less flexible.

From what you've been posting, it looks like you're confusing 38A with an earlier version of 2.0 (and as a by-product of that, confusing Teascript-vb with an earlier version of LunaLua), where in fact they are entirely separate things. You should make sure that you are working with LunaLua, not Teascript-vb, if you are working in SMBX 2.0.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari