Announcement

Collapse
No announcement yet.

player[] array

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

  • player[] array

    Ok, there's a question for the really experienced modders:

    simple:
    As far as I know, player[0] and [1] are used by the game - any event or function that uses player[2]?

    not so simple:
    What is the size of this array/the accessable numbers - unlimited?

    hard:
    When can I store values into this array by writing e.g. player[4] = 2; ? Anytime? Depending on the event? Depending on having assigned [2] and [3]?
    Depending on system time?!!?? (the last one is my guess after the game's constantly been making fun of me!)

  • #2
    1. I don't think so. Only the diplomacy functions use player[1], nothing should need 3 players stored...

    2. unlimited afaik. Certainly up to MaxPlayers in userprofile.txt

    3. Yes, you can. Locutus does it in his capital code slic for the MedPack. Should work any time in the code.
    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
      I think the player[] array is just a regular global array like all the others we create. The only difference is that information is given to them by the game engine.

      any event or function that uses player[2]?
      Only if there is a event hidden somewhere because any event known by the mods has it.
      "Kill a man and you are a murder.
      Kill thousands and you are a conquer.
      Kill all and you are a God!"
      -Jean Rostand

      Comment


      • #4
        So is there a restriction on read-access by message-strings then?

        Or how can you explain that a player[3]=i in a begin turn handler and in the message sent at the same moment gives the errors:

        line: (line number of the messagebox text) array: index out of bounds
        (and then same line, value lookup failed)

        Comment


        • #5
          Ok, I found the solution to the problem I had. Now if anyone is going to write 'Duh, we all know that' I'll be really pissed. I was going nuts on this last night.

          Reading the error messages carefully I might have guessed that the problem wasn't the assigning bit but the reading from the array.

          Here's the thing:
          while this won't work
          Code:
          ...
             player[3] = 5;
             Level = 6;
             message(tmpplayer,'Info');
          ...
          messagebox 'Info' {
          text(ID_newINFO)  //newINFO: player[3].civ_name_singular...
          ...
          this will do the trick:
          Code:
          ...
             Level = 6;
             player[3] = 5;
             message(tmpplayer,'Info');
          ...
          messagebox 'Info' {
          text(ID_newINFO)  //newINFO: player[3].civ_name_singular...
          ...
          Apparently the value gets kicked immeadetly when a next bit of code is executed.
          Duh, we all knew that, didn't we!

          Comment


          • #6
            This really is a surprise for me! I would never had imagined.
            Great Work and terrific thread about the slic crazy stuff. Deserves to be topped

            PS: Shouldnt the comment numbers in that thread start from 0
            "Kill a man and you are a murder.
            Kill thousands and you are a conquer.
            Kill all and you are a God!"
            -Jean Rostand

            Comment


            • #7
              further testing has revealed more:
              while
              Code:
              player[3] = x;
              player[4] = y;
              message(...);
              won't let you access player[3] in the message - it's lost for the reason above
              but this will work in a event that uses player[0]
              Code:
              player[0] = x;
              player[4] = y;
              message(...);
              everything clear?

              Comment


              • #8
                This is great news for the religion info, isnt it!?!
                "Kill a man and you are a murder.
                Kill thousands and you are a conquer.
                Kill all and you are a God!"
                -Jean Rostand

                Comment

                Working...
                X