- Joined
- Feb 23, 2008
- Messages
- 587
SOVLED
Question: This prints out 5 , twice. Any Idea What I am Doing wrong?
Answer: I wasn't creating instances of the tracks, correctly.
SOVLED
Question: This prints out 5 , twice. Any Idea What I am Doing wrong?
Answer: I wasn't creating instances of the tracks, correctly.
JASS:
//What Was Changed
//Old
//call r.myTracks[0].create()
//call r.myTracks[1].create()
//New
set r.myTracks[0] = r.myTracks[0].create()
set r.myTracks[1] = r.myTracks[1].create()
JASS:
struct Track
public integer x
static method create takes nothing returns thistype
local thistype r = thistype.allocate()
set r.x = 0
return r
endmethod
endstruct
struct Cart
public integer x
endstruct
struct Rollercoaster
Track array myTracks[1000]
Cart array myCarts[8]
integer y
static method create takes nothing returns thistype
local thistype r = thistype.allocate()
//What Was Changed
//Old
//call r.myTracks[0].create()
//call r.myTracks[1].create()
//New
set r.myTracks[0] = r.myTracks[0].create()
set r.myTracks[1] = r.myTracks[1].create()
set r.y = 20
return r
endmethod
endstruct
JASS:
function CreateArrayOfPlayersLotsOfTracks takes nothing returns nothing
local Rollercoaster array myPlayer
call myPlayer[0].create()
set myPlayer[0].myTracks[0].x = 10
set myPlayer[0].myTracks[1].x = 5
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(myPlayer[0].myTracks[0].x))
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(myPlayer[0].myTracks[1].x))
endfunction
//===========================================================================
scope SetupGame initializer InitA
function InitA takes nothing returns nothing
call CreateArrayOfPlayersLotsOfTracks()
endfunction
endscope
SOVLED
Last edited: