March 16, 2003, 16:17
|
#1
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
accessing constants in DB files
Does anyone know how to access the numerical constants in the non-unit database files?
If you want to get the constants for the unit.txt file you can ues this method:
UnitRecord[0] = UnitDB(UNIT_WARRIOR);
tmpArm = UnitDB(UnitRecord[0]).Armor;
But the unit database file is set up like this:
## UNIT 0
UNIT_ABOLITIONIST {
...
Firepower 1
Armor 1
...
}
How would you access the constants in the terrain file when the values there are set up like this?
TERRAIN_FOREST {
EnvBase {
Score 50
Food 10
Shield 5
Gold 10
}
}
I noticed in the Greatlibrary.txt file, they just wrote in the values by hand, but I'm hoping there is a way for SLIC to access the information without needing to be told what the values are.
|
|
|
|
March 16, 2003, 17:37
|
#2
|
Prince
Local Time: 22:53
Local Date: November 1, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
I'm pretty sure you can use the method above, replacing unitrecord[0] with value[0].
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
|
|
|
|
March 16, 2003, 17:44
|
#3
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
Quote:
|
Originally posted by Immortal Wombat
I'm pretty sure you can use the method above, replacing unitrecord[0] with value[0].
|
Thanks, IW. I'll give it a try.
|
|
|
|
March 16, 2003, 17:54
|
#4
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
The game launches but hangs when a game is started with:
Value[0] = TerrainDB(TERRAIN_FOREST);
tmpAtt = TerrainDB(Value[0]).food;
I think the problem is how to get the values inside the second set of brackets.
Code:
|
TERRAIN_FOREST {
EnvBase {
Score 50
Food 10
Shield 5
Gold 10
}
} |
How to make "TerrainDB(Value[0]).food" into "TerrainDB(Value[0]).EnvBase.food"? Obviously this syntax won't work, so I tried a double hop with:
Value[0] = TerrainDB(TERRAIN_FOREST);
Value[1] = TerrainDB(Value[0]).Envbase;
tmpAtt = TerrainDB(Value[1]).food;
But this just causes another game hang. ANy ideas?
Last edited by ahenobarb; March 16, 2003 at 18:07.
|
|
|
|
March 16, 2003, 18:11
|
#5
|
Prince
Local Time: 22:53
Local Date: November 1, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
Ah. oops. Problem:
from the docu:
Quote:
|
Any bitfield, integer, or floating point value that is in the main body of a record (NOT values in sub-structures!)
|
That would be a substructure you're trying to access.
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
|
|
|
|
March 16, 2003, 18:25
|
#6
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
Quote:
|
Originally posted by Immortal Wombat
Ah. oops. Problem:
from the docu:
Quote:
|
Any bitfield, integer, or floating point value that is in the main body of a record (NOT values in sub-structures!)
|
That would be a substructure you're trying to access.
|
Bummer.
Since, I've got you here. What about accessing the non-integer constant values in the "userprofile.txt" file. For instance, if you want the number of players.
tmpNum = preference("NumPlayers");
What about the "Yes" and "No" fields. I've tried to use them as binary 1/0 numbers, but no go. Also, StringCompare always seems to return false. Even more frustrating, StringCompare returns false (0) for:
x = StringCompare("Yes", "Yes");
|
|
|
|
March 16, 2003, 18:42
|
#7
|
Prince
Local Time: 22:53
Local Date: November 1, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
StringCompare is junk. It doesn't work for anything useful, and it seems not always for anything useless.
I've no idea about the other preferences.
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
|
|
|
|
March 16, 2003, 18:54
|
#8
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
Quote:
|
Originally posted by Immortal Wombat
StringCompare is junk. It doesn't work for anything useful, and it seems not always for anything useless.
I've no idea about the other preferences.
|
Thanks for confirming my opinion of StringCompare!  and the other help as well. If I figure out how to get the Yes/No to work, I'll let everyone know.
|
|
|
|
March 16, 2003, 19:05
|
#9
|
King
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
|
While we're talking functions, what about "IsContinentBiggerThan(location,size)"? I seem to have had it returning 1's and 0's for the same location and the same size
|
|
|
|
March 16, 2003, 19:25
|
#10
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
Quote:
|
Originally posted by Peter Triggs
While we're talking functions, what about "IsContinentBiggerThan(location,size)"? I seem to have had it returning 1's and 0's for the same location and the same size
|
What values are you putting in the parenthesis? I haven't used it but I think it should be:
x = IsContinentBiggerThan(tmpLoc, 54);
So it should check the size of the landmass that tmpLoc is part of and determine if there are more than 54 land squares that form the continent. 1 if there are, 0 if there is not.
My 2c, without knowing what values have been entered.
|
|
|
|
March 16, 2003, 20:26
|
#11
|
King
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
|
That's the theory. But, IIRC, I tried it with size=100 and size=10000 (bigger than the map area) and got incomprehensible results.
I wanted to use it in a function to find the areas of the oceans (it's supposed to work with oceans too) that two water locations are in so that if the areas were the same, I would know that they were in the same ocean.
|
|
|
|
March 16, 2003, 21:06
|
#12
|
Prince
Local Time: 21:53
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
|
Quote:
|
Originally posted by Peter Triggs
That's the theory. But, IIRC, I tried it with size=100 and size=10000 (bigger than the map area) and got incomprehensible results.
I wanted to use it in a function to find the areas of the oceans (it's supposed to work with oceans too) that two water locations are in so that if the areas were the same, I would know that they were in the same ocean.
|
Hmmm. Didn't know that about the oceans, but it makes sense I suppose. One problem may be however, that the question is whether the continent is "bigger", so if it is the same size, the answer is no. You may have to do a size -1 equation to get the result?
|
|
|
|
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 17:53.
|
|