Forum

> > CS2D > Scripts > Lua Error 'then' expected near '='
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Error 'then' expected near '='

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Lua Error 'then' expected near '='

Louie
User Off Offline

Zitieren
So i'm trying to make this lua for my map but i always get this error:
IMG:https://i.imgur.com/6KAAY9Q.png

heres my code
1
2
3
4
5
if entity= 7,5 typename=Info_Dom_Point int=2
then parse('spawnobject 8 8 5 0 0 2')
elseif entity= 7,5 typename=Info_Dom_Point int=1
then parse('spawnobject 8 8 5 0 0 1')
end
what did i do wrong? I'm still newbie at this scripting stuff

alt Re: Lua Error 'then' expected near '='

DC
Admin Off Offline

Zitieren
To explain the problem a bit more:

A single = is an assignment (variable will have the value afterwards):
1
variable = value

Double = is a comparison (will be true if variable currently has that value):
1
if variable == value then ...

So simply remember this:
Always use == in if-conditions!

alt Re: Lua Error 'then' expected near '='

Dousea
User Off Offline

Zitieren
This may help you.
1
2
3
4
5
6
7
if (entity(7, 5, "typename") == "Info_Dom_Point") then
	local team = entity(7, 5, "int0")
	
	if (team > 0) then
		parse("spawnobject 8 8 5 0 0 " .. team)
	end
end
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht