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

custom-text trigger (compiling errors)

Status
Not open for further replies.
Level 3
Joined
Dec 17, 2017
Messages
39
hey, im trying to use a mouse-controlled camera-system (made by Zwiebelchen: heres the thread )
in my map but when i save or test it, it deactivates the trigger, indicating an compiling error.
Is this because of the 1.29 update doesnt support something anymore or is there another problem? is there a way to make it work? Sry, i dont have knowledge about Jass..
I upload the map here.
thanks in advances:)
 

Attachments

  • Mouse check 2.w3m
    16.9 KB · Views: 46
Level 7
Joined
Dec 28, 2014
Messages
83
It is possible to make this trigger, you have to translate it from vJass to Jass manually.

To show you how you translate it, here's an example:


upload_2018-6-10_19-4-48.png



Since it is impossible to declare Jass global variables in the standard World Editor, you have to rely on the GUI Variable Editor. In Jass, all GUI variables should be name with a namespace udg_.

For MouseCam_AoaSpeed, it would be named like:
vJASS:
udg_MouseCam_AoaSpeed

vJASS:
function MouseCam_GlobalVariables takes nothing returns nothing
    // Constants variables
    set udg_MouseCam_BoundOffset = 1
    set udg_MouseCam_Interval = 0.05
    set udg_MouseCam_RotationSpeed = 1
    set udg_MouseCam_AoaSpeed = 1
    set udg_MouseCam_Precision = 0.1
    set udg_MouseCam_Key_None = 0
    set udg_MouseCam_Key_Left = 1
    set udg_MouseCam_Key_Up = 2
    set udg_MouseCam_Key_Right = 3
    set udg_MouseCam_Key_Down = 4
    // Non-constant variables
    set udg_MouseCam_Key = 0
    set udg_MouseCam_U = null
 
    set udg_MouseCam_toggle = false
    set udg_MouseCam_StoredX = 0
    set udg_MouseCam_StoredY = 0
    set udg_MouseCam_initialized = false 
endfunction
function MouseCam_ApplyCameraForPlayer takes unit u, player p returns nothing
    if GetLocalPlayer() == p then
        set udg_MouseCam_U = u
    endif
endfunction
function MouseCam_CamMovementToArrowKey takes real dx, real dy returns integer
    local real AngleCamera = GetCameraField(CAMERA_FIELD_ROTATION) * bj_RADTODEG
    local real AngleDirection = Atan2(dy, dx) * bj_RADTODEG
    local real Delta = AngleCamera - AngleDirection
    if (RAbsBJ(dx) < udg_MouseCam_Precision) and (RAbsBJ(dy) < udg_MouseCam_Precision) then //within precision margin, assume no camera movement
        return udg_MouseCam_Key_None
    endif
    set Delta = Delta + 45
    if Delta > 360 then
        set Delta = Delta - 360
    elseif Delta < 0 then
        set Delta = Delta + 360
    endif
    return R2I(Delta/90.0)
endfunction
function MouseCam_Periodic takes nothing returns nothing
    local real x = GetUnitX(udg_MouseCam_U)
    local real y = GetUnitY(udg_MouseCam_U)
    if GetUnitTypeId(udg_MouseCam_U) != 0 then
        set udg_MouseCam_toggle = not udg_MouseCam_toggle
        if udg_MouseCam_toggle then
            set udg_MouseCam_Key = MouseCam_CamMovementToArrowKey(GetCameraTargetPositionX()-udg_MouseCam_StoredX, GetCameraTargetPositionY()-udg_MouseCam_StoredY)
            call SetCameraBounds(x, y, x, y, x, y, x, y)
            set udg_MouseCam_StoredX = x
            set udg_MouseCam_StoredY = y
        else
            call SetCameraBounds(udg_MouseCam_StoredX-udg_MouseCam_BoundOffset, udg_MouseCam_StoredY-udg_MouseCam_BoundOffset, udg_MouseCam_StoredX-udg_MouseCam_BoundOffset, udg_MouseCam_StoredY+udg_MouseCam_BoundOffset, udg_MouseCam_StoredX+udg_MouseCam_BoundOffset, udg_MouseCam_StoredY+udg_MouseCam_BoundOffset, udg_MouseCam_StoredX+udg_MouseCam_BoundOffset, udg_MouseCam_StoredY-udg_MouseCam_BoundOffset)
        endif
    else
        set udg_MouseCam_Key = udg_MouseCam_Key_None
    endif
    if udg_MouseCam_Key == udg_MouseCam_Key_Left then
        call BJDebugMsg("Left")
    elseif udg_MouseCam_Key == udg_MouseCam_Key_Up then
        call BJDebugMsg("Up")
    elseif udg_MouseCam_Key == udg_MouseCam_Key_Right then
        call BJDebugMsg("Right")
    elseif udg_MouseCam_Key == udg_MouseCam_Key_Down then
        call BJDebugMsg("Down")
    endif
endfunction
function MouseCam_init takes nothing returns nothing
    local timer t = CreateTimer()
 
    set udg_MouseCam_U = CreateUnit(GetLocalPlayer(), 'hfoo', 0, 0, 0)
 
    call TimerStart(t, udg_MouseCam_Interval, true, function MouseCam_Periodic)
    set t = null
endfunction
function InitTrig_MouseCam takes nothing returns nothing
    call MouseCam_GlobalVariables()
    call MouseCam_init()
endfunction

Everything within the library MouseCam in vJass, in Jass you have to rely on using a namespace like "MouseCam_" on your global variables and functions. In my translation, I ignored most of the private access modifiers since it will make the code a bit longer longer. If it is a private access modifier, it should named as MouseCam__p_Periodic. Everything in my example uses a public access modifier when compared it to vJass.

vJASS:
function smooth_init takes nothing returns nothing
    call CameraSetSmoothingFactor(2.4)
endfunction
function InitTrig_smooth takes nothing returns nothing
    call smooth_init()
endfunction

It same goes to this library.

I added a sample map in the attachment.
 

Attachments

  • Mouse check 2.w3m
    19.5 KB · Views: 34
Level 3
Joined
Dec 17, 2017
Messages
39
hey, thank you for the detailed explanation and the code and map:)
at the moment i have a lot of work in rl, but ill go through it as soon as i find some spare time! ill give report if it works or if im to stupid to get it done, but that may take a few weeks as it looks now.
greetings:)
 
Status
Not open for further replies.
Top