Announcement

Collapse
No announcement yet.

accessing constants in DB files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    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

    Comment


    • #3
      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.

      Comment


      • #4
        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, 18:07.

        Comment


        • #5
          Ah. oops. Problem:

          from the docu:
          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

          Comment


          • #6
            Originally posted by Immortal Wombat
            Ah. oops. Problem:

            from the docu:
            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");

            Comment


            • #7
              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

              Comment


              • #8
                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.

                Comment


                • #9
                  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

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      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.

                      Comment


                      • #12
                        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?

                        Comment

                        Working...
                        X