Page 1 of 1

Syntax

PostPosted: 01 Sep 2017, 13:22
by petrmenzel
Can someone explain why does not work this syntax?
  Code:
... 21 procedure nameofprocedure(aPlayer: Integer); 22 begin 23 LU_ID24 := States.ClosestUnit(aPlayer,1,1,24); 24 if (States.UnitAt(7,1) = LU_ID24) then aStuff1 := 2; 25 begin 26 _code_ 27 end; 28 end; ...
if States.Some() then variable := number

Thx for answer.

Re: Syntax

PostPosted: 01 Sep 2017, 13:28
by Strangelove
if you put the "aStuff1 := 2;" after "begin" it should work.

Like this:
  Code:
... 21 procedure nameofprocedure(aPlayer: Integer); 22 begin 23 LU_ID24 := States.ClosestUnit(aPlayer,1,1,24); 24 if (States.UnitAt(7,1) = LU_ID24) then 25 begin 26 aStuff1 := 2; 27 _code_ 28 end; 29 end; ...

Re: Syntax

PostPosted: 01 Sep 2017, 16:52
by petrmenzel
But it is not same.
My: if Status is true so the variable is some number
Your: variable is the Status

Re: Syntax

PostPosted: 01 Sep 2017, 17:33
by Strangelove
Well, I don't really know what you wanna do and I am not good with scripting/programming terminology, but doesn't it yield the same result tho?
Maybe some other scripter can help you out here.

Re: Syntax

PostPosted: 01 Sep 2017, 18:17
by petrmenzel
Difference:
My: If States = 1 then variable should be 2 (1 -> 2)
You: If States = 1 then variable should be 1 (1 = 1)

Re: Syntax

PostPosted: 03 Sep 2017, 07:24
by Rey
  Code:
if (States.UnitAt(7,1) = LU_ID24) then aStuff1 := 2; 25 begin 26 _code_ 27 end;
Why do you need begin..end block here?
Where is aStuff1 variable declared?

So do you have an error, as you said on github or not? And what do you mean by 'does not work this syntax'? What is not working exactly?
Any error? (what error?)
Or it does not work as you wanted it to? (how it should work and how is it work actually?)

Please provide full script, as I asked you on github.

Re: Syntax

PostPosted: 03 Sep 2017, 10:23
by petrmenzel
I have written error:
(24:5) Identifier expected

Variable is global.

And it works now. Problem was solved by setup by default variable as -1.

Re: Syntax

PostPosted: 03 Sep 2017, 11:00
by Rey
Good! :)