Thread Tools
Old April 5, 2003, 18:13   #1
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 23:11
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
GetInput
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.
ahenobarb is offline  
Old April 5, 2003, 20:12   #2
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 23:11
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
This is a new one on me. Where did you find this?
Peter Triggs is offline  
Old April 6, 2003, 10:29   #3
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 01:11
Local Date: November 2, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
GetInput is one of three keyword you can find in Locutus' slic doc and in my Flag list. I classified it as slic function that is probably wrong. It looks rather like something Stop and Continue. Stop is used in slic code the two other keywords aren't used. Possible all the keywords can be used in loops for example. It would be interesting what the use of these words is in other programing languages.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old April 6, 2003, 12:48   #4
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 23:11
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
'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.
Peter Triggs is offline  
Old April 6, 2003, 13:16   #5
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 01:11
Local Date: November 2, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
That was it I had in mind for continue, but GetInput is still a mystery.

At least we have a possibility to break loops now.

Well we could use it like ahenobarb suggested but then it wouldn't make sense that it returns some mouse values. It could be used as return argument for a function to get to know what it does well at least if it is something with an integer representaion:

[CODE]
int_f TestFunktion(){
return GetInput;
}

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old April 6, 2003, 13:57   #6
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 23:11
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
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?
ahenobarb is offline  
Old April 12, 2003, 15:01   #7
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 01:11
Local Date: November 2, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Comparing it with Java stuff it looks like continue is used to break a loop cycle in order to continue with the next loop cycle. In all of the examples we see in this thread it wouldn't make any difference if it is there or not. So far I understood it it could replace an if - else statement.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old April 24, 2003, 07:00   #8
J Bytheway
Call to Power PBEMCall to Power II Democracy GameCTP2 Source Code Project
Emperor
 
J Bytheway's Avatar
 
Local Time: 00:11
Local Date: November 2, 2010
Join Date: Jul 2001
Location: England
Posts: 3,826
I thought "return CONTINUE" was just the opposite to "return STOP", and - in an event - probably does exactly the same as just "return", or reaching the final closing brace.
J Bytheway 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 19:11.


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