HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Undeclared variable and function

11-14-2007, 10:32 PM#1
Zandose
Sorry, it's my first time making this is jass, and I'm getting some errors I can't seem to fix, "Undeclared variable water" and "Undeclared function". So, how shall i go about fixing this?

Also, any other suggections are welcome. Leaks, better method, etc...

Collapse JASS:
//This trigger creates negative terrain deformation and then adds a water model, in short, fake water.
function wateractions takes nothing returns nothing
//deformation points and size
local real array x //point x
local real array y //point y
local real array s //size
local integer l //loop
//Changes the rect into coordinates. Saves on having to clean up triggers that create random rects.
local rect map = GetPlayableMapRect() //clean up after
local real array p //points
set p[1] = GetRectMinX(map) //Bottom left?
set p[2] = GetRectMaxX(map) //Top left?
set p[3] = GetRectMinY(map) //Bottom left?
set p[4] = GetRectMaxY(map) //Bottom right?
call RemoveRect(map)

//Points, deformaiton size, and terrain deforamtion. Points and deformation size are used as 
//starting point for the following loop, and to reverse the deforamtions later.
    set x[0] = GetRandomReal(p[1], p[2])
    set y[0] = GetRandomReal(p[3], p[4])
    set s[0] = GetRandomReal(0, 1000.0) //Random number 0-1000
    call TerrainDeformCrater(x[0], y[0], s[0], -100.0, 99999, false) //Crater deformaiton
    call CreateDestructableZ('B000', x[0], y[0], 0, 0, R2I(s[0]/128), 1) //fake water over deformaiton
    set l = 1
    loop
        set x[l] = x[l - 1] + GetRandomReal(-500, 500)
        set y[l] = y[l - 1] + GetRandomReal(-500, 500)
        set s[l] = GetRandomReal(0, 1000.0)
    call TerrainDeformCrater(x[l], y[l], s[l], -100.0, 99999, false) //Crater deformaiton
    call CreateDestructableZ('B000', x[l], y[l], 0, 0, R2I(s[l]/128), 1) //Water over deformaiton
    set l = l + 1
    exitwhen l == 10
    endloop
    call DestroyTrigger(GetTriggeringTrigger()) //Just to save some memory
endfunction

function water takes nothing returns nothing
    set water = CreateTrigger( )
    call TriggerRegisterTimerEventSingle(water, 1.00)
    call TriggerAddAction(water, function wateractions)
endfunction
11-14-2007, 10:37 PM#2
cohadar
It would not piss anyone, post your code as much as you like.

Collapse JASS:
//This trigger creates negative terrain deformation and then adds a water model, in short, fake water.
function wateractions takes nothing returns nothing
//deformation points and size
local real array x //point x
local real array y //point y
local real array s //size
local integer l //loop
//Changes the rect into coordinates. Saves on having to clean up triggers that create random rects.
local rect map = GetPlayableMapRect() //clean up after
local real array p //points
set p[1] = GetRectMinX(map) //Bottom left?
set p[2] = GetRectMaxX(map) //Top left?
set p[3] = GetRectMinY(map) //Bottom left?
set p[4] = GetRectMaxY(map) //Bottom right?
call RemoveRect(map)

//Points, deformaiton size, and terrain deforamtion. Points and deformation size are used as 
//starting point for the following loop, and to reverse the deforamtions later.
    set x[0] = GetRandomReal(p[1], p[2])
    set y[0] = GetRandomReal(p[3], p[4])
    set s[0] = GetRandomReal(0, 1000.0) //Random number 0-1000
    call TerrainDeformCrater(x[0], y[0], s[0], -100.0, 99999, false) //Crater deformaiton
    call CreateDestructableZ('B000', x[0], y[0], 0, 0, R2I(s[0]/128), 1) //fake water over deformaiton
    set l = 1
    loop
        set x[l] = x[l - 1] + GetRandomReal(-500, 500)
        set y[l] = y[l - 1] + GetRandomReal(-500, 500)
        set s[l] = GetRandomReal(0, 1000.0)
    call TerrainDeformCrater(x[l], y[l], s[l], -100.0, 99999, false) //Crater deformaiton
    call CreateDestructableZ('B000', x[l], y[l], 0, 0, R2I(s[l]/128), 1) //Water over deformaiton
    set l = l + 1
    exitwhen l == 10
    endloop
    call DestroyTrigger(GetTriggeringTrigger()) //Don't be stupid
endfunction

function water takes nothing returns nothing // same name for a function and variable???
    set water = CreateTrigger( )
    call TriggerRegisterTimerEventSingle(water, 1.00)
    call TriggerAddAction(water, function wateractions)
endfunction

Perhaps you should read this.
11-14-2007, 11:09 PM#3
Zandose
You are evil! lol. I now have more errors, plus the original, then when I started. Anyways, I got to go take a shower so while I'm gone work your magic.

1) Should I use integer for MID_WATER? Are models ID's also integers like ability ID's? (auto converts?)
2) Error (for globals): statment outside of function
3) Error: Undeclared variable MID_WATER
4) Error (same old one): undeclared function InitTrig_water

Also, for some reason the endfunction at the end of the first trigger is cut off?

Collapse JASS:
function wateractions takes nothing returns nothing
//deformation points and size
local real array x //point x
local real array y //point y
local real array s //size
local integer l //loop
//Changes the rect into coordinates. Saves on having to clean up triggers that create random rects.
local rect map = GetPlayableMapRect() //clean up after
local real array p //points
set p[1] = GetRectMinX(map) //Bottom left?
set p[2] = GetRectMaxX(map) //Top left?
set p[3] = GetRectMinY(map) //Bottom left?
set p[4] = GetRectMaxY(map) //Bottom right?
call RemoveRect(map)

//Points, deformaiton size, and terrain deforamtion. Points and deformation size are used as 
//starting point for the following loop, and to reverse the deforamtions later.
    set x[0] = GetRandomReal(p[1], p[2])
    set y[0] = GetRandomReal(p[3], p[4])
    set s[0] = GetRandomReal(0, 1000.0) //Random number 0-1000
    call TerrainDeformCrater(x[0], y[0], s[0], -100.0, 99999, false) //Crater deformaiton
    call CreateDestructableZ(MID_WATER, x[0], y[0], 0, 0, R2I(s[0]/128), 1) //fake water over deformaiton
    set l = 1
    loop
        set x[l] = x[l - 1] + GetRandomReal(-500, 500)
        set y[l] = y[l - 1] + GetRandomReal(-500, 500)
        set s[l] = GetRandomReal(0, 1000.0)
    call TerrainDeformCrater(x[l], y[l], s[l], -100.0, 99999, false) //Crater deformaiton
    call CreateDestructableZ(MID_WATER, x[l], y[l], 0, 0, R2I(s[l]/128), 1) //Water over deformaiton
    set l = l + 1
    exitwhen l == 10
    endloop
    call DestroyTrigger(GetTriggeringTrigger()) //Just to save some memory
endfunction

Collapse JASS:
function water takes nothing returns nothing
    local trigger water1 = CreateTrigger()
    call TriggerRegisterTimerEventSingle(water1, 1.00)
    call TriggerAddAction(water1, function wateractions)
endfunction
Attached Files
File type: w3xAB.w3x (14.5 KB)
11-14-2007, 11:39 PM#4
Anopob
Collapse JASS:
local real array p //points
To declare points, you do something like "local location array p"... I have no idea why you have reals there.

But then I get confused on how you comment x and y to be points, and then set them to random reals...which one do you want?
11-15-2007, 12:30 AM#5
cohadar
I fixed that monstrosity of code that you posted.
It is in the attached map.

I wonder why I help you noobs anyways...

Ah now I remember, it is because I am evil.
And by helping you I get to have +rep that will eventually enable me to do
a -rep on you, mwhahahahahahahaha.
Attached Files
File type: w3xAB_fixed.w3x (16.5 KB)
11-15-2007, 03:43 PM#6
Zandose
@Anopob
Sorry if I confussed you, I'm a noob at jass after all. First time commenting on triggers. But now that you bring it up, I probably didn't use the correct words. I thought if I used a location variable I would end up using triggers that create new locations, such as getting a new location based on the last one (extra work). So instead I changed the location to four reals (the size of the location) and edited those instead. As far as I know, no leaks (extra locations), and no calls to location editing functions.

@cohadar
Thank you for doing it. I'm still getting errors whenever I do a syntax check so I' guessing its on my end. I'll try to fix it later on today. Btw, I didn't add the scope, private, or anything else yet because I wanted to fix the one error I was getting. Sorry for all the trouble. Oh +rep of course, and yes I do suck at math.
11-15-2007, 04:54 PM#7
cohadar
Please tell me you are using NewGen?
11-15-2007, 05:47 PM#8
Zandose
Yep, I am. Verison 4a.
11-15-2007, 06:18 PM#9
cohadar
Quote:
Originally Posted by Zandose
@cohadar
Thank you for doing it. I'm still getting errors whenever I do a syntax check so I' guessing its on my end.

Syntax checking from TESH does not work.
If the map compiles = it works, that is all you should know.
11-15-2007, 08:55 PM#10
Zandose
Good to know.
11-15-2007, 11:56 PM#11
Pyrogasm
Not sure if anyone pointed this out to you... but this is unbelievably bad to do:
Collapse JASS:
local rect map = GetPlayableMapRect() //clean up after
//...
call RemoveRect(map)
There's no reason to destroy that rect. If you do, it will fuck with a lot of stuff (mainly GUI). Simply use the global variable bj_mapInitialPlayableArea to refer to the rect. There's no need to remove or null it then.
11-16-2007, 01:09 AM#12
Zandose
I didn't know about bj_mapInitialPlayableArea and thought that when I called GetPlayableMapRect() it created a new location.
11-16-2007, 03:11 AM#13
Pyrogasm
Quote:
Originally Posted by Zandose
I didn't know about bj_mapInitialPlayableArea and thought that when I called GetPlayableMapRect() it created a new location.
"Rect" you mean, and no it doesn't.