• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] Unsure about this.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
JASS:
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!
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
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)
 
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
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
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.
 
Level 12
Joined
Dec 2, 2016
Messages
733
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.

I found it but thanks.
 
Status
Not open for further replies.
Top