Couple of weird syntax errors:

Technomancer

New Member
Reaction score
14
Hey, the code so far is ugly, but this is for a new timer system that I'm working on.

JASS:
// These functions and structs are the core of the hit n' run library.
// 
// DOCUMENTATION
// I'm generally bad at documentation so please, if you would like anything explained,
// please, PM me @Technomancer on <a href="http://www.thehelper.net" class="link link--internal">www.thehelper.net</a>, and I&#039;ll add it to the documentation
// 
// ***************************************************************************************
// The general idea is to run your map according to a global timer, instead of creating
// and destroying any number of individual timers, because as a rule we try to cut down
// on trigger events and function calls during the execution of a map, and CreateTimer(),
// DestroyTimer(), and espeically TimerStart(...) and the associated triggers will lag your
// shit up, that&#039;s a gaurentee.  Several maps already incorporate global event timers into
// themselves, this is just a premade package that will allow you to easily do so in your 
// map.
// 
// ***************************************************************************************
// This trigger set uses vJass.  The only other effective system for doing this sort of 
// would be to use gamecache based handle var systems, which in rare cases are buggy,
// but can also slow the game excessively.
//
// ***************************************************************************************
//
// This is how this pacakage will create new timer operated units:
// Step 1) Create a Unit
// Step 2) Create a timer structure (Techno_TimerUnitOnTimerHandle)
// Step 3) Assign a struct of type Techno_GunUnitAttach to the unit&#039;s custom value
//               using ABC attachment system
// Step 4) Create a function with the following arguements:
//            function NAME takes unit interface_unit returns nothing
// Step 5) Assign the unit and an associated function to the timer
//               the timer can now automatically pick out the unit&#039;s necessary 
//               custom values from the attached
//        &#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;
//      EXAMPLE
//        call YOUR_TIMER_STRUCT_NAME.Timer_Add_Unit( YOUR_UNIT_NAME, UNIT&#039;S_FUNCTION_NAME )
//        Obviously, replace the stuff in all caps with your names
//        &#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;               
// Step 5) Activate the timer if necessary.  The timer will automatically pass the unit
//               to the required function.
// Step 7) Any additional data you wish to pass can be passed in the structure you
//         assigned in the Unit&#039;s custom value.  This allows total modularity, because
//         any function that can access the unit can access all of the values that are
//         involved in the function
//                
//
//         I would love some help textmacroing this up to be more modular, so that the unit
//         can take differently named structs, and the function interface can take different
//         arguements if the user so desires.


globals
constant integer MAX_UNITS = 64
endglobals

function interface INTERFACE takes unit interface_unit returns nothing

struct Techno_TimerUnitOnTimerHandle
    private timer T_Timer = CreateTimer()
    private unit array Unit_Array[MAX_UNITS]
    private INTERFACE array Unit_Funcs_Array[MAX_UNITS]
    private real cooldown = .01
    private integer Num_Units = 0
    
    method Timer_Add_Unit takes unit u, INTERFACE f returns nothing
        if (this.Num_Units &lt;= MAX_UNITS) then
            set this.Unit_Array[this.Num_Units] = u
            set this.Unit_Funcs_Array[this.Num_Units] = f
            set this.Num_Units = this.Num_Units + 1
        else
            call BJDebugMsg(&quot;Unit Cap Reached on Timer&quot;)
        endif
        set u = null
    endmethod
    method Timer_Get_Last_Unit takes nothing returns unit
        local unit u = this.Unit_Array[this.Num_Units]
        return u
    endmethod
    method Timer_Remove_Last_Unit takes nothing returns nothing
        set this.Unit_Array[this.Num_Units] = null
        set this.Num_Units = this.Num_Units - 1
    endmethod
    
// ***AWAITING IMPLEMENT***    
    method Timer_Remove_Unit_Enum takes integer unum returns nothing
        //This one could use rescripting...
    endmethod
    
    
    //This function is the function on the timer trigger
    method Timer_Action_Functions takes nothing returns nothing
    local integer i = 0
    local unit u
    local Techno_GunUnitAttach gattach = Techno_GunUnitAttach.create()
    local INTERFACE f
    loop
        exitwhen i &gt; this.Num_Units
            //Get Function Attached GunStruct
            set u = this.Unit_Array<i>
            set gattach = GetUnitUserData(u)
            //***AWAITING IMPLEMENT***
            //***CHECK COOLDOWN OF UNIT TRIGGER***
                //Get associated function of gunstruct
                set f = this.Unit_Funcs_Array<i>
                call f.execute(u)
                set i = i + 1
        endloop
    set u = null
    endmethod
    method Timer_SetCooldown takes real cd returns nothing
        set this.cooldown = cd
    endmethod
    
    //***AWAITING IMPLEMENT***
    //For some reason, the following line of code bugs.
    method Timer_TimerStart takes nothing returns nothing
//        call TimerStart(this.T_Timer, this.cooldown, true, this.Timer_Action_Functions)
    endmethod
    
endstruct

struct Techno_GunUnitAttach
    integer timercounter //counts timer iterations
    integer projectile_unit
    //targetting declares
    integer targetting_function_type = 2
    unit targ1_targettingunit
    real targ2_fixedx
    real targ2_fixedy
    real targ3_angle
    
    method SetProjectileType takes integer UnitType returns nothing
        set this.projectile_unit = UnitType
    endmethod

    method GetProjectileType takes nothing returns integer
        return this.projectile_unit
    endmethod
    
    method GetTimerCounter takes nothing returns integer
        return this.timercounter
    endmethod
    
    method GetTargLocX takes nothing returns real
        if (this.timercounter == 1) then
            return GetUnitX(this.targ1_targettingunit)
        elseif (this.timercounter == 2) then
            return this.targ2_fixedx
        endif
        return 0.
    endmethod
    
    method GetTargLocY takes nothing returns real
        if (this.timercounter == 1) then
            return GetUnitY(this.targ1_targettingunit)
        elseif (this.timercounter == 2) then
            return this.targ2_fixedy
        endif
        return 0.
    endmethod
    
    method GetTargFixedAngle takes nothing returns real
        return this.targ3_angle
    endmethod
    
    method CalcTargAngle_targ1 takes real sourceX, real sourceY returns real
        return (bj_RADTODEG * Atan2( (GetUnitY(this.targ1_targettingunit) - sourceY ), (GetUnitX(this.targ1_targettingunit) - sourceX) ))
    endmethod
    
    method CalcTargAngle_targ2 takes real sourceX, real sourceY returns real
        return (bj_RADTODEG * Atan2( (this.targ2_fixedy - sourceY ) , ( this.targ2_fixedx - sourceX ) ) )
    endmethod

    method GetTargUnit takes nothing returns unit
        return this.targ1_targettingunit
    endmethod
    
    method GetTargFuncType takes nothing returns integer
        return this.targetting_function_type
    endmethod

//    method SetProjectileTargType takes integer t returns null
//    set this.targetting_function_type = t
//    endmethod

    method Init takes unit u, integer i returns nothing
        set this.targetting_function_type = i
        set this.timercounter = 0
        set this.projectile_unit = &#039;nfro&#039; //make sure to change this if your shit is coming out in frogs, dumbass.
        set this.targ2_fixedx = 0.
        set this.targ2_fixedy = 0.
        set this.targ3_angle = 0.
    endmethod
endstruct

library TechnoGunSystem uses ABC
    function TGSLinearMove takes unit interface_unit returns nothing
        //Move unit in a straight line according to distance every tick
    endfunction
    
    function TGSArcMoveByAngle takes unit interface_unit returns nothing
        //Move unit and adjust move angle each time.
    endfunction
    
    function TGSArcMoveByDxDy takes unit interface_unit returns nothing
        //Move unit in an arc pattern, and use distance modifiers instead of angle modifiers
    endfunction
    
    function TGSMathFuncMove takes unit interface_unit returns nothing
        //Move unit following a mathematical function.
    endfunction
    
    function TGSLinearMove_AdjustWithMathFunc takes unit interface_unit returns nothing
        //Moves unit following the path of a straight line, and adjusts the pathing of the unit using a mathematical function
    endfunction

    function TGSCollision_Detect takes unit interface_unit returns nothing
        local trigger trig = GetTriggeringTrigger()
        //Get applicable units
        //Get EFFECTS functions
        //Apply EFFECTS to target
        //Clean Up Trigger
        //Remove Triggering Unit from the Game
    endfunction
endlibrary</i></i>


First syntax error:
JASS:
    //***AWAITING IMPLEMENT***
    //For some reason, the following line of code bugs.
    method Timer_TimerStart takes nothing returns nothing
//        call TimerStart(this.T_Timer, this.cooldown, true, this.Timer_Action_Functions)
    endmethod


Second syntax error:
JASS:

//    method SetProjectileTargType takes integer t returns null
//    set this.targetting_function_type = t
//    endmethod


The appropriate crap is commented out right now, however, for the first one, I'm stumped, for the second one, I'm stumped.

Import this and ABC into a map, uncomment, and try to compile to see what I mean.
 

SFilip

Gone but not forgotten
Reaction score
634
In the first you're using a method for timer callback, that won't work unless this method is static.
In the second you wrote returns null instead of returns nothing. You should also know that it's pointless to use a method just to set a variable like that, methods are in fact slow compared to simply doing it "manually".
 

Technomancer

New Member
Reaction score
14
Ok, so I changed the method to a static method, and it didn't work, can you explain what you meant by static methods? This script is starting to come around but I gotta be able to start the timer to test anything.

Further testing reveals that I might be boned and have to make alot of jumps in and out of the struct instance.
 

SFilip

Gone but not forgotten
Reaction score
634
Static methods are methods not bound to a specific struct, you can't use this. inside them.
They're basically like using a normal function, but with a fancy name and that can be accessed from anywhere.
Example
Code:
struct test
   integer foo
   static method bar takes nothing returns nothing
   endmethod
endstruct

function runme takes nothing returns nothing
     call [B]test[/B].bar()
endfunction
Notice that it's used without any struct being created, just with <structname>. in front of it.
 
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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top