• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

A fairly easy jass question

Status
Not open for further replies.
I have a problem primarily caused by forgetfulness, I've made a function that takes a real and returns a string in form of a bar of "|"s.

Well my problem is I can't quite remember to call that function from inside a command, I need it to return a bar for my multiboard system, so if anyone could help me with this and give me the exact way to do it I'll be happy. :)

Rep will be rewarded if it do any difference
 
Well, more like:
  • Custom script: set udg_string = YourFunction(udg_integer)
As it returns a string.

This is somewhat, what I was looking for.
An example could be
call DisplayTexttoForce( AllPlayers(), Barconversion(10.) )

I know "DisplayTexttoForce" may not be an actual function, I just don't have access to an we while on my labtop. I want to know if its the right way to call it inside another line of command, so to speak.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
It is an actual function :p (Well, kinda: JASS functions are CamelCased (the first letter of each word is capitalized), so the function is: DisplayTextToForce.
Just a side-note: if you're going to use "all players", DisplayTextToPlayer(GetLocalPlayer(), ...) is better.

If you want to call it inside another JASS script ( = custom script), then using Pharaoh's method is better (as you can directly insert it in your JASS script without having to store it inside a variable first).
If you're going to use it in GUI, however, then storing it in variable would be better.

Here's the difference:

  • Custom script: DisplayTextToPlayer(GetLocalPlayer(), 0., 0., YourFunction(integer))
This is Pharaoh's method. Without storing it in a variable, you can still use it to display a message (or whatever it is you want), because you're using it in a JASS script.

  • Custom script: set udg_string = YourFunction(integer)
  • Custom script: call DisplayTextToPlayer(GetLocalPlayer(), 0., 0., udg_string)
This isn't advised. The "string"-variable is pretty useless if you only use it once.

  • Custom script: set udg_string = YourFunction(integer)
  • Game - Display to (All players) the text: string
Even though JASS is faster, this would be the best option for GUI.


So, there you have it. Choose wisely :)
 
It is an actual function :p (Well, kinda: JASS functions are CamelCased (the first letter of each word is capitalized), so the function is: DisplayTextToForce.
Just a side-note: if you're going to use "all players", DisplayTextToPlayer(GetLocalPlayer(), ...) is better.

If you want to call it inside another JASS script ( = custom script), then using Pharaoh's method is better (as you can directly insert it in your JASS script without having to store it inside a variable first).
If you're going to use it in GUI, however, then storing it in variable would be better.

Here's the difference:

  • Custom script: DisplayTextToPlayer(GetLocalPlayer(), 0., 0., YourFunction(integer))
This is Pharaoh's method. Without storing it in a variable, you can still use it to display a message (or whatever it is you want), because you're using it in a JASS script.

  • Custom script: set udg_string = YourFunction(integer)
  • Custom script: call DisplayTextToPlayer(GetLocalPlayer(), 0., 0., udg_string)
This isn't advised. The "string"-variable is pretty useless if you only use it once.

  • Custom script: set udg_string = YourFunction(integer)
  • Game - Display to (All players) the text: string
Even though JASS is faster, this would be the best option for GUI.


So, there you have it. Choose wisely :)

Wasn't really going to use in the function: "DisplayTextToForce", was just the only function I could somehow remember without the help of NewGen JASSHELPER. Was using it in my multiboard, couldn't just remember the line for that. Was also going to use it in Pharaoh's way, although I didn't know it was called that. Thank you very much sir, was exactly what I needed. +REP
 
Status
Not open for further replies.
Top