'=' expected near 'if' problem

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?
PlumberGraduate
Fighter Fly
Fighter Fly
Posts: 38
Joined: Sat Jun 14, 2014 11:39 am

'=' expected near 'if' problem

Postby PlumberGraduate » Wed Sep 28, 2016 11:34 am

So, I tried to make a switch palace, and found this script from the official PGE wiki, so it probably should work, but it doesn't. I'm just getting this error: '=' expected near 'if'. Is it a bug? I can't find any errors. :x

The script

Code: Select all

local myGlobalData = Data(Data.DATA_WORLD, "switchPalace")
 
if myGlobalData == nil then
    myGlobalData:set("exampleGlobalSwitch", tostring(1))
	myGlobalData:save()
end
 
function onEvent(eventname)
    if eventname == "globalBarrierKill" then
        myGlobalData:set("exampleGlobalSwitch", tostring(0))
        myGlobalData:save()
    end
end
 
local ranInitialCheck = false;
local barrierData = myGlobalData:get("exampleGlobalSwitch");
 
function onLoop()
    if ranInitialCheck == false then
        if barrierData = tostring(0) then
            triggerEvent("globalBarrierKill")
        end
    ranInitialCheck = true;
    end
end

Waddle
Tellah
Tellah
Posts: 1583
Joined: Sun Sep 07, 2014 4:59 am
Flair: hi!!!
Pronouns: He/Him

Re: '=' expected near 'if' problem

Postby Waddle » Wed Sep 28, 2016 11:59 am

The error message should specify in what line the error occurs, which might help you find the error.

EDIT: nvm, got it. In the last few lines of the code you're saying "if barrierData = tostring(0) then" whereas it should be "if barrierData == tostring(0) then". That might solve the problem. Also function onLoop() is effectively a worse function onTick() so I recommend you switch those too.

PlumberGraduate
Fighter Fly
Fighter Fly
Posts: 38
Joined: Sat Jun 14, 2014 11:39 am

Re: '=' expected near 'if' problem

Postby PlumberGraduate » Wed Sep 28, 2016 12:38 pm

The error still occurs even though I fixed those two errors. And sorry for not specifying on what line the error happens. It happens in the third line. Also, the LunaWorld.lua also contains "smb3card = loadAPI("smb3goalcard");", but I don't think it matters.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari