Hey all 
Now that I have my custom stat system, I am working on a custom item system to work with it. I am using a struct to hold item data, and making an array of the struct for each item type. Maybe I am not familiar enough with the syntax involved with looping through an array of structs, but for some reason, when I use my add function to add an item to the array, it fills up the array. I think. I made a test function to list the contents of the array, and it makes like 2940 of the only item I have added.
I realize that the struct for this purpose is overkill, and i could just use parallel arrays at most, but I plan to add more variables to the data at some point in the future.
I am initializing my struct and array like this:
And then my add function looks like:
And then finally I have an item initiation trigger (the previous code is all in my map header) with the following function call:
I am thinking that I am just adding the item incorrectly with my add function. If someone happens to see something incorrect in my code, or could suggest a better solution to my system, I would really appreciate it
Thanks!
-enyeas
Now that I have my custom stat system, I am working on a custom item system to work with it. I am using a struct to hold item data, and making an array of the struct for each item type. Maybe I am not familiar enough with the syntax involved with looping through an array of structs, but for some reason, when I use my add function to add an item to the array, it fills up the array. I think. I made a test function to list the contents of the array, and it makes like 2940 of the only item I have added.
I realize that the struct for this purpose is overkill, and i could just use parallel arrays at most, but I plan to add more variables to the data at some point in the future.
I am initializing my struct and array like this:
JASS:
struct itemData
string name
integer itemCode
endstruct
JASS:
globals
itemData array OneHandSlashing
endglobals
And then my add function looks like:
JASS:
function addOneHandSlashing takes string n, integer i returns nothing
local integer z = 0
loop
exitwhen (OneHandSlashing[z].name == null)
set z = z + 1
endloop
set OneHandSlashing[z].name = n
set OneHandSlashing[z].itemCode = i
endfunction
And then finally I have an item initiation trigger (the previous code is all in my map header) with the following function call:
JASS:
scope Items initializer init
private function init takes nothing returns nothing
call addOneHandSlashing("Test Sword", 'I000')
endfunction
endscope
I am thinking that I am just adding the item incorrectly with my add function. If someone happens to see something incorrect in my code, or could suggest a better solution to my system, I would really appreciate it
Thanks!
-enyeas