Need help with my vJass trigger!

Regga-Voska

New Member
Reaction score
0
Hi, I am new to vJass, as you can see...
JASS:
//Move and rotate the picked unit, make the owner of the picked unit face the same angle as the picked unit and also pan the camera to the units location.
function Trig_Execute_Player_Reds_Unit_Functions_Func002Func005A takes nothing returns nothing
    call SetCameraFieldForPlayer( GetOwningPlayer(GetEnumUnit()), CAMERA_FIELD_ROTATION, GetUnitFacing(GetEnumUnit()), 0.10 )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetEnumUnit()), udg_Temp_Point_Red, 0.10 )
endfunction

function Trig_Execute_Player_Reds_Unit_Functions_Func002A takes nothing returns nothing
    set udg_Temp_Point_Red = GetUnitLoc(GetEnumUnit())
    set udg_Temp_Point_Red_Two = PolarProjectionBJ(udg_Temp_Point_Red, udg_Move_Red, ( GetUnitFacing(GetEnumUnit()) + udg_Rotation_Red ))
    call SetUnitPositionLoc( GetEnumUnit(), udg_Temp_Point_Red_Two )
    call SetUnitFacingTimed( GetEnumUnit(), ( GetUnitFacing(GetEnumUnit()) + ( udg_Rotation_Red + udg_Bonus_Rotation[1] ) ), 0 )
    call ForGroupBJ( udg_Temp_Group_Red, function Trig_Execute_Player_Reds_Unit_Functions_Func002Func005A )
    call RemoveLocation (udg_Temp_Point_Red)
    call RemoveLocation (udg_Temp_Point_Red_Two)
endfunction

function Trig_Execute_Player_Reds_Unit_Functions_Actions takes nothing returns nothing
    set udg_Temp_Group_Red = GetUnitsOfPlayerAndTypeId(Player(0), 'h000')
    call ForGroupBJ( udg_Temp_Group_Red, function Trig_Execute_Player_Reds_Unit_Functions_Func002A )
    call DestroyGroup (udg_Temp_Group_Red)
endfunction

//Periodic Event "Every 0.02 second"
function InitTrig_Execute_Player_Reds_Unit_Functions takes nothing returns nothing
    set gg_trg_Execute_Player_Reds_Unit_Functions = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Execute_Player_Reds_Unit_Functions, 0.02 )
    call TriggerAddAction( gg_trg_Execute_Player_Reds_Unit_Functions, function Trig_Execute_Player_Reds_Unit_Functions_Actions )
endfunction
//Done
But I got a few errors called Undeclared Variables, and may I ask you guys how to fix them?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Try this:
JASS:
scope Name initializer Init

    globals
        private group Red = CreateGroup()
        private constant integer MoveRed = 100
        private constant integer RotationRed = 100
        private integer array BonusRotation
    endglobals
    
    private function RedGroup takes nothing returns nothing
        local unit eu = GetEnumUnit()
        local real x = GetUnitX(eu)
        local real y = GetUnitY(eu)
        local real x2 = x + MoveRed * Cos(RotationRed * bj_DEGTORAD)
        local real y2 = y + MoveRed * Sin(RotationRed * bj_DEGTORAD)
        
        call SetUnitX(eu, x2)
        call SetUnitY(eu, y2)
        call SetUnitFacingTimed(eu, GetUnitFacing(eu) + (RotationRed + BonusRotation[1]), 0)
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(eu), 0.10)
        endif
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call PanCameraToTimed(x, y, 0.10)
        endif
        call GroupRemoveUnit(Red, eu)
        set eu = null
    endfunction
    
    private function Actions takes nothing returns nothing
        set bj_groupEnumTypeId = 'h000'
        call GroupEnumUnitsOfPlayer(Red, Player(0), filterGetUnitsOfPlayerAndTypeId)
        call ForGroup(Red, function RedGroup)
    endfunction


//====================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()   //Create the trigger
        
        call TriggerRegisterTimerEvent(t, 0.02, true)   //0.02 periodic event
        call TriggerAddAction(t, function Actions)   //Actions for your trigger
    endfunction

endscope
 

Regga-Voska

New Member
Reaction score
0
Try this:
JASS:
scope Name initializer Init

    globals
        private group Red = CreateGroup()
        private constant integer MoveRed = 100
        private constant integer RotationRed = 100
        private integer array BonusRotation
    endglobals
    
    private function RedGroup takes nothing returns nothing
        local unit eu = GetEnumUnit()
        local real x = GetUnitX(eu)
        local real y = GetUnitY(eu)
        local real x2 = x + MoveRed * Cos(RotationRed * bj_DEGTORAD)
        local real y2 = y + MoveRed * Sin(RotationRed * bj_DEGTORAD)
        
        call SetUnitX(eu, x2)
        call SetUnitY(eu, y2)
        call SetUnitFacingTimed(eu, GetUnitFacing(eu) + (RotationRed + BonusRotation[1]), 0)
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(eu), 0.10)
        endif
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call PanCameraToTimed(x, y, 0.10)
        endif
        call GroupRemoveUnit(Red, eu)
        set eu = null
    endfunction
    
    private function Actions takes nothing returns nothing
        set bj_groupEnumTypeId = 'h000'
        call GroupEnumUnitsOfPlayer(Red, Player(0), filterGetUnitsOfPlayerAndTypeId)
        call ForGroup(Red, function RedGroup)
    endfunction


//====================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()   //Create the trigger
        
        call TriggerRegisterTimerEvent(t, 0.02, true)   //0.02 periodic event
        call TriggerAddAction(t, function Actions)   //Actions for your trigger
    endfunction

endscope

Thank you one hundred and twenty five thousand times!
But, I guess I can't just Copy/Paste and replace my current trigger.
Am I correct? Because when I did that all my older errors disappeared BUT it came 53 new errors such as Statement outside of function, Syntax Error, Missing line break etc.
 

Regga-Voska

New Member
Reaction score
0
You can place that into any trigger.
You just need NewGen (You should have it if you're doing vJASS :confused: ) .

That's exactly the same thing I downloaded a few hours ago. And i guess it's working correctly for me.
(When i trying to run the map, the Wc3 intro screen comes up, but the map where never loaded)
And all my variables will/needs to be affected by other triggers.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Could you post a screenshot of the errors or show me some lines that error?

EDIT: Also, make sure to have vJASS Syntax active.
 

Regga-Voska

New Member
Reaction score
0
Could you post a screenshot of the errors or show me some lines that error?

EDIT: Also, make sure to have vJASS Syntax active.

errors.jpg

There you go....
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I just copied the code into a new trigger and it worked fine.

Make a new trigger,
Convert it to custom text;
Then replace everything that's there with the code:
JASS:
scope Name initializer Init

    globals
        private group Red = CreateGroup()
        private constant integer MoveRed = 100
        private constant integer RotationRed = 100
        private integer array BonusRotation
    endglobals
    
    private function RedGroup takes nothing returns nothing
        local unit eu = GetEnumUnit()
        local real x = GetUnitX(eu)
        local real y = GetUnitY(eu)
        local real x2 = x + MoveRed * Cos(RotationRed * bj_DEGTORAD)
        local real y2 = y + MoveRed * Sin(RotationRed * bj_DEGTORAD)
        
        call SetUnitX(eu, x2)
        call SetUnitY(eu, y2)
        call SetUnitFacingTimed(eu, GetUnitFacing(eu) + (RotationRed + BonusRotation[1]), 0)
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(eu), 0.10)
        endif
        if(GetLocalPlayer() == GetOwningPlayer(eu)) then
            call PanCameraToTimed(x, y, 0.10)
        endif
        call GroupRemoveUnit(Red, eu)
        set eu = null
    endfunction
    
    private function Actions takes nothing returns nothing
        set bj_groupEnumTypeId = 'h000'
        call GroupEnumUnitsOfPlayer(Red, Player(0), filterGetUnitsOfPlayerAndTypeId)
        call ForGroup(Red, function RedGroup)
    endfunction


//====================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()   //Create the trigger
        
        call TriggerRegisterTimerEvent(t, 0.02, true)   //0.02 periodic event
        call TriggerAddAction(t, function Actions)   //Actions for your trigger
    endfunction

endscope
 

GooS

Azrael
Reaction score
154
I started the editor by pressing the Icon called NewGen WE.exe

vJASS requires you to actually save the map before testing it, otherwise it will just go to the wc3 main menu.

Also, the syntax checker is outdated (?) and does not work with vJASS, save is your only option of compiling.

Save before test map, always.
Even the slightest nudge in the code and you will have to re-compile the code.
Hope that works.

//==GooS
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Ahh yeah.
Don't use the "Syntax Check" button.
Just Save (CTRL + S) the map and if nothing comes up you're good!
 

Regga-Voska

New Member
Reaction score
0
Huh?

Okey, now the unit moves. But not when I want it to...
(It moves constantly)

EDIT: And it only moves right. It should move forward. (The angle of the unit)
I will give you an example, when the unit looks right, he should move right. When the unit looks left, it should move left etc.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top