• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Floating Text

Status
Not open for further replies.
Level 3
Joined
Jun 16, 2016
Messages
50
Hello guys im tryin to understand those scripts , so i downloaded the Bpowers Floating Text Script/System
and i just want to know if there is a way to trigger the floating text api by GUI ?

DmeoTrigger :

JASS:
scope Demo initializer Init

    globals
        private ScrollingText SW
    endglobals

    // You can colorize each line or char via color codes.
    private function SetText takes nothing returns nothing
        local ScrollingText text = ScrollingText.create(TREBUCHET_MS)
   
        call text.addLine("|cffffd700It is a period  of civil war.", 12, 0.)
        call text.addLine("|cffffd700Rebel  spaceships ,  striking", 12, 0.)
        call text.addLine("|cffffd700from  a  hidden base,  have", 12, 0.)
        call text.addLine("|cffffd700won  their   first  victory", 12, 0.)
        call text.addLine("|cffffd700against  the  evil Galactic", 12, 0.)
        call text.addLine("|cffffd700Empire.", 12, 0.)
        call text.addLine(null, 12, 0.)
        call text.addLine(null, 12, 0.)
        call text.addLine("|cffffd700During  the   battle, rebel", 12, 0.)
        call text.addLine("|cffffd700spies   managed   to steal", 12, 0.)
        call text.addLine("|cffffd700secret plans to the Empire's", 12, 0.)
        call text.addLine("|cffffd700ultimate   weapon ,   the", 12, 0.)
        call text.addLine("|cffffd700DEATH STAR, an armored", 12, 0.)
        call text.addLine("|cffffd700space station  with enough", 12, 0.)
        call text.addLine("|cffffd700power to destroy an entire", 12, 0.)
        call text.addLine("|cffffd700planet.", 12, 0.)
        call text.addLine(null, 12, 0.)
        call text.addLine(null, 12, 0.)
        call text.addLine("|cffffd700Pursued   by  the  Empire's", 12, 0.)
        call text.addLine("|cffffd700sinister   agents ,  Princess", 12, 0.)
        call text.addLine("|cffffd700Leia races home  aboard her", 12, 0.)
        call text.addLine("|cffffd700starship , custodian  of the", 12, 0.)
        call text.addLine("|cffffd700stolen plans that can save", 12, 0.)
        call text.addLine("|cffffd700her  people   and  restore", 12, 0.)
        call text.addLine("|cffffd700freedom to  the galaxy ...", 12, 0.)
   
        set SW = text
    endfunction

    private function Skip takes nothing returns nothing
                                                      // Velocity
        call DisplayScrollingText(SW, 0, 0, 300, 300, 1.)
    endfunction

    private function CreateEscWarning takes nothing returns nothing
        local textsplat s = textsplat.create(TREBUCHET_MS)
        call s.setText("Press Esc Start / Restart!", 28, 0)
        call s.setPosition(0, 0 - s.height*.5, 0)
        call SetCameraPosition(s.width*.5, s.height)
        set s.permanent = false
        set s.lifespan  = 1
    endfunction

    private function Init takes nothing returns nothing
        call CreateEscWarning()
        call SetText()
        call SetCameraField(CAMERA_FIELD_ROTATION, 90., 0.)
        call TryInitCinematicBehaviorBJ()
        call TriggerAddAction(bj_cineSceneBeingSkipped, function Skip)
    endfunction

endscope

As i can see in the last lines this code executes after map init (?)

Code:
    private function Init takes nothing returns nothing
        call CreateEscWarning()
        call SetText()
        call SetCameraField(CAMERA_FIELD_ROTATION, 90., 0.)
        call TryInitCinematicBehaviorBJ()
        call TriggerAddAction(bj_cineSceneBeingSkipped, function Skip)
    endfunction

But when i was tryin to make my action in GUI then coverting to Custom Text (Jass mby?)
After i tried to compile it , jasshelper told me that something is wrong(Doesnt remeber what it was)
So i thought thatw would be okay if i try to use custom script like this
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Custom script: call DisplayScrollingText(SW, 0, 0, 300, 300, 1.)
But JassHelper while compiling told me that variable SW have been declared yet.

So, Then.. i tried to
  • set SW=test
But obviously it still wasnt workin'
..So is there any option to Fire this floating text by GUI or i have to do it in Jass?
And if i have to do , could anyone help me with it ? I'm just lost over there
 
Last edited:
Level 3
Joined
Jun 16, 2016
Messages
50
Scrolling Text v.1.1

If u will be that honeyly , i just need to create that "text" after 1 second after map init
In the certain region to make units lock camera in there

Misnaned thread its scrolling text
 
Last edited:
Level 3
Joined
Jun 16, 2016
Messages
50
@IcemanBo Well , as i can see Jass/vJass isnt different from Php and c+ so thats why i'm tryin' to ask ya.I cant find a tutorial on how to use linked libraries in jass. If u know about one , feel free to link it
 
Level 3
Joined
Jun 16, 2016
Messages
50
Okay so i think i just get how to this.

I've look'd into this code and saw :
Code:
    function DisplayScrollingText takes ScrollingText text, real x, real y, real width, real height, real speed returns nothing
        call STPeriodic.start(text, x, y, width, height, speed, bj_FORCE_ALL_PLAYERS)
    endfunction

So...if i'm not wrong those ones means the parametres and specific region i need to get.
So shall i do it on center of playable map area from global variable?
Or is there any other way to check x y of position ?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
The error you were getting was because you tried to use SW, a private variable, out of scope. Only the Demo scope can 'see' this:
JASS:
globals
      private ScrollingText SW
    //^^^^^^
   endglobals
So in whatever trigger you want to use this library you need to do:
  • Trig
    • Actions
      • ------- this line must be the first in your trigger -------
      • Custom script: local ScrollingText MyTxt = ScrollingText.create(TREBUCHET_MS)
      • ------- these lines may go anywhere -------
      • Custom script: call MyTxt.addline("here is the text", 12, 0.00)
      • Custom script: call DisplayScrollingText(MyTxt,0,0,300,300,1.00)
      • Custom script: call MyTxt.destroy()
Note that this makes a new ScrollingText object and then deletes it every time the trigger runs. This is fine if your text is dynamic (not the same every time this particular trigger should display it) but if it's static you should really create a global ScrollingText like in the demo library and just display that one when you need. Just don't add the private keyword.
 
Last edited:
Level 3
Joined
Jun 16, 2016
Messages
50
Well the private keyword wasnt added by my :D.. Thanks but i alrdy got it , rep

So i got at this

JASS:
local integer i = 1
        local playercolor c

        local ScrollingText text = ScrollingText.create(TREBUCHET_MS)
           loop
        exitwhen i > 12
        set c = GetPlayerColor(Player(i - 1))
        if c == PLAYER_COLOR_RED then
            set udg_PlayerColors[i] = "|c00ff0303"
        elseif c == PLAYER_COLOR_BLUE then
            set udg_PlayerColors[i] = "|c000042ff"
        elseif c == PLAYER_COLOR_CYAN then
            set udg_PlayerColors[i] = "|c001ce6b9"
        elseif c == PLAYER_COLOR_PURPLE then
            set udg_PlayerColors[i] = "|c00540081"
        elseif c == PLAYER_COLOR_YELLOW then
            set udg_PlayerColors[i] = "|c00fffc01"
        elseif c == PLAYER_COLOR_ORANGE then
            set udg_PlayerColors[i] = "|c00ff8000"
        elseif c == PLAYER_COLOR_GREEN then
            set udg_PlayerColors[i] = "|c0020c000"
        elseif c == PLAYER_COLOR_PINK then
            set udg_PlayerColors[i] = "|c00e55bb0"
        elseif c == PLAYER_COLOR_LIGHT_GRAY then
            set udg_PlayerColors[i] = "|c00959697"
        elseif c == PLAYER_COLOR_LIGHT_BLUE then
            set udg_PlayerColors[i] = "|c007ebff1"
        elseif c == PLAYER_COLOR_AQUA then
            set udg_PlayerColors[i] = "|c00106246"
        elseif c == PLAYER_COLOR_BROWN then
            set udg_PlayerColors[i] = "|c004e2a04"
        else
            set udg_PlayerColors[i] = "|c00000000"
        endif
        set udg_PlayerNames[i] =  udg_PlayerColors[i] + GetPlayerName(Player(i - 1)) + "|r"
        set i = i + 1
    endloop

But unfortunately when im tryin to use it in text code like this

JASS:
       call text.addLine("|cffffd700So ...  "  + udg_PlayerNames[i] , 12, 0.)
But the will appear yellow only as P13(Player13) but not as WorldEdit
 
Last edited:
Status
Not open for further replies.
Top