 |
|
ahenobarb
|
|
Still more SLIC questions ...
Has anyone used GetInput? It's syntax has to be:
Return GetInput;
I assume it allows you to get input from the player somehow, although how this is done with a function return is beyond me. Is that correct? I haven't found a single instance of it used in slc code.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:27
|
|
This is a new one on me. Where did you find this?
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:27
|
|
'Continue' is ok, but you have to use it with 'Return'. There was an example in the Function Reference doc:
code:
int_t i;
location_t my_loc;
//initialise these variables
for(i = 0; i < 8; i = i + 1) {
GetNeighbor(city[0].location, i, my_loc);
if(AllUnitsCanBeExpelled(my_loc)) {
//do stuff
return CONTINUE;
}
}
//if all of the enemy units 1 tile away from city[0], do stuff, then break the for loop and continue.
It would be nice if this 'GetInput' returned some mouse value though.
|
|
|  |
 |
|
ahenobarb
|
|
quote: Originally posted by Peter Triggs
'Continue' is ok, but you have to use it with 'Return'. There was an example in the Function Reference doc:
code:
int_t i;
location_t my_loc;
//initialise these variables
for(i = 0; i < 8; i = i + 1) {
GetNeighbor(city[0].location, i, my_loc);
if(AllUnitsCanBeExpelled(my_loc)) {
//do stuff
return CONTINUE;
}
}
//if all of the enemy units 1 tile away from city[0], do stuff, then break the for loop and continue.
It would be nice if this 'GetInput' returned some mouse value though. |
Return CONTINUE is also used in Tut_main.slc
code:
//oh, baby, show me your workaround face
trigger 'TCheckQueue' on "CityWindow.CloseButton" when (1) {
int_t player;
player = g.player;
if(CityBuildingWonder(player)) {
EARLY_BUILDING_STARTED = 1;
DisableTrigger('TCheckQueue');
return CONTINUE;
} elseif(CityBuildingBuilding(player)) {
EARLY_BUILDING_STARTED = 1;
DisableTrigger('TCheckQueue');
return CONTINUE;
} elseif (AllCitiesBuilding(player)) {
Message(g.player, 'TMKeepExploring');
EARLY_BUILDING_STARTED = 1;
DisableTrigger('TCheckQueue');
return CONTINUE;
} else {
return CONTINUE;
}
}
and in a HandleEvent
code:
//count the number of caravans and let the player know if the have any goods
HandleEvent(CreateUnit) 'TCheckForCaravans' post {
int_t k;
city_t tmpCity;
CARAVANS_AVAILABLE = TradePoints(player[0]) - TradePointsInUse(player[0]);
if(IsHumanPlayer(player[0]) && CARAVANS_AVAILABLE) {
for(k = 0; k < player[0].cities; k = k + 1) {
GetCityByIndex(player[0], k, tmpCity);
if(CityIsValid(tmpCity)) {
if(FindGood(tmpCity.location) >= 0) {
city[0] = tmpCity;
Message(g.player, 'TMYouHaveAGood');
DisableTrigger('TCheckForCaravans');
return CONTINUE;
} else {
Message(g.player, 'TMYouHaveNoGoods');
DisableTrigger('TCheckForCaravans');
}
}
}
}
}
It seems that this code would function fine without return CONTINUE and it is not clear in this code where CONTINUE is being returned to.
I like Martin's idea about using GetInput in a function. Perhaps, the function could prompt the user to enter something either alphanumeric text (a single key entry or multiple keys?) or mouse clicks, which would then be returned to the statement that called the function. It's not really clear how a mouse click could be returned to the statement. What form would the return be? screen coordinates for the spot that was clicked? 1 or 0?
|
|
|  |
All times are GMT. The time now is 05:27. Apolyton Time is 00:27. |
top of page
|
| archivepost |
|
Forum 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
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|