HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Global variable in Jass?

12-06-2006, 12:51 PM#1
RaveEye
How do I create a global trackabel variable in jass, like you can in WEU?
-thanks
12-06-2006, 01:50 PM#2
wyrmlord
You need to edit the map script, to do this simply go to file -> export map script. Then open up the map script file in notepad or program of your choice. To add a global, put the variable somewhere after globals and before endglobals. Like so:
Collapse JASS:
globals
    gamecache udg_cache
    handle your_name
    trackable your_trackable
endglobals

And when you're done, you must import the map script back into your map.
12-06-2006, 02:03 PM#3
RaveEye
I have tryed that. It dosent work.
12-06-2006, 02:51 PM#4
DioD
wc3\UI

This file adds trigger action you can edit it and add ANY type to GUI
Attached Files
File type: zipTriggerData.zip (47.7 KB)
12-06-2006, 03:46 PM#5
RaveEye
Thats to complicated for me

Do you really need to edit so much to use global trackable? -
there must be an easyer way.
12-06-2006, 04:29 PM#6
The)TideHunter(
Theyre is no GUI function for trackables, so blizzard dident need to put trackables into the global list for GUI variables section.

You dont need it global anyways, just use the return bug and a I2Trackable function.
All you need is a global gamecache. Call it GC. (Create via GUI variable editor - Ctrl+x)

Example:

Collapse JASS:
function GC takes nothing returns gamecache
    if(udg_GC==null)then
        call FlushGameCache(InitGameCache("GC"))
        set udg_GC=InitGameCache("GC")
    endif
    return udg_GC
endfunction

function H2I takes handle H returns integer
    return H
    return 0
endfunction

function I2Trackable takes integer I returns trackable
    return I
    return null
endfunction

function SaveTrackable takes trackable t, string s returns nothing
    call StoreInteger(GC(), "trackables" , s, H2I(t))
endfunction
function LoadTrackable takes string s returns trackable
    return I2Trackable(GetStoredInteger(GC(), "trackables", s))
endfunction

I also added SaveTrackable and LoadTrackable, if you are familiar with Jass, you will know how to use them easily.

Anyway, just to show:

Collapse JASS:
function Hi takes nothing returns nothing
    local trackable t = LoadTrackable("MyTrackable")
    // Do stuff
endfunction

function Bye takes nothing returns nothing
    local trackable t = CreateTrackable(...)
    call SaveTrackable(t, "MyTrackable")
endfunction

That will pass the trackable in function Bye into function Hi, pretty simple.
Just paste the code i gave you at the top and put it into your main map script section and these 2 functions will be active.

If your having trouble you know where to post :).
12-06-2006, 04:30 PM#7
Jazradel
Just use the global variable dialog or use vexorian's pre-processor.
12-06-2006, 04:47 PM#8
The)TideHunter(
Quote:
Originally Posted by Jazradel
Just use the global variable dialog or use vexorian's pre-processor.

I see no Trackable in the GUI Variable editor, and Vexorian's preprocessor is alot for a small job.
Attached Images
File type: jpgtrackablenogui.jpg (47.1 KB)
12-06-2006, 05:03 PM#9
Rising_Dusk
Generally, if you ever have the need to manage global trackables, it isn't going to be a "small job."
Use Vex's preprocessor, you'll find it not only useful to be able to declare globals on the fly, but you'll find it useful in other ways as well.

I believe this is the link to it.
12-06-2006, 06:18 PM#10
Vexorian
gamecache is a lot for a small job
12-06-2006, 09:38 PM#11
RaveEye
Thanks TideHunter It work perfect! +rep
12-07-2006, 10:10 PM#12
PandaMine
What exactly are global trackables, I have never heard of them
12-07-2006, 10:11 PM#13
shadow1500
Quote:
Originally Posted by PandaMine
What exactly are global trackables, I have never heard of them
Collapse JASS:
globals
     trackable t = null
endglobals
12-07-2006, 10:13 PM#14
PandaMine
Oh i see its just a variable name, im an idiot