• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] DisplayTextToForce does not display

Status
Not open for further replies.

Ardenian

A

Ardenian

I had this problem quite a few times. If I would like to test my systems, then DisplayTextToForce does not print a message.

How shall I interpret that ? Runs something infinitely and prevents the printing ?
 

Ardenian

A

Ardenian

post an example trigger

Aight, but it is a quite big example trigger.

  • Example
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set TestPoint = (Position of TestUnit)
      • Custom script: set udg_TestInteger = GetTerrainTypeInRange( udg_TestPoint, "blight", 500, "circle")
      • Custom script: call DisplayTextToForce( GetPlayersAll(), "Test : " + I2S(udg_TestInteger)
^Does not print message

Corresponding functions:

JASS:
//***

function GetTileCenterCoordinate takes real a returns real
    if (a >= 0.) then
        set a = R2I((a/128) + .5)
    else
        set a = R2I((a/128) - .5)
    endif
    return a*128
endfunction    

//***

function IsTerrainType takes real x, real y, string tt, integer ic returns integer
    if tt != "blight" and tt != "water" then    
         //actions when a terrain type is searched
        if GetTerrainType( x, y) == S2I(tt) then
            set ic = ic + 1
            return ic 
        else
            return ic 
        endif
    
    elseif tt == "blight" then
        if IsPointBlighted( x, y) == true then
            set ic = ic + 1
            return ic 
        else
            return ic
        endif
    
    elseif tt == "water" then 
        if IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x,y,PATHING_TYPE_AMPHIBIOUSPATHING) then
            set ic = ic + 1
            return ic 
        else
            return ic
        endif    
    endif
    return ic
endfunction

function GetTerrainTypeInRange takes location p, string tt, integer range, string s returns integer
    local integer pn = 1 // algebraic sign +/-
    local integer ic = 0 // counts matching tiles
    local real x 
    local real y  
    local real x2
    local real y2
    local real y3
    set x = GetLocationX(p)
    set y = GetLocationY(p)
    set x = GetTileCenterCoordinate(x) // x of the next tile center to a point
    set y = GetTileCenterCoordinate(y) // y of the next tile center to a point
    set ic = IsTerrainType( x, y, tt, ic) // check the initial tile
    
    if s == "circle" then
        loop // decide direction, first positive, then negative  
        exitwhen pn < -1 // runs two times, once positive and once negative 
    
            set x = GetTileCenterCoordinate(GetLocationX(p)) // reset to inital tile
            set x2 = x 
            set y = GetTileCenterCoordinate(GetLocationY(p)) // reset to inital tile
            set y2 = y
            set y3 = y
    
            loop // update x tile, moving along the x axis dependent on pn 
            exitwhen DistanceBetweenPoints( p, Location(x2, y)) > range
                    set x2 = x2 + 128*pn
                    set ic = IsTerrainType( x2, y, tt, ic) // check tiles on the x axis
                
                    // go up and down in y direction
                    loop 
                    exitwhen DistanceBetweenPoints( p, Location(x2, y2)) > range
                    
                        set y2 = y2 + 128
                        set ic = IsTerrainType( x2, y2, tt, ic) // check tiles on the positive y branch
                
                    endloop
                    loop
                    exitwhen DistanceBetweenPoints( p, Location(x2, y3)) > range    
                    
                        set y3 = y3 - 128
                        set ic = IsTerrainType( x2, y3, tt, ic) // check tiles on the negative y branch
            
                    endloop    
     
            
            endloop
            set pn = -1 // reverse direction, run again once
        endloop
    
    endif
    return ic
endfunction
 
Last edited by a moderator:

Ardenian

A

Ardenian

Yup, it does, thanks.

Any idea what could be wrong in the function that could result into its end ?

EDIT:
It's likely that you have invalid actions in your code which immediately ends the function or trigger. Examples include using undeclared variables, divide by zero, etc.

Sorry, missed you.

Well, I don't get syntax errors. What else could it be ?
 

Ardenian

A

Ardenian

Thanks, I am going to try that when future problems occur
 
Status
Not open for further replies.
Top