HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JASS Question

05-17-2006, 11:18 PM#1
Sir-LoynStake
Teaching myself JASS, with the help of JassCraft and Vexorian's first JASS tutorial.
I have been replacing all my old map's gui triggers with jass, to get some exp and to possibly enhance it some. I was just wondering if I could define something like my own native :

Collapse JASS:
TextToPlayer takes player toPlayer, string playertext returns nothing

Instead of using the native "DisplayTextToPlayer", or making ^that^ use the native, turning it to a useless function. Well, I guess this whole thing is useless, but I'm like that...

Yes, I am lazy and want to reduce the number of typed characters by like 5. Also, it would be cool to define my own "natives".

Also: Why are real x and real y arguments in "DisplayTextToPlayer"?
05-17-2006, 11:26 PM#2
Meanie
Hmm..how i understand your problem it something like this....you are to lazy to write that native....and there is another BJ function(useless function) who is called
Collapse JASS:
BJDebugMsg takes string text returns nothing

shorter call and just writes (text) for all players
05-17-2006, 11:31 PM#3
Blade.dk
As far as I know, you can't make your own natives, unless you use xttoc's jAPI, but that is probably too much work for a small thing like this.

You can just create a function that passes the values to the native, and place the function in top of your map's custom script section. Then you can all it everywhere below, even though it is kind of a bad idea, as it will make your map run slower. In my opinion, it would be better to type 5 more characters.

But if you want to make it, the function should look like this:

Collapse JASS:
function TextToPlayer takes player toPlayer, string playertext returns nothing
    call DisplayTextToPlayer(toPlayer, 0, 0, playertext)
endfunction

The coordinates are used for the position of the text, they should always be 0, 0 for the normal position. An example of a function that uses this is SimError.
05-18-2006, 12:06 AM#4
Sir-LoynStake
Thanks!

So you can make a function that doesn't take all the arguments of a native? That's cool.
05-18-2006, 05:48 AM#5
Blade.dk
Yes, as long as the function just sends some preset values to the native, that works fine. But it is not really a good idea, as it makes takes more time to execute, like the Blizzard.j wrapper functions.