- Joined
- May 4, 2007
- Messages
- 2,260
Hi guys, I am making a small system that will be guided by icons. For such a thing to work properly I need to use trackables. However, it doesn't matter what I try, the code just doesn't create any trackable. It creates peons and displays the message, but the trackables are never created. I hope this is just a minor mistake. I would appreciate any possible help.
Here is the vJASS code:
I will rep+ those who help me =S
Here is the vJASS code:
JASS:
scope SetIcons initializer Init
//===========================================================================
//=============================SETUP START===================================
//===========================================================================
globals
private constant string TRACK_MODEL = "units\\human\\Peasant\\Peasant"
private constant real DOWN_LEFT_Y = -7900.
private constant real DOWN_LEFT_X = -8000.
private constant integer COL_NUM = 3
private constant integer LINE_NUM = 2
private constant real TRACK_SIZE = 90.
endglobals
//===========================================================================
//=============================SETUP END=====================================
//===========================================================================
private struct aTrackable
real x
real y
real facing
string modelPath
integer value
trackable tc
static method create takes string path, real tx, real ty, real tfacing, integer tvalue returns aTrackable
local aTrackable data = aTrackable.allocate()
set data.x = tx
set data.y = ty
set data.facing = tfacing
set data.modelPath = path
set data.value = tvalue
set data.tc = CreateTrackable(data.modelPath, data.x, data.y, data.facing)
call BJDebugMsg("Tc created at " + R2S(data.x) +" " + R2S(data.y))
//call CreateUnit(Player(0), 'hpea', data.x, data.y, 0)
return data
endmethod
endstruct
//===========================================================================
private function TrackableHit takes nothing returns nothing
//local trackable tc = GetTriggeringTrackable()
call BJDebugMsg("click!")
endfunction
//===========================================================================
private function TrackableTrack takes nothing returns nothing
//local trackable tc = GetTriggeringTrackable()
call BJDebugMsg("track!")
endfunction
//===========================================================================
private function Actions takes nothing returns nothing
local aTrackable data
//create the triggers for the trackables
local trigger hit = CreateTrigger()
local trigger track = CreateTrigger()
local real prevX
local integer i = 0
local real x
local real y = DOWN_LEFT_Y
local real maxY = DOWN_LEFT_Y + (TRACK_SIZE * LINE_NUM)
local real maxX = DOWN_LEFT_X + (TRACK_SIZE * COL_NUM)
//we create the tracktables for the race icons
loop
exitwhen y > maxY - TRACK_SIZE
set x = DOWN_LEFT_X
loop
exitwhen x > maxX - TRACK_SIZE
set data = aTrackable.create(TRACK_MODEL, x, y, 0, i)
//set tc = NewTrackable(TRACK_MODEL, x, y, 0, i)
call TriggerRegisterTrackableTrackEvent(track, data.tc)
call TriggerRegisterTrackableHitEvent(hit, data.tc)
set i = i + 1
set x = x + TRACK_SIZE
endloop
set y = y + TRACK_SIZE
endloop
//add the actions for the triggers previously craeted
call TriggerAddAction(hit, function TrackableHit)
call TriggerAddAction(track, function TrackableTrack)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger SetIconsTrg = CreateTrigger( )
call TriggerRegisterTimerEvent(SetIconsTrg, 0.5, false )
call TriggerAddAction(SetIconsTrg, function Actions )
endfunction
endscope
I will rep+ those who help me =S