Map Database  •  FAQ  •  RSS  •  Login

I need help with dynamics scripting

<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 13 May 2014, 11:56

I need help with dynamics scripting

How i can make a loop that will run the dynamic script every 1 min?
There is my code
begin
if States.UnitpositionX(10)then;
Actions.GiveAnimal(31,10,10);
end;
<<

Skypper

Knight

Posts: 436

Joined: 28 Jun 2013, 09:37

KaM Skill Level: Fair

Location: Dutch :D

Post 13 May 2014, 12:38

Re: I need help with dynamics scripting

your code
  Code:
begin if States.UnitpositionX(10)then; Actions.GiveAnimal(31,10,10); end;
mycode
  Code:
Procedure onTick; begin if(states.GameTime mod 600 = 0) then begin if States.UnitpositionX(10) then begin Actions.GiveAnimal(31,10,10); end; end;
not sure if this works, didn't test it.
good luck
Greets Skypper (Totally Insane)

- Beginning map maker -
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 13 May 2014, 13:38

Re: I need help with dynamics scripting

I meaned the Repeat command not one time maybe lewin knows...
<<

Skypper

Knight

Posts: 436

Joined: 28 Jun 2013, 09:37

KaM Skill Level: Fair

Location: Dutch :D

Post 13 May 2014, 13:45

Re: I need help with dynamics scripting

with this script your code well be execute every 60 secondes.

with states.gametime you get the play time of the game.
with "mod" you can calculate what the remainder of game time is, if that is 0, it is exactly 1 whole minute.
it can be the 1 minute but also the 56 minute.

I hope i explained it understandable :$
Greets Skypper (Totally Insane)

- Beginning map maker -
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 13 May 2014, 14:32

Re: I need help with dynamics scripting

Yea but its does'nt work
<<

Skypper

Knight

Posts: 436

Joined: 28 Jun 2013, 09:37

KaM Skill Level: Fair

Location: Dutch :D

Post 13 May 2014, 14:40

Re: I need help with dynamics scripting

here is a map, with a working example.
it will spawn every minute a single serf
You do not have the required permissions to view the files attached to this post.
Greets Skypper (Totally Insane)

- Beginning map maker -
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 13 May 2014, 14:51

Re: I need help with dynamics scripting

Ty it works with serf and animals
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 14 May 2014, 01:33

Re: I need help with dynamics scripting

How i can make a loop that will run the dynamic script every 1 min?
There is my code
begin
if States.UnitpositionX(10)then;
Actions.GiveAnimal(31,10,10);
end;
That code is not valid for a few reasons:
- You don't put a semicolon after "then", that ends the if-statement, so GiveAnimal will get executed every time (and the if-statement has no effect).
- "10" is not a valid parameter to UnitPositionX. You need to give it a unit ID which was given to you from a function like UnitAt.
- UnitPositionX returns a number. Your statement is like saying "if 5 then ...". "if 5" is meaningless and won't compile. You need to compare the number to something so you end up with a true/false statement. For example: "if States.UnitpositionX(SomeUnit) = 12 then" ("if 5 = 12" is valid since it is either true or false).

Return to “General / Questions”

Who is online

Users browsing this forum: No registered users and 12 guests