• 🏆 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!

[JASS] DisplayTextToForce Long Strings

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
I know this maybe would be a stupid question but, is it ok to place a long string in JASS code? This is an example of some of my code
JASS:
    call DisplayTextToForce( bj_FORCE_PLAYER[0], "Select the game mode (Default is Rush)|n-|c000080ffRush|r: Hordes of desperate and hungry cannibals will be chasing you. |c00808080Stay alive or you lose!|r|n-|c000080ffTeam|r: 2 Separate teams will try to destroy the other team survivors. |c00808080Shaman can revive fallen heroes.|r|n-|c000080ffFree|r: Build freely! You can do whatever you want. If you die, you will be revived! |c00808080Traning Mode.|r" )
I noticed it may sometimes become too long if you want to show a long info text, so I was trying to find the TRIGSTR_#### in the war3map.wts but could only find STRING # instead of TRIGSTR's. Should it be ok by just using the long strings inside the code? Is there some method to make my code look neater? I appreciate your help.

EDIT: Oh, the TRIGSTR location would be really helpful so in case Im using the above method, I can delete all the TRIGSTR's that arent in use. Just map optimization.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Hmm I don't know if there would be any big problem, but you can create your action in GUI. Then change the GUI into Custom Text and normally you should get a string now which you can use instead of the long text.



JASS:
local integer i = 0

loop
    exitwhen i == 11
    call DisplayTimedTextToPlayer(Player(i),0.,0.,10.,"String")
    set i = i + 1
endloop
Greetings
~ The Bomb King > Dr. Boom
 
Level 6
Joined
Feb 12, 2008
Messages
207
Yeah, the trigger from the example was a conversion from GUI, it had a TRIGSTR_3594 but I want to edit the TRIGSTR directly sometime later, someone said all custom strings are stored in that war3map.wts but never found the ones I wanted.
And about your fix: First of all, the text should display only to FORCE 0, that means, Player 1 (Red), not to all. Besides that, is there something wrong with BJ's? I mean, do they hurt my map in any way? Thanks again DrBoom :D
 
Level 6
Joined
Feb 12, 2008
Messages
207
Ok thats good to know, thanks about that. But what with the BJ's? Do they have something wrong so that I shouldn't use them?
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Jeah the rule is, to try to avoid these BJ functions. Also the red marked parts ( If you use Jass New Gen Pack and write triggers in Jass ), because there bad. I don't know why there so bad but there are =D

Edit: I read something [ I don't know if this is the same, but here stands: "string (limit is 1023 signs, actually to provide save/load compatibility it's required to use only 1013 signs)" ]

Greetings
~ The Bomb King > Dr. Boom
 
Level 16
Joined
Feb 22, 2006
Messages
960
actually there are some BJs you can use, but others are just unnecessary. BJ's are non-native function by Blizzard which often contain other native function calls or even other BJ calls. To avoid many function calls one pends to use to call native functions directly.

actually to display a timed text to a player use this function: DisplayTimedTextToPlayer

and Player1(Red) in Jass is Player(0)
 
The war3map.wts should show the initial string table. If you ever need to add something to it, you can either directly input it by modifying the file and importing it back via an MPQ editor, or you can just use the GUI functions and they will place it in TRIGSTRs.

For example, in azeroth grand prix, here are the first two strings shown:
Code:
STRING 1
{
Player 1
}

STRING 3
{
Azeroth Grand Prix
}

I'm guessing simply omitting one will remove it from the table. Just make sure it isn't referenced anywhere else (eg: Object Editor) or it might be added again.

The strings have Id's by integers (as shown), so string 1 would probably be TRIGSTR_001. (just off memory, I'm not positive though)

If you ever want to quickly read your table in game, you can just use this code:
JASS:
function SearchTable takes nothing returns nothing
    local integer i = 0
    local string ss
    loop
        exitwhen i == 1000
        set ss = I2S(i)
        if i < 10 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_00"+ss))
        elseif i < 100 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_0"+ss))
        elseif i < 1000 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_"+ss))
        endif
        set i = i + 1
    endloop
endfunction

Just call it whenever you want, like this:
  • Custom script: call SearchTable()
And it should read the contents. That is useful if you are too lazy to open the war3map.wts over and over again. ;D

TRIGSTR's are fine to use though, and useful in some cases if you want to chew off a few bytes from your map. (lol, it won't make the biggest difference though) AFAIK, TRIGSTR's take 12 bytes each whereas a normal string uses its string length of bytes + 1 byte (for the null char to end the string). If your string is long, it is fine to enter it in the table. ;) It is just more of a hassle to read compared to reading a string in the trigger editor itself.
 
Level 6
Joined
Feb 12, 2008
Messages
207
Yeah, the trigger from the example was a conversion from GUI, it had a TRIGSTR_3594 but I want to edit the TRIGSTR directly sometime later, someone said all custom strings are stored in that war3map.wts but never found the ones I wanted.

Thanks for all your help, I've already opened the damn .wts file but as I said before I could only find STRING and not TRIGSTR. The file ended in somewhere near 3570, so "3594" in this case wasn't showing up either.
If you have some concrete info about this file it would be good to know.

Anyway, using a function to read the table seems pretty nice idea. Ill try that later.
 
Sorry, I guess I didn't look up on the topic enough. D;

Anyway, using the function is essentially the only way to read the table ingame. The actual TRIGSTR's from the trigger editor are stored in the table upon map initialization, opposed to upon saving your map. So what the string table (wts) reads now is different from what it reads in game. At the moment, it only reads the object editor strings, but on map initialization, it will load all the trigger strings entered.

Simply removing all references to a trigger string will automatically remove it from the table. =) And you can always just use the search table function to check to make sure.

Anyway, at the moment that search table function that I posted was a little limited. In a normal game, there will be several thousand strings, so here you can extend it:
JASS:
function SearchTable takes nothing returns nothing
    local integer i = 0
    local string ss
    loop
        exitwhen i == 5000 //loops through the first 5000 strings of the table
        set ss = I2S(i)
        if i < 10 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_00"+ss))
        elseif i < 100 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_0"+ss))
        else
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_"+ss))
        endif
        set i = i + 1
    endloop
endfunction

I don't think the "GetLocalizedString()" part is necessary but I haven't tested it without it.
 
Level 3
Joined
Oct 30, 2020
Messages
20
Sorry, I guess I didn't look up on the topic enough. D;

Anyway, using the function is essentially the only way to read the table ingame. The actual TRIGSTR's from the trigger editor are stored in the table upon map initialization, opposed to upon saving your map. So what the string table (wts) reads now is different from what it reads in game. At the moment, it only reads the object editor strings, but on map initialization, it will load all the trigger strings entered.

Simply removing all references to a trigger string will automatically remove it from the table. =) And you can always just use the search table function to check to make sure.

Anyway, at the moment that search table function that I posted was a little limited. In a normal game, there will be several thousand strings, so here you can extend it:
JASS:
function SearchTable takes nothing returns nothing
    local integer i = 0
    local string ss
    loop
        exitwhen i == 5000 //loops through the first 5000 strings of the table
        set ss = I2S(i)
        if i < 10 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_00"+ss))
        elseif i < 100 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_0"+ss))
        else
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,GetLocalizedString("TRIGSTR_"+ss))
        endif
        set i = i + 1
    endloop
endfunction

I don't think the "GetLocalizedString()" part is necessary but I haven't tested it without it.
String concatenation of TRIGSTR + some string via GetLocalizedString() works in this way
local string str_concat = GetLocalizedString("TRIGSTR_00") + ss
but not GetLocalizedString("TRIGSTR_00"+ss)
 
Status
Not open for further replies.
Top