Thread Tools
Old April 3, 2001, 15:20   #1
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:58
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
SLIC for Mars
Though directly related to my scenario, a SLIC question probably fits in better here.

I tried this SLIC to get a settler into every capital city every 24 turns, and I get no error messages, so far so good...
Then it doesn't work - no settlers, no errors, what am I doing wrong?

Code:
HandleEvent(beginturn) 'settlercount' pre{
int_t	SettlerCount;
city_t	tmpCity;
int_t	i;
(SettlerCount = SettlerCount + 1);
		if(SettlerCount == 3){
			for(i = 0; i < 8; i = i + 1){           //how do I get "number of players" instead of 8 ?
				if(isplayeralive(i)){
				tmpCity = player[i].capital;
					createunit(player[i], UnitDB(UNIT_SETTLER), tmpCity.location, 0);
					}
				}
			settlercount = 0;
		}
}
Any ideas?

*cough* Dale *cough*
Thanks
Ben
Immortal Wombat is offline  
Old April 4, 2001, 18:42   #2
Dale
Emperor
 
Dale's Avatar
 
Local Time: 19:58
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
*cough* OK *cough*

Let's have a look shall we.......

Code:
HandleEvent(beginturn) 'SettlerCaptialCreate' pre{     // SettlerCount won't work as it's a variable below
     int_t SettlerCount;
     city_t tmpCity;
     int_t i;
     int_t NumOfPlayers;     // What it says
     location_t tmpLoc;     // Location of Capital
     NumOfPlayers = preference("NumPlayers");     // How to 'get' # of players
     if(IsHumanPlayer(player[0])) {     // Increases SettlerCount only once per turn, not NumOfPlayers times per turn
          SettlerCount = SettlerCount + 1;     // Take out brackets
     }
     if(SettlerCount == 3){
          for(i = 1; i < NumOfPlayers; i = i + 1){     // i=1 means don't do for barbs
               if(IsPlayerAlive(i)){     // Note capital letters.....
                    GetCityByIndex(i, 0, tmpCity);     // Get Capital city
                    tmpLoc = tmpCity.location;     // Get location of city
                    CreateUnit(i, UnitDB(UNIT_SETTLER), tmpLoc, 0);
               }
          }
     SettlerCount = 0;
     }
}
------------------
Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."
Dale is offline  
Old April 5, 2001, 05:50   #3
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:58
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Thanks a lot Dale, if I ask enough times I might get it right once in a while

One thing though, I read in the Activision documentation that Slic was case-insensitive, or is that just for ElSeiF statements ?

What was my code actually doing then? ?
Immortal Wombat is offline  
Old April 5, 2001, 19:07   #4
Dale
Emperor
 
Dale's Avatar
 
Local Time: 19:58
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
Only some things are case-sensitive. For example, events are case sensitive, routines are case-sensitive, variables are case-sensitive. Plus, after doing a few years programming I'm just in the habit of using capitals.

Your script was actually doing this.

1. Enter the script and initialise the variables.
2. Pass over the SettlerCount = line as it was in brackets.
3. Check SettlerCount to see if it's 3, but it's never 3 (see line above).
4. Exit script.

------------------
Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."
Dale is offline  
Old April 9, 2001, 05:13   #5
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:58
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Thanks for clearing those things up Dale, I might get the hang of this some time...

------------------
Whoever said SLIC was easy once you got used to it, was probably telling the truth. If anyone tells you that getting used to it was easy - they're lying
[This message has been edited by Immortal Wombat (edited April 10, 2001).]
Immortal Wombat is offline  
Old April 10, 2001, 07:37   #6
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:58
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Problem Number 2:
Assume all the variables are defined at the top of the slc page. I'm sure I have pretty much used the code in the same way its used in Alex.scn and samurai scenario, and I'm fed up. Can you help again? thanks

Code:
HandleEvent(BeginTurn) 'GiveResourcesA' pre {
int_t	tmpPlayer;

player[0] = tmpPlayer;                                        //player[0] - the player whose turn is beginning is stored
if(tmpPlayer == 1) {					     //  if the stored player is player 1...
	PwcountA = PwcountA + 1;			                              //then their pw counter is added to
	if(PwcountA == 3){						// if it is now 3...
		player[0].publicworkslevel = tmpPwA;                    // then store it  (Error: Symbol player is not a struct)
		tmpPw2A = tmpPwA + 5000;                                 // add 5000 to it, and store that as another variable
		setPW(tmpPlayer, tmpPw2A);                               // make the player's pw the new variable
		PwcountA = 0;						  // and set the counter to zero
		}
	}
}

Immortal Wombat is offline  
Old April 10, 2001, 08:41   #7
kaan
CTP2 Source Code Project
Prince
 
Local Time: 09:58
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Aarhus
Posts: 333
player[0].publicworkslevel = tmpPwA;

needs to be:

tmpPwA = player[0].publicworkslevel;

you assign values from the left side of "=" to the right side.

you could put it like this:

tmpPwa "is set equal to" player[0].publicworkslevel

-klaus
kaan is offline  
Old April 10, 2001, 09:12   #8
kaan
CTP2 Source Code Project
Prince
 
Local Time: 09:58
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Aarhus
Posts: 333
these are my notes to all the code:

Code:
HandleEvent(BeginTurn) 'GiveResourcesA' pre {
int_t tmpPlayer;
tmpPlayer = g.player;                  // g.player is the current player 
  if(tmpPlayer == 1) {                 // why player 1 ???
    PwcountA = PwcountA + 1;
    if(PwcountA == 3){                 // this line will only run if 
                                       // tmpPlayer = 1 , see above
      tmpPwA = tmpPlayer.publicworkslevel;
      tmpPw2A = tmpPwA + 5000;         // why not tmpPwA = tmpPwA + 5000;
      setPW(tmpPlayer, tmpPw2A);       // if above then 
                                       // setPW(tmpPlayer, tmpPwA);
      PwcountA = 0;
    }
  }
}
-klaus
kaan is offline  
Old April 11, 2001, 13:09   #9
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 10:58
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Goddamnit, I HATE SLIC

but I'll carry on trying. There are too few things I find challenging

Thanks a lot klaus!!

quote:

Originally posted by kaan on 04-10-2001 09:12 AM
these are my notes to all the code:

Code:
HandleEvent(BeginTurn) 'GiveResourcesA' pre {
int_t tmpPlayer;
tmpPlayer = g.player;                  // g.player is the current player 
  if(tmpPlayer == 1) {                 // why player 1 ???
    PwcountA = PwcountA + 1;
    if(PwcountA == 3){                 // this line will only run if 
                                       // tmpPlayer = 1 , see above
      tmpPwA = tmpPlayer.publicworkslevel;
      tmpPw2A = tmpPwA + 5000;         // why not tmpPwA = tmpPwA + 5000;
      setPW(tmpPlayer, tmpPw2A);       // if above then 
                                       // setPW(tmpPlayer, tmpPwA);
      PwcountA = 0;
    }
  }
}



right...
player1 only because I need to have separate triggers to disable for each player, there will be duplicate triggers for each player.
tmpPw2 is in there so it is more easy for me to see where I'm going wrong.

Anyway, thanks a lot to you klaus, and Dale also for the first answer, things are looking up.

Ben
Immortal Wombat is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:58.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team