Goto https://www.stucuk.netGoto https://www.atlanticaonlinewiki.comGoto https://www.game-requirements.com


Menu


It is currently Wed Oct 18, 2017 5:27 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Arrays
PostPosted: Sat Oct 04, 2014 11:30 am 
Offline
Soldier level 0
Soldier level 0
User avatar

Joined: Fri Sep 19, 2014 7:18 pm
Posts: 4
I'm trying to use an array, but it doesn't work.
When i write this
Code:
every 0$1 trigger IsDying(ru_ware) or IsDead(ru_ware) do
var sklad;
begin
sklad:=ChangeMissionObjectives('M5_02');
GiveMedals('znicit2',1);
exit;
end;
begin
vsichni:=[Howard, JohnS, Steve, bunker2, del];
for a in vsichni do
begin
  if (IsInArea(a,konec)) then
      RemoveUnit(a);
end;

it tels me 'definition or trigger expected but 'begin' found
would you please help me?


Top
 Profile  
 
 Post subject: Re: Arrays
PostPosted: Sat Oct 04, 2014 3:02 pm 
Offline
Moderator
Moderator
User avatar

Joined: Mon Mar 17, 2008 6:03 pm
Posts: 1129
Location: Denmark
Code:
begin
vsichni:=[Howard, JohnS, Steve, bunker2, del];
for a in vsichni do
begin
  if (IsInArea(a,konec)) then
      RemoveUnit(a);
end;

This part of the code "stands for itself" which it can't. It must be wrapped in one of the four possible blocks: An every, a function, an event or the "Starting" block. You probably want something like

Code:
Every 0$1 do
var vsichni, a;
begin
  vsichni:=[Howard, JohnS, Steve, bunker2, del];
  for a in vsichni do
  begin
    if (IsInArea(a,konec)) then
      RemoveUnit(a);
  end;
  enable;
end;

You use of the array is just fine :)

Code:
every 0$1 trigger IsDying(ru_ware) or IsDead(ru_ware) do
var sklad;
begin
sklad:=ChangeMissionObjectives('M5_02');
GiveMedals('znicit2',1);
exit;
end;

As far as I know "ChangeMissionObjectives" doesn't return anything interesting. Why save it in a variable?
"GiveMedals" takes only 1 argument (a string) and you will want to use some "AddMedal" functions before executing "GiveMedals" (see the guidelines in editor Tools -> Identify).

_________________
I have an if that has an else, but that if has another if with an else inside... My question is... If an if has an else, if there is more than one line in that if, should it have a begin and an end?


Top
 Profile  
 
 Post subject: Re: Arrays
PostPosted: Sat Oct 04, 2014 5:09 pm 
Offline
Soldier level 0
Soldier level 0
User avatar

Joined: Fri Sep 19, 2014 7:18 pm
Posts: 4
thanks,
and how do I use the array in everys?
for example
Code:
every 0$1 trigger IsInArea(vsichni) do


Top
 Profile  
 
 Post subject: Re: Arrays
PostPosted: Sat Oct 04, 2014 8:44 pm 
Offline
Moderator
Moderator
User avatar

Joined: Mon Mar 17, 2008 6:03 pm
Posts: 1129
Location: Denmark
You are more limited there because it has to be a clean boolean expression. You can't do multiple statements. So you would have to create a function that does what you need and return a boolean as appropriate. Something like

Code:
Function IsInAreaList(list, area);
var i;
begin
  result = true;
  for i in list do
    if not IsInArea(list[i], area) then
      begin
        result = false;
        exit;
      end;
end;


This would return true if and only if all units in the "list" are in area "area".

_________________
I have an if that has an else, but that if has another if with an else inside... My question is... If an if has an else, if there is more than one line in that if, should it have a begin and an end?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Original War is an RTS / RPG game by Altar Games
Original War Support is not part of Altar Games but is maintaining Original War for Altar Games

Privacy Policy