1. Please help test custom maps and more on the latest PTR!
    Dismiss Notice
  2. Create competitive 1v1 maps in the Melee Mapping Contest #2!
    Dismiss Notice
  3. Evolution complete! Make Darwin proud and go vote in the Techtree Contest #12 - Poll.
    Dismiss Notice
  4. Icon Contest #17 - Results are out! Step by to congratulate our winners!
    Dismiss Notice
  5. Succumb to the whispers and join our Texturing Contest #29 - Old Gods!
    Dismiss Notice
  6. The results for Texturing Contest #28 are out! Step by to congratulate our winners!
    Dismiss Notice
  7. We've created the Staff Job Openings thread. We're currently in need of icon, video production, and social/multimedia positions to be filled. Thank you!
    Dismiss Notice

[vJASS] Unsure about this.

Discussion in 'Triggers & Scripts' started by Rugarus, Jul 7, 2018.

  1. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    547
    Resources:
    0
    Resources:
    0
    Code (vJASS):

    private function OnAttack takes nothing returns boolean
      local unit a = GetAttacker()
      local player pa = GetOwningPlayer(a)

      local integer SideATK = PlayerData(pa).side
    endfunction
     


    I have this script (not written by me)
    I've read up array structs that is like

    integer x = 1

    local playerdata pd
    set playerdata[3].x=5


    But in this script I don't see "side" ever declared anywhere. Is side a pre built in property of player data?
    The script also doesn't require any other libraries, so I don't know how else 'side' could be defined unless already a premade property?

    And if it is, what are the other things that are premade properties?
    In the same script it also does

    playerdata[3].main

    Any help would be appreciated!
     
  2. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    994
    Resources:
    2
    Models:
    1
    Icons:
    1
    Resources:
    2
    What you have there is a member of a struct, (in this case, side of PlayerData). The struct would look something like this...

    Code (vJASS):

    struct PlayerData
        integer side
    endstruct
     


    As you can see, it is a member to every instance of the struct, but not to the struct itself.
     
  3. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,159
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    Seems like a struct as "." syntax is not really used elsewhere.

    So you want to look for the struct playerdata which supposedly has the "side" variable you are looking for
     
  4. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    547
    Resources:
    0
    Resources:
    0
    But wouldn't the library this code is in require another library that contains the 'side' variable? Because it's not in this script.
     
  5. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,159
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    Not necessarily.

    If the stars align you can have it work.

    Basically, in order to use something it needs to be placed above the line that uses it.
    So if you are lucky the struct you want to use happened to be placed above your triggers.

    The "requires" keyword ensures that the dependency is placed on top, but it is technically not needed.

    (actually I do not think it is "random" but rather in which order the triggers were created, but do not quote me on that)
     
  6. IcemanBo

    IcemanBo

    JASS Class Tutor

    Joined:
    Sep 6, 2013
    Messages:
    5,715
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Yeh, like it was said there must be a struct somehwere declared with this data. You can always attach the map, too if there are issues to find.

    struct
    works a bit different than normal JASS, it doesn't need to be placed on top, or concretly required/used by some library, because JassHelper will automatically make the organization for struct variables and methods.
    • struct variables will be globals, and there is anyways always only 1 globals block on the very top, in final JASS script
    • struct methods will be declared directly under the globals block
     
  7. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    547
    Resources:
    0
    Resources:
    0
    Oh ok gotcha, guess I need to sift through like 100 libraries to find this! xD
    Thanks!
     
  8. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    1,398
    Resources:
    0
    Resources:
    0
    You can intentionally put a compiler error in your code after a line that uses
    PlayerData(pa).side
    and then see what array is assigned to play the role of .side by JASSHelper when it notices the error during compilation.

    Say it's __s__PlayerData__var__side. Then you remove the compiler error, save the map, and extract its war3map.j. Search through that file for instances of __s__PlayerData__var__side and you might be able to identify which library or bit of code is modifying .side.
     
  9. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    547
    Resources:
    0
    Resources:
    0
    I found it but thanks.