Announcement

Collapse
No announcement yet.

Some more slic questions.

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

  • Some more slic questions.

    Hey, got some questions about slic.

    1. I know it says that all the variables are global but are they global only throughout that one file or multiple files. For example.

    If I had two files slic.slc and gem.slc and I declared x as a variable in both files would each one interfere with each other or are they isolated from each other??

    Sorry if the way I questioned this above seems a bit crude but I'm quite new to any kind of programming.

    2. Also, is there any way in slic to store hex locations. I know it should be possible to do this with something like unit.location and city.location but I have been unable to store just plain old hex locations in some type of typelocation variable, I've tried almost everything and have almost come to the conclusion that it is not possible. So for example,

    If you wanted to build a unit on a certain hex location that is not a city and the coordinates for the hex were something like this 46,44,0, can this be done, can you pass 46,44,0 those hex numbers into some sort of variable so you can script a unit to be built on that hex.

    ------------------
    Gemini

  • #2
    gemini,

    Let me answer your questions:

    1. I haven't actually tested this but I pretty sure variables are handled globally even over multiple files. The way I suspect it works is that all SLIC-files are read into memory first and then processed. Once loaded into memory the program can't see which code comes from which file, so all code is handled as if it comes from one file. So if you don't want variables interfering with each other you'll must give them different names.

    2. I wanted something like this myself for flat-map support as well (to store the map-edge locations) but as far as I know that isn't possible. I *have* found some sort of a workaround this, although my code still has some bugs (if it wasn't for those bugs we would have had flat-map support a month ago) and I don't know if something like this will work for your situation. Here it is anyway:
    For existing maps I created a location-variable for every location I want to store. I then placed a dummy-unit (created just for this purpose) on every location I wanted to store through the cheat menu. So this doesn't work for random maps, you'll have to manually put the unit(s) into place. When you click on a dummy-unit you get a message box asking you if you want to kill the dummy-units again and store their locations (and in my case the place the map-edge at those locations). So once you do this you your old map back and the locations are stored (if you need different locations for different things you could create different types of dummy units). All you have to do now is click on Clear LOS in the cheat menu and save your scenario. I think this should work although, as I said, I'm still having some trouble with this myself (but I'm not sure where the problem is exactly so it might work fine for you).
    If you don't know how to implement this idea in SLIC-code I'm willing to send you my files for flat-map support as an example or even help you create the code for your specific situation.

    Locutus
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

    Comment


    • #3
      Hey Locutus, Thanks man!!!!

      Yes, regarding question 1, that kinda what I thought.

      Your solution to question 2 is something that I never thought of doing and it should work theoritically. But I tried this little test and didn't produce a very good ending. This is just a simple little trigger.

      trigger 'move' when (IsHumanPlayer(g.player)){a = 1;

      bliz = bliz + a;

      message (g.player, 'whoiswho');}

      Just a simple trigger that increments the variable bliz every turn and sends a message to me so I can make sure the value of bliz changes each turn.

      Anyway, the reason I tried this cos I wanted to test to make sure that the variable would retain it's value if the game was saved and loaded again.

      For example if after 20 turns the value of bliz was 20 and the game was saved by the user and then the user exits the game, when he returns would bliz equal 20 again or start over at 1.


      So that's what I did. I played for 20 turns everything was going fine and I recieved a message everyturn and I confirmed the value of bliz was being incremented with every turn. I then saved a game. Exited ctp. Restarted ctp. Then I tried to load the game again it immediately crashed and gave me this page fault error thingy.

      I tried this several times after rebooting the computer and still produced the same result.

      Have you run into anything like this before??

      Is this maybe what your trigger for your flat map support is doing.

      So I'm not sure if I build dummy units on my map to store the locations into location variables if it will retain it's value after a person has loaded a save game. Hmmm

      Maybe,,,do you have to save it as a scenario, cos I just saved as a normal savegame.

      Thanks for your quick responses by the way Locutus!!!!

      Also thanks for the offer of help on this subject.










      ------------------
      Gemini

      Comment


      • #4
        I never investigated why I had problems loading saved games because I had plenty of other problems to take care of first but I guess you found the source of the problem for me. Mayor bummer That means unit-locations can't be stored for long times, and limits me with flat-map support (it will still work, but less elegant) and probably make whatever you're trying to do impossible. The only way to do whatever you want now is to place a unit as a placeholder at the location you need to store or something like that. If you tell me what exactly you want I can think about a possible solution but I really need some specifics. The solution, if it exists at all, will probably be an ugly hack specific for your situation, such as we're using for flat-map support (we use units for that instead of terrain-types).
        Well, thanks for finding out that problem anyway, probably saves me many hours of frustration solving this and other flat-map related problems.

        BTW I saved it as a normal game as well, but if it doesn't work with normal savegames it doesn't really matter if it works as a scenario: you want players to be able to save a game.

        Locutus
        [This message has been edited by Locutus (edited May 02, 2000).]
        Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

        Comment


        • #5
          Hey Locutus, I found something that may help the both of us.

          typelocation bliz;
          trigger 'move' when (IsHumanPlayer(g.player)){


          Makelocation(bliz, 46,44,0);
          createunit(g.player, unittype("UNIT_SETTLER"), bliz,0);

          message (g.player, 'whoiswho');}

          Ah yes!!!! The Makelocation function works like a charm. You can pass in hex cooridinates into location variables. I tested it. It works, as you can tell I had it build a settler everyturn on the coordinates held in the bliz location variable. I also sent myself a message displaying the value of the variable bliz just to double check things and it seems to work!!!

          So I hope this helps you out a bit as well.

          ------------------
          Gemini

          Comment


          • #6
            Hey gemini,
            I think it was you who said that you can use slic to make an advance available, eg Majanic Assembly. Could you tell me how to do it please?. The reason I don't know is that I've not had time to stuff around with slic over the last few weeks and it requires a bit of getting used to all the functions.

            Later,
            Dogmatrix

            P.s. The reason I've had time to write all of my replies is because I do it at school and we don't have CTP at school so mods are at home, a pitty . See ya!
            Flying shields and no warm beer.

            Comment


            • #7
              Hey Dogmatrix, Well no it wasn't me who told you about that I think it was Locutus but let me answer your question anyway.

              Use this Function

              GrantAdvance(player, advance)

              I think the advance is the index in advance.txt. But I am not 100% sure about that.

              For example.

              GrantAdvance(g.player, 10);

              Hope that helps.



              ------------------
              Gemini

              Comment


              • #8
                gemini,

                Great! I've been looking for a function like that for a long time Thanks a lot for finding that out! I think that makes flat-map support a lot easier although there are also some complications (but I think they can be solved).

                Again, thanks man, great job.
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment

                Working...
                X