System Trackables (Extended Trackables)

Reaction score
341
Trackables
TriggerHappy187​
Current Version v1.01

This is a little library i made that extends the functions of trackables... and thats about it.
What is a trackable?
A trackable is a model displayed in the game, similiar to a special effect.
It stands out by being able to detect whenever the mouse moves over this model, and when the mouse clicks it.
Problems are that we cannot delete, move or hide a trackable again. - Katana

Credits
  • KaTTaNa - For CreateTrackableZ

Changelog

Version 1.01
  • Inlined Functions
  • New Function ClearTrackableData

Functions - 9 Total
JASS:
function CreateTrackableEx takes string trackableModelPath, real x, real y, real f returns trackable


JASS:
function GetTrackableX takes trackable t returns real


JASS:
function GetTrackableY takes trackable t returns real


JASS:
function GetTrackableZ takes trackable t returns real


JASS:
function GetTrackableFacing takes trackable t returns real


JASS:
function GetTrackableLoc takes trackable t returns location


JASS:
function CreateTrackableZ takes string s, real x, real y, real z, real f returns trackable


JASS:
function CreateTrackablePlayerZ takes player p, string s, real x, real y, real z, real f returns trackable


JASS:
function CreateTrackablePlayer takes player p, string trackableModelPath, real x, real y, real facing returns trackable


JASS:
function ClearTrackableData takes nothing returns nothing

Library

JASS:
library TrackableSystem

globals
    private constant gamecache TRACK_DATA = InitGameCache("TrackableSystem.w3v")
endglobals

private function H2I takes handle h returns integer
    return h
    return 0
endfunction

private struct Data
    
    real x
    real y
    real f
    real z
    
    static method create takes real x, real y, real f, real z, trackable t returns Data
        local Data d = Data.allocate()
        set d.x = x
        set d.y = y
        set d.f = f
        set d.x = x
        call StoreInteger(TRACK_DATA, I2S(H2I(t)), "", d)
        return d
    endmethod
    
endstruct

function ClearTrackableData takes nothing returns nothing
    call FlushGameCache(TRACK_DATA)
endfunction

function CreateTrackableEx takes string trackableModelPath, real x, real y, real f returns trackable
    local trackable t = CreateTrackable(trackableModelPath, x, y, f)
    local Data d = Data.create(x,y,f,0,t)
    return t
endfunction

function GetTrackableX takes trackable t returns real
    return Data(GetStoredInteger(TRACK_DATA, "", I2S(H2I(t)))).x
endfunction

function GetTrackableY takes trackable t returns real
    return Data(GetStoredInteger(TRACK_DATA, "", I2S(H2I(t)))).y
endfunction

function GetTrackableZ takes trackable t returns real
    return Data(GetStoredInteger(TRACK_DATA, "", I2S(H2I(t)))).z
endfunction

function GetTrackableFacing takes trackable t returns real
    return Data(GetStoredInteger(TRACK_DATA, "", I2S(H2I(t)))).f
endfunction

function GetTrackableLoc takes trackable t returns location
    local Data d = GetStoredInteger(TRACK_DATA, "", I2S(H2I(t)))
    return Location(d.x, d.y)
endfunction

function CreateTrackableZ takes string s, real x, real y, real z, real f returns trackable
    local destructable d = CreateDestructableZ('OTip',x,y,z,0.00,1,0)
    local trackable tr = CreateTrackableEx(s,x,y,f)
    call RemoveDestructable(d)
    set d = null
    return tr
endfunction

function CreateTrackablePlayerZ takes player p, string s, real x, real y, real z, real f returns trackable
    local destructable d = CreateDestructableZ('OTip',x,y,z,0.00,1,0)
    local string path = ""
    if GetLocalPlayer() == p then
        set path = s
    endif
    call RemoveDestructable(d)
    set d = null
    return CreateTrackable(path,x,y,f)
endfunction

function CreateTrackablePlayer takes player p, string trackableModelPath, real x, real y, real facing returns trackable 
    local string path = ""
    if GetLocalPlayer() == p then
        set path = trackableModelPath
    endif
    return CreateTrackableEx(path, x, y, facing)
endfunction


endlibrary


Enyjoy!
 

Attachments

  • Trackables.w3x
    9.2 KB · Views: 193

Romek

Super Moderator
Reaction score
964
This seems like a bunch of BJs. Not much usability, really.

---------

JASS:
call StoreInteger(TRACK_DATA, I2S(H2I(t)), I2S(H2I(t)), d)

Any reason why you're using "I2S(H2I(t))" twice there?
Just make the second string "a" or something.

---------

JASS:
local Data d = GetStoredInteger(TRACK_DATA, I2S(H2I(t)), I2S(H2I(t)))
    return d.z

Could be:
JASS:
return Data(GetStoredInteger(TRACK_DATA, I2S(H2I(t)), I2S(H2I(t)))).z


...And that applies to all the other, similar (BJ-ish) functions.
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
Romek, your optimizing will also get inlined by Jasshelper. (I think it will.)
 

Ghostwind

o________o
Reaction score
172
What the fuck does this do? Explanations for newbies FTW.

This seems like a bunch of BJs. Not much usability, really.

Really? If I could have a bunch of BJs I'd be pretty damn happy ;P
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> In what way?

Well, for example, by looking at post #1... I've no idea what I would do with this. Or what the point of this library would be. Or why I would need it if I were to use trackables.


Btw, the correct way to use a gamecache is init - flush - init, in that order.
 
Reaction score
341
I've no idea what I would do with this

Well, it is useful for full screen things (Inventories, Menus ect..) and also could be useful for some mini-games.

I know i'll be using it so.... Just because you have no use for it doesn't mean others wont.

Btw, the correct way to use a gamecache is init - flush - init, in that order.

Thanks.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> it is useful ...

I hope so.
But, what for? What is this? What is it doing? Why would I want to use your library for it?

You're posting here in "tutorials and resources".
The required minimum is a decent description and explanation!
For now it's just a bunch of functions.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Gamecache is a bit outdated, but that doesn't make it a bad system. :p

This seems like a bunch of BJs. Not much usability, really.

Yes it is an extra function call, but the point of a system is to make something easier. In this case, I don't think someone's going to want to type out

JASS:
local Data d = GetStoredInteger(TRACK_DATA, I2S(H2I(t)), I2S(H2I(t)))
    local location l = Location(d.x, d.y)
    ...
    DoSomething(l)


That I2S(H2I()) stuff is a bit tedious. This will also automatically store all the variables, so you only have to create with one function call, instead of doing a bunch of others.

Anyways, back to the original system:

JASS:
        call StoreInteger(TRACK_DATA, I2S(H2I(t)), I2S(H2I(t)), d)


save a few function calls and just do this:

JASS:
        call StoreInteger(TRACK_DATA, I2S(H2I(t)),"", d)


Each time they want to use the trackable.

BTW, since you're creating a local integer variable, I'm pretty sure functions like this:

JASS:
function GetTrackableX takes trackable t returns real
    local Data d = GetStoredInteger(TRACK_DATA, I2S(H2I(t)), I2S(H2I(t)))
    return d.x
endfunction


won't get inlined.

Inlining Rules:

Code:
How to make a function inlineable? The current algorithm basically follows these rules (which are subject to change to allow more functions to be considered inlineable in the future):

    * The function is a one-liner
    * If the function is called by call the function's contents must begin with set or call or be a return of a single function.
    * If the inlined function is an assigment (set) it should not assign one of its arguments.
    * Every argument must be evaluated once and only once by the function, in the same order as they appear in the arguments list.
    * If the function contains function calls, they should all be evaluated after the arguments UNLESS the function is marked as non-state changing, at the moment some very few native functions and also return bug exploiters are considered as non-state changing.

you might be able to do this for some of them (not sure if this syntax is possible):

JASS:
function GetTrackableX takes trackable t returns real
    return Data(GetStoredInteger(TRACK_DATA, I2S(H2I(t)),"")).x
endfunction


But this would probably make it inline-able if it doesn't give any errors.
 

Romek

Super Moderator
Reaction score
964

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Yep. However there is some problem with Gamecaches, which requires you initialize it, flush it, and initialize it again.

JASS:
...
        call StoreInteger(TRACK_DATA, I2S(H2I(t)), "", d)
...
    return Data(GetStoredInteger(TRACK_DATA, "", I2S(H2I(t)))).x
...

You have to keep the order of the "" and the I2S(H2I(t)) the same throughout. Either put I2S(H2I(t)) first, and then "" or the other way around.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top