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

JASS Message Linebreaks & BJs

Status
Not open for further replies.

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
Hi. I have a few questions about things working in JASS.

  • First: About line-breaks on text messages (not the actual script, but for using the BJDebugMSG for example). The "|n" does not appear to work.
  • Second: There are certain BJs that feel tempting to use.
    For example, the BJ function that fades in/out of the screen, appears to do a lot of the native typing for us.
    What do you recommend in these situations? Using natives or these BJ quick-functions?

Thank you for your time. Do not be afraid to answer.:razz:
 
Level 11
Joined
Aug 25, 2006
Messages
971
Ok for the first, I'd solve that by simply sending two messages.
JASS:
function This takes nothing returns nothing
    call DisplayTextToPlayer(Player(0),0,0,"This is on one line")
    call DisplayTextToPlayer(Player(0),0,0,"This is on the next line")
endfunction

Not all the bj's are useless. Check them over for leaks first though.

Beware, some bj's are extremely inefficient and can be done in much less code.

For example, heres the bj for setting the value of a multiboard item:
JASS:
function MultiboardSetItemValueBJ takes multiboard mb, integer col, integer row, string val returns nothing
    local integer curRow = 0
    local integer curCol = 0
    local integer numRows = MultiboardGetRowCount(mb)
    local integer numCols = MultiboardGetColumnCount(mb)
    local multiboarditem mbitem = null

    // Loop over rows, using 1-based index
    loop
        set curRow = curRow + 1
        exitwhen curRow > numRows

        // Apply setting to the requested row, or all rows (if row is 0)
        if (row == 0 or row == curRow) then
            // Loop over columns, using 1-based index
            set curCol = 0
            loop
                set curCol = curCol + 1
                exitwhen curCol > numCols

                // Apply setting to the requested column, or all columns (if col is 0)
                if (col == 0 or col == curCol) then
                    set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
                    call MultiboardSetItemValue(mbitem, val)
                    call MultiboardReleaseItem(mbitem)
                endif
            endloop
        endif
    endloop
endfunction
It has one feature I don't need, the ability to set all values at the same time. Without this feature, it becomes much smaller.
JASS:
    function MIB takes multiboard mb, integer col, integer row, string value returns nothing
    local multiboarditem mbitem
        set mbitem = MultiboardGetItem(mb, row -1, col -1)
        call MultiboardSetItemValue(mbitem, value)
        call MultiboardReleaseItem(mbitem)
        set mbitem = null
    endfunction
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Well there is an easy way for this
JASS:
local string ENTER = "
"
call BJDebugMsg("You got"+ENTER+"PWN3D")
// well... Enter button creates a weird character inside text that carries text to down line (bad english)
// But still its a character and we can store it in a variable
Enjoy

About BJ's: I well dont like them
They are slow usualy, but running 50 functions in same thread doesnt seem to make lag,
so I dont have a real reason to say "Dont use them".
But there are good ones if you ask me:
- PanCameraTimedToPlayer (saves me from CnP'ing GetLocalPlayer etc)
- RectContainsCoords, RectContainsUnit (I love these ones)
- GroupAddGroup (pwnaz0rs)
 
Status
Not open for further replies.
Top