April 3, 2001, 15:20
|
#1
|
Prince
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
|
|
|
|
April 4, 2001, 18:42
|
#2
|
Emperor
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."
|
|
|
|
April 5, 2001, 05:50
|
#3
|
Prince
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?  ?
|
|
|
|
April 5, 2001, 19:07
|
#4
|
Emperor
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."
|
|
|
|
April 9, 2001, 05:13
|
#5
|
Prince
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).]
|
|
|
|
April 10, 2001, 07:37
|
#6
|
Prince
Local Time: 10:58
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
|
|
|
|
April 10, 2001, 08:41
|
#7
|
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
|
|
|
|
April 10, 2001, 09:12
|
#8
|
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
|
|
|
|
April 11, 2001, 13:09
|
#9
|
Prince
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
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
All times are GMT -4. The time now is 05:58.
|
|