Map Database  •  FAQ  •  RSS  •  Login

Syntax

<<

petrmenzel

Serf

Posts: 7

Joined: 22 Apr 2017, 18:31

KaM Skill Level: Veteran

Post 01 Sep 2017, 13:22

Syntax

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.
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 01 Sep 2017, 13:28

Re: Syntax

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; ...
<<

petrmenzel

Serf

Posts: 7

Joined: 22 Apr 2017, 18:31

KaM Skill Level: Veteran

Post 01 Sep 2017, 16:52

Re: Syntax

But it is not same.
My: if Status is true so the variable is some number
Your: variable is the Status
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 01 Sep 2017, 17:33

Re: Syntax

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.
<<

petrmenzel

Serf

Posts: 7

Joined: 22 Apr 2017, 18:31

KaM Skill Level: Veteran

Post 01 Sep 2017, 18:17

Re: Syntax

Difference:
My: If States = 1 then variable should be 2 (1 -> 2)
You: If States = 1 then variable should be 1 (1 = 1)
<<

Rey

User avatar

KaM Remake Developer

Posts: 217

Joined: 12 Oct 2016, 07:41

KaM Skill Level: Fair

Location: Moscow

Post 03 Sep 2017, 07:24

Re: Syntax

  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.
<<

petrmenzel

Serf

Posts: 7

Joined: 22 Apr 2017, 18:31

KaM Skill Level: Veteran

Post 03 Sep 2017, 10:23

Re: Syntax

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.
<<

Rey

User avatar

KaM Remake Developer

Posts: 217

Joined: 12 Oct 2016, 07:41

KaM Skill Level: Fair

Location: Moscow

Post 03 Sep 2017, 11:00

Re: Syntax

Good! :)

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest