Announcement

Collapse
No announcement yet.

Question

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

  • #16
    Here's the problem:

    SLIC provides direct read-only access to much of the data contained in the game databases.
    Also, although it's written that you can access many fields from the databases (using dot notation) this only seems to work for the UnitDB. Every time I've tried a different one (even using the examples that were given in the documentation), I get a syntax error. So it looks to me that this was something that was intended to be included but didn't get finished. It's a pity, being able to access the fields in strategies.txt and diplomacy.txt would be very useful.

    Comment


    • #17
      Originally posted by Peter Triggs
      Here's the problem:



      Also, although it's written that you can access many fields from the databases (using dot notation) this only seems to work for the UnitDB. Every time I've tried a different one (even using the examples that were given in the documentation), I get a syntax error. So it looks to me that this was something that was intended to be included but didn't get finished. It's a pity, being able to access the fields in strategies.txt and diplomacy.txt would be very useful.
      I read through the SLIC documentation yesterday and saw that same passage. However, in the 10 minutes I had free last night, I tried my hand at it. I expected that I would get an error, but it should point me to the proper solution.

      However, that one part I thought wasn't in error apparantly was. The error message said: "No TERRAIN_HILL in the TerrainDB" "No TERRAIN_MOUNTAIN in the TerrainDB" (I had referenced both with TerrainDB(TERRAIN_XXXX))

      I haven't had anytime to look at it again, but that struck me as odd. Unless the Terrain.txt is not considered the TerrainDB, I don't know what is wrong.

      Any ideas?

      Comment


      • #18
        God... i never remember what this thread is for in the morning

        Comment


        • #19
          That's odd, ahenobarb, I did the same thing just now and got a syntax error, just like Peter. Are you sure you didn't make any typos or anything silly like that? If not, could you post your code, so others can see they can reproduce and explain it?

          Aside from that, it's good to know we have an experienced programmer looking into SLIC again. We desperately need people like you
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #20
            Originally posted by Locutus
            That's odd, ahenobarb, I did the same thing just now and got a syntax error, just like Peter. Are you sure you didn't make any typos or anything silly like that? If not, could you post your code, so others can see they can reproduce and explain it?

            Aside from that, it's good to know we have an experienced programmer looking into SLIC again. We desperately need people like you
            It was a case-sensitivity issue. i was rushing out the door and didn't get time to fool around to check it.

            Anyway, here's the SLIC I did for this:

            HandleEvent(MoveUnits) 'IncreaseVision' post {
            unit_t tmpUnit;

            While(tmpUnit.location == 8 ||
            tmpUnit.location == 9 ||
            tmpUnit.location == 18 ||
            tmpUnit.location == 19 ||
            tmpUnit.location == 20 ||
            tmpUnit.location == 21 )
            {
            tmpUnit.visionrange = tmpUnit.visionrange + 1;
            }
            }
            }


            However, when I load it up, CTP2 tells me "Visionrange is not a member of tmpUnit".

            So from this I believe I have learned the only parts of the unit array that can be used are:

            unit.owner - the unit's owner
            unit.location - the unit's location
            unit.type - the unit's database index
            unit.hp - the unit's remaining hit points
            unit.valid - true if the unit still exists, false otherwise
            unit.name - the unit's name, only useful in string replacements

            Comment


            • #21
              Originally posted by ahenobarb
              It was a case-sensitivity issue. i was rushing out the door and didn't get time to fool around to check it.

              Anyway, here's the SLIC I did for this:

              HandleEvent(MoveUnits) 'IncreaseVision' post {
              unit_t tmpUnit;

              While(tmpUnit.location == 8 ||
              tmpUnit.location == 9 ||
              tmpUnit.location == 18 ||
              tmpUnit.location == 19 ||
              tmpUnit.location == 20 ||
              tmpUnit.location == 21 )
              {
              tmpUnit.visionrange = tmpUnit.visionrange + 1;
              }
              }
              }


              However, when I load it up, CTP2 tells me "Visionrange is not a member of tmpUnit".

              Some notes about the code, the MoveUnits event has two location variables and an army variable in its context. You can take access with army[0] on the army variable. (See the slic documentation which variables are in the context) If you now want to take access on the units of the army you have to use the GetUnitByIndex function within a for loop. It is also possible to get the army size, the best thing here is to consult the various slic files and the slic documentation for examples. So your temporary unit variable actual contains nothing.

              Another problem I see in your code is the while loop: As your handler is a post handler the code will be executed after the move event was done. The event is called everytime a unit moves from one tile to its adjacent tile. Once the army is on the hill for instance the condition in the while loop is true and the while loop will be executed until the army leaves the hill. But the next MoveUnits event want be called until the your code was be executed. So once the condition in the while loop is true it will be always true. And the loop turned in an endless loop.

              Originally posted by ahenobarb
              So from this I believe I have learned the only parts of the unit array that can be used are:

              unit.owner - the unit's owner
              unit.location - the unit's location
              unit.type - the unit's database index
              unit.hp - the unit's remaining hit points
              unit.valid - true if the unit still exists, false otherwise
              unit.name - the unit's name, only useful in string replacements
              These ones does work with the unit array, for the other ones you have to use the unitrecord array. See the Great Library for some example code about this although I think the GL is not the best place to find examples.

              Even if it takes some time to learn slic, don't give up keep on trying.

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • #22
                Originally posted by Martin Gühmann



                If you now want to take access on the units of the army you have to use the GetUnitByIndex function within a for loop. It is also possible to get the army size, the best thing here is to consult the various slic files and the slic documentation for examples. So your temporary unit variable actual contains nothing.

                Another problem I see in your code is the while loop: .... the loop turned in an endless loop.



                These ones does work with the unit array, for the other ones you have to use the unitrecord array. See the Great Library for some example code about this although I think the GL is not the best place to find examples.

                Even if it takes some time to learn slic, don't give up keep on trying.

                -Martin
                Thanks, Martin. I dumped the GetUnitsByIndex even though I saw an example using that. I figured, if I really needed it, CTP2 would say something when I started the game and it spat out its error messages. It didn't say anything when I dropped it, so I figured I didn't need it. Guess I was wrong.

                While loop: I thought that might be the case, but figured I'd cross that bridge when/if I ever saw the visionrange actually increase.

                I'll check the GL. Thanks again.

                Comment


                • #23
                  Originally posted by Martin Gühmann
                  Would it is such easy then you have to answer me this question: Why we need such a function to add additional movement points:

                  AddMovement
                  Even if such modification did work (which it apparently doesn't) you would still need the AddMovement function since this affects the units current available movement, not the MaxMovePoints. Similarly for the hp.

                  Comment


                  • #24
                    Originally posted by ahenobarb
                    Thanks, Martin. I dumped the GetUnitsByIndex even though I saw an example using that. I figured, if I really needed it, CTP2 would say something when I started the game and it spat out its error messages. It didn't say anything when I dropped it, so I figured I didn't need it. Guess I was wrong.

                    While loop: I thought that might be the case, but figured I'd cross that bridge when/if I ever saw the visionrange actually increase.

                    I'll check the GL. Thanks again.
                    There are two kinds of errors that can you code contain. On the one hand syntax errors on the other hand semantic errors. The syntax errors are the easier ones, because you will get an error message, even if slic error messages could give you more pieces of information. But the semantic errors are the ones that are much harder to detect, because the syntax is ok but the content is the problem. The only symptom that you notice is that your code doesn't do the stuff that it is supposed to do, and now you have to search why.

                    Here is an example in English:

                    Code:
                    The only symptom code is that doesn't do the stuff that it is supposed and now have why.
                    You see I just deleted some words of my last sentece and you don't get the content, but nevertheless all the words I used are valid English words and also the form should be correct, capital letter on the beginning a dot at the end, and the grammer is ok more or (rather) less correct.

                    -Martin
                    Civ2 military advisor: "No complaints, Sir!"

                    Comment

                    Working...
                    X