I have tried to hack a lua script (my first) and found the following problem. I do not understand the error. Can someone tell me what I need to do to correct this error?
From the info.txt log......
Failed to load: my_unit_Marker.lua ([string "C:\Program Files\Spring\LuaUI\Widgets\my_unit_Marker.lua"]:62: ')' expected near '=')
line 62 of the script......
if ((UnitDefs[uDefID].name) = 'armbrtha') then
local x, y, z = spGetUnitPosition(uID)
spMarkerAddPoint(x, y, z, "Bertha")
end
script error '=' and ')' I don't get it....
Moderator: Moderators
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: script error '=' and ')' I don't get it....
Need two equals signs.
Code: Select all
if ((UnitDefs[uDefID].name) == 'armbrtha') then
Re: script error '=' and ')' I don't get it....
= assigns a value, it usually returns true when the assigning was successful. But since Lua is typeless, all assigns succeed
== compares two values, returns true if equal.
== compares two values, returns true if equal.
-
- Posts: 2
- Joined: 02 Dec 2009, 04:52
Re: script error '=' and ')' I don't get it....
Thanks! That did it.
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: script error '=' and ')' I don't get it....
Not in lua, hence the context error, which turned out to be a good thing in this case.Beherith wrote:= assigns a value, it usually returns true when the assigning was successful.
Re: script error '=' and ')' I don't get it....
In which languages does it actually do that?
In the ones I know it either returns nothing and it's illegal to use it where a result is expected (like in Lua), or it returns the value that was assigned (like in C/C++/C#, etc.) so you can assign the same value to multiple variables at once.
In the ones I know it either returns nothing and it's illegal to use it where a result is expected (like in Lua), or it returns the value that was assigned (like in C/C++/C#, etc.) so you can assign the same value to multiple variables at once.
Re: script error '=' and ')' I don't get it....
well, in c/c++ anything not 0 means true so you are both correct i think.
Re: script error '=' and ')' I don't get it....
According to that interpretation assigning 0 to some variable can never be successful 
