• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Jasshelper 2011-12-19

Status
Not open for further replies.
i dont know why jasshelper ver 2011-12-25 has report bug is Line 3336: Syntax Error, unexpected "to" ? from this trigger :goblin_cry:

set Lightning__data.eU = to

JASS:
//
//      _    ___  ___ _   _ _____ __  _ ___ __  _  ___
//     | |  |_ _|/ __| |_| |_   _|  \| |_ _|  \| |/ __|
//     | |__ | || (_ |  _  | | | | \ \ || || \ \ | (_ |
//     |____|___|\___|_| |_| |_| |_|\__|___|_|\__|\___|
//                                   By Lyncor. v1.01.
//
//      What is Lightning?
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//           Lightning is an efficient end-point tracker and fader for lightning
//          effects in Warcraft III.
//          
//      How to implement?
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//           Simply create a new trigger object called Lightning, go to 'Edit -> Convert
//          to Custom Text', and replace everything that's there with this script.
//          
//      Lightning Codes (Thanks to Flare):
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//          "CLPB" - Chain Lightning Primary
//          "CLSB" - Chain Lightning Secondary
//          "DRAB" - Drain
//          "DRAL" - Drain Life
//          "DRAM" - Drain mana
//          "AFOD" - Finger of Death
//          "FORK" - Forked Lightning
//          "HWPB" - Healing Wave Primary
//          "HWSB" - Healing Wave Secondary
//          "CHIM" - Lightning Attack
//          "LEAS" - Magic Leash
//          "MBUR" - Mana Burn
//          "MFPB" - Mana Flare
//          "SPLK" - Spirit Link
//
//      Functions:
//     ¯¯¯¯¯¯¯¯¯¯¯¯
//          For the creation functions:
//              - "string code"   is the lightning type as a string.
//              - "real duration" is how long the lightning should last.
//              - "boolean fade"  is true if the lightning should fade over its duration.
//          
//          function Lightning_UnitUnit takes string code, unit from, unit to,
//           real duration, boolean fade returns nothing
//              - Creates and tracks lightning from one unit to another.
//          
//          function Lightning_CoordsUnit takes string code, real x, real y, real z,
//           unit to, real duration, boolean fade returns nothing
//              - Creates and tracks lightning from coordinates to a unit.
//          
//          function Lightning_UnitCoords takes string code, unit from,
//           real x, real y, real z, real duration, boolean fade returns nothing
//              - Creates and tracks lightning from a unit to coordinates.
//          
//          function Lightning_ColorLast takes real r, real g, real b returns nothing
//              - Sets the colour of the last created lightning to the red,
//                greed and blue values passed into the function (r, g, b).
//              - The values are real numbers ranging from 0 to 1.
//              - This must only be called immediately after calling a
//                creation function.
//
//      Thanks:
//     ¯¯¯¯¯¯¯¯¯
//          - Jesus4Lyf for assistance and writing T32.
// 

library Lightning uses T32
    globals
        // This offset is applied for all unit lightning links.
        private constant real HEIGHT_OFFSET = 56.0
    endglobals
    
    //===========================================================
    // DATA DECLARATION:
    //
    //  The basic data for a link of lightning. This is so there
    // is minimal array declaration, and faster recycling of unit
    // handle ids.
    // 
    
    private struct Link //extends array // JassHelper won't allow this with inheritance.
        // Allocator that won't lose efficiency with inheritance.
        // Faster than vJass allocator.
        private static thistype array recycled
        private static integer recycledMax = 0
        private static integer lastAlloc = 0
        static method alloc takes nothing returns thistype
            if thistype.recycledMax==0 then
                set thistype.lastAlloc = thistype.lastAlloc + 1
                return thistype(thistype.lastAlloc)
            endif
            set thistype.recycledMax = thistype.recycledMax - 1
            return thistype.recycled[thistype.recycledMax]
        endmethod
        method dealloc takes nothing returns nothing
            set thistype.recycled[thistype.recycledMax] = this
            set thistype.recycledMax = thistype.recycledMax + 1
        endmethod
        
        // Data
        lightning link
        
        real x // Don't need 2 sets of these, 
        real y // because if it was linking coords
        real z // to coords, it wouldn't move.
        
        unit sU
        unit eU
        
        integer ticks
        
        real r
        real g
        real b
        real a
        real aSlide
    endstruct
    
    //===========================================================
    // CALLBACK DECLARATION:
    //
    //  This is all the data and code segments used in the links'
    // callback functions. Textmacros are brilliant, because they
    // provide functional decomposition without any efficiency
    // penalty.
    // 
    //  Globals have been used to shorten code (locals also have
    // terribly ugly declarations) and provide an efficiency
    // boost, as well as eliminate nulling concerns for the unit.
    // 
    //  T32 has been used to complete the razor sharp efficiency.
    // 
    
    globals
        private location LOC = Location(0, 0)
    endglobals
    
    globals//locals
        private real X1
        private real Y1
        private real Z1
        
        private real X2
        private real Y2
        // Don't need Z2, can inline into the MoveLightning call.
        
        private unit Unit
    endglobals
    
    //===========================================================
    // Callback Snippets
    // 
    
    //! textmacro LGHT_CB__LoadUnit1
    set Unit = this.sU
    set X1 = GetUnitX(Unit)
    set Y1 = GetUnitY(Unit)
    call MoveLocation(LOC, X1, Y1)
    //! endtextmacro
    
    //! textmacro LGHT_CB__LoadUnit2
    set Unit = this.eU
    set X2 = GetUnitX(Unit)
    set Y2 = GetUnitY(Unit)
    call MoveLocation(LOC, X2, Y2)
    //! endtextmacro
    
    //! textmacro LGHT_CB__EscapeClause
    if this.ticks==0 then
        call DestroyLightning(this.link)
        call this.dealloc()
        return true
    endif
    set this.ticks = this.ticks - 1 // Is effectively at the end of the periodic function.
    //! endtextmacro
    
    //! textmacro LGHT_CB__AlphaUpkeep
    call SetLightningColor(this.link, this.r, this.g, this.b, this.a)
    set this.a = this.a - this.aSlide
    //! endtextmacro
    
    //===========================================================
    // T32 Callbacks
    // 
    //  One for with alpha fading and one without for each cross
    // of unit/coords. For free efficiency if you don't fade.
    // 
    // Semantics:
    //  "U" means "Unit". "XY" means "Coordinates".
    //  "a" is for "alpha". Therefore:
    //  - UU means Unit to Unit, no alpha fade.
    //  - XYUa means Coordinates to Unit, with alpha fade.
    //  - etc.
    // 
    
    private struct LinkUUa extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            //! runtextmacro LGHT_CB__AlphaUpkeep()
            
            return false
        endmethod
        implement T32
    endstruct
    private struct LinkUU extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            
            return false
        endmethod
        implement T32
    endstruct
    
    private struct LinkXYUa extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            call MoveLocation(LOC, this.x, this.y)
            set Z1 = GetLocationZ(LOC) + this.z
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            //! runtextmacro LGHT_CB__AlphaUpkeep()
            
            return false
        endmethod
        implement T32
    endstruct
    private struct LinkXYU extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            call MoveLocation(LOC, this.x, this.y)
            set Z1 = GetLocationZ(LOC) + this.z
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            
            return false
        endmethod
        implement T32
    endstruct
    
    private struct LinkUXYa extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            call MoveLocation(LOC, this.x, this.y)
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
            //! runtextmacro LGHT_CB__AlphaUpkeep()
            
            return false
        endmethod
        implement T32
    endstruct
    private struct LinkUXY extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            call MoveLocation(LOC, this.x, this.y)
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
            
            return false
        endmethod
        implement T32
    endstruct
    
    //===========================================================
    // PUBLIC INTERFACE:
    // 
    //  This is the declaration of all functionality exposed to
    // end users. Once again, a global struct variable has been
    // used to remove the ugly local declaration, and textmacros
    // have been used for efficient functional decomposition.
    // 
    
    globals//locals
        private Link data
    endglobals
    
    //===========================================================
    // Interface Snippets
    // 
    
    //! textmacro LGHT_I__Unit1
    set X1 = GetUnitX(from)
    set Y1 = GetUnitY(from)
    call MoveLocation(LOC, X1, Y1)
    //! endtextmacro
    
    //! textmacro LGHT_I__Unit2
    set X2 = GetUnitX(to)
    set Y2 = GetUnitY(to)
    call MoveLocation(LOC, X2, Y2)
    //! endtextmacro
    
    //! textmacro LGHT_I__Start takes WHICH
    set data.r = 1.0
    set data.g = 1.0
    set data.b = 1.0
    set data.ticks = R2I(duration / T32_PERIOD)
    if fade then
        set data.a = 1.0
        set data.aSlide = 1 / duration * T32_PERIOD
        call Link$WHICH$a(data).startPeriodic()
    else
        call Link$WHICH$(data).startPeriodic()
    endif
    //! endtextmacro
    
    //===========================================================
    // Interface
    // 
    
    public function UnitUnit takes string whichCode, unit from, unit to, real duration, boolean fade returns nothing
        set data = Link.alloc()
        set data.sU = from
        set data.eU = to 
        
        //! runtextmacro LGHT_I__Unit1()
        set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
        //! runtextmacro LGHT_I__Unit2()
        
        set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(to))
        //! runtextmacro LGHT_I__Start("UU")
    endfunction
    public function CoordsUnit takes string whichCode, real x, real y, real z, unit to, real duration, boolean fade returns nothing
        set data = Link.alloc()
        set data.x = x
        set data.y = y
        set data.z = z
        set data.eU = to
        
        call MoveLocation(LOC, x, y)
        set Z1 = GetLocationZ(LOC) + z
        //! runtextmacro LGHT_I__Unit2()
        
        set data.link = AddLightningEx(whichCode, true, x, y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(to))
        //! runtextmacro LGHT_I__Start("XYU")
    endfunction
    public function UnitCoords takes string whichCode, unit from, real x, real y, real z, real duration, boolean fade returns nothing
        set data = Link.alloc()
        set data.sU = from
        set data.x = x
        set data.y = y
        set data.z = z
        
        //! runtextmacro LGHT_I__Unit1()
        set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
        call MoveLocation(LOC, x, y)
        
        set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, x, y, GetLocationZ(LOC) + z)
        //! runtextmacro LGHT_I__Start("UXY")
    endfunction
    
    // Let's not clutter our interfaces.
    public function ColorLast takes real r, real g, real b returns nothing
        set data.r = r
        set data.g = g
        set data.b = b
        call SetLightningColor(data.link, r, g, b, 1.0)
    endfunction
    
    //===========================================================
    // Note to users:
    // 
    //  Keep smiling. God loves you. :D
    //  Happy mapping.
endlibrary
 
You can fix it by just changing all occurrences of the word "to" to something else. It assumes you are using a keyword, so it will bring up an error. Same thing happens when you use any other keyword for a parameter, such as loop or function etc..

JASS:
//
//      _    ___  ___ _   _ _____ __  _ ___ __  _  ___
//     | |  |_ _|/ __| |_| |_   _|  \| |_ _|  \| |/ __|
//     | |__ | || (_ |  _  | | | | \ \ || || \ \ | (_ |
//     |____|___|\___|_| |_| |_| |_|\__|___|_|\__|\___|
//                                   By Lyncor. v1.01.
//
//      What is Lightning?
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//           Lightning is an efficient end-point tracker and fader for lightning
//          effects in Warcraft III.
//
//      How to implement?
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//           Simply create a new trigger object called Lightning, go to 'Edit -> Convert
//          to Custom Text', and replace everything that's there with this script.
//
//      Lightning Codes (Thanks to Flare):
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//          "CLPB" - Chain Lightning Primary
//          "CLSB" - Chain Lightning Secondary
//          "DRAB" - Drain
//          "DRAL" - Drain Life
//          "DRAM" - Drain mana
//          "AFOD" - Finger of Death
//          "FORK" - Forked Lightning
//          "HWPB" - Healing Wave Primary
//          "HWSB" - Healing Wave Secondary
//          "CHIM" - Lightning Attack
//          "LEAS" - Magic Leash
//          "MBUR" - Mana Burn
//          "MFPB" - Mana Flare
//          "SPLK" - Spirit Link
//
//      Functions:
//     ¯¯¯¯¯¯¯¯¯¯¯¯
//          For the creation functions:
//              - "string code"   is the lightning type as a string.
//              - "real duration" is how long the lightning should last.
//              - "boolean fade"  is true if the lightning should fade over its duration.
//
//          function Lightning_UnitUnit takes string code, unit from, unit to,
//           real duration, boolean fade returns nothing
//              - Creates and tracks lightning from one unit to another.
//
//          function Lightning_CoordsUnit takes string code, real x, real y, real z,
//           unit to, real duration, boolean fade returns nothing
//              - Creates and tracks lightning from coordinates to a unit.
//
//          function Lightning_UnitCoords takes string code, unit from,
//           real x, real y, real z, real duration, boolean fade returns nothing
//              - Creates and tracks lightning from a unit to coordinates.
//
//          function Lightning_ColorLast takes real r, real g, real b returns nothing
//              - Sets the colour of the last created lightning to the red,
//                greed and blue values passed into the function (r, g, b).
//              - The values are real numbers ranging from 0 to 1.
//              - This must only be called immediately after calling a
//                creation function.
//
//      Thanks:
//     ¯¯¯¯¯¯¯¯¯
//          - Jesus4Lyf for assistance and writing T32.
//

library Lightning uses T32
    globals
        // This offset is applied for all unit lightning links.
        private constant real HEIGHT_OFFSET = 56.0
    endglobals
    
    //===========================================================
    // DATA DECLARATION:
    //
    //  The basic data for a link of lightning. This is so there
    // is minimal array declaration, and faster recycling of unit
    // handle ids.
    //
    
    private struct Link //extends array // JassHelper won't allow this with inheritance.
        // Allocator that won't lose efficiency with inheritance.
        // Faster than vJass allocator.
        private static thistype array recycled
        private static integer recycledMax = 0
        private static integer lastAlloc = 0
        static method alloc takes nothing returns thistype
            if thistype.recycledMax==0 then
                set thistype.lastAlloc = thistype.lastAlloc + 1
                return thistype(thistype.lastAlloc)
            endif
            set thistype.recycledMax = thistype.recycledMax - 1
            return thistype.recycled[thistype.recycledMax]
        endmethod
        method dealloc takes nothing returns nothing
            set thistype.recycled[thistype.recycledMax] = this
            set thistype.recycledMax = thistype.recycledMax + 1
        endmethod
        
        // Data
        lightning link
        
        real x // Don't need 2 sets of these,
        real y // because if it was linking coords
        real z // to coords, it wouldn't move.
        
        unit sU
        unit eU
        
        integer ticks
        
        real r
        real g
        real b
        real a
        real aSlide
    endstruct
    
    //===========================================================
    // CALLBACK DECLARATION:
    //
    //  This is all the data and code segments used in the links'
    // callback functions. Textmacros are brilliant, because they
    // provide functional decomposition without any efficiency
    // penalty.
    //
    //  Globals have been used to shorten code (locals also have
    // terribly ugly declarations) and provide an efficiency
    // boost, as well as eliminate nulling concerns for the unit.
    //
    //  T32 has been used to complete the razor sharp efficiency.
    //
    
    globals
        private location LOC = Location(0, 0)
    endglobals
    
    globals//locals
        private real X1
        private real Y1
        private real Z1
        
        private real X2
        private real Y2
        // Don't need Z2, can inline into the MoveLightning call.
        
        private unit Unit
    endglobals
    
    //===========================================================
    // Callback Snippets
    //
    
    //! textmacro LGHT_CB__LoadUnit1
    set Unit = this.sU
    set X1 = GetUnitX(Unit)
    set Y1 = GetUnitY(Unit)
    call MoveLocation(LOC, X1, Y1)
    //! endtextmacro
    
    //! textmacro LGHT_CB__LoadUnit2
    set Unit = this.eU
    set X2 = GetUnitX(Unit)
    set Y2 = GetUnitY(Unit)
    call MoveLocation(LOC, X2, Y2)
    //! endtextmacro
    
    //! textmacro LGHT_CB__EscapeClause
    if this.ticks==0 then
        call DestroyLightning(this.link)
        call this.dealloc()
        return true
    endif
    set this.ticks = this.ticks - 1 // Is effectively at the end of the periodic function.
    //! endtextmacro
    
    //! textmacro LGHT_CB__AlphaUpkeep
    call SetLightningColor(this.link, this.r, this.g, this.b, this.a)
    set this.a = this.a - this.aSlide
    //! endtextmacro
    
    //===========================================================
    // T32 Callbacks
    //
    //  One for with alpha fading and one without for each cross
    // of unit/coords. For free efficiency if you don't fade.
    //
    // Semantics:
    //  "U" means "Unit". "XY" means "Coordinates".
    //  "a" is for "alpha". Therefore:
    //  - UU means Unit to Unit, no alpha fade.
    //  - XYUa means Coordinates to Unit, with alpha fade.
    //  - etc.
    //
    
    private struct LinkUUa extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            //! runtextmacro LGHT_CB__AlphaUpkeep()
            
            return false
        endmethod
        implement T32
    endstruct
    private struct LinkUU extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            
            return false
        endmethod
        implement T32
    endstruct
    
    private struct LinkXYUa extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            call MoveLocation(LOC, this.x, this.y)
            set Z1 = GetLocationZ(LOC) + this.z
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            //! runtextmacro LGHT_CB__AlphaUpkeep()
            
            return false
        endmethod
        implement T32
    endstruct
    private struct LinkXYU extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            call MoveLocation(LOC, this.x, this.y)
            set Z1 = GetLocationZ(LOC) + this.z
            //! runtextmacro LGHT_CB__LoadUnit2()
            
            call MoveLightningEx(this.link, true, this.x, this.y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(Unit) + HEIGHT_OFFSET)
            
            return false
        endmethod
        implement T32
    endstruct
    
    private struct LinkUXYa extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            call MoveLocation(LOC, this.x, this.y)
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
            //! runtextmacro LGHT_CB__AlphaUpkeep()
            
            return false
        endmethod
        implement T32
    endstruct
    private struct LinkUXY extends Link
        private method periodic takes nothing returns boolean
            //! runtextmacro LGHT_CB__EscapeClause()
            
            //! runtextmacro LGHT_CB__LoadUnit1()
            set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(Unit)
            call MoveLocation(LOC, this.x, this.y)
            
            call MoveLightningEx(this.link, true, X1, Y1, Z1 + HEIGHT_OFFSET, this.x, this.y, GetLocationZ(LOC) + this.z)
            
            return false
        endmethod
        implement T32
    endstruct
    
    //===========================================================
    // PUBLIC INTERFACE:
    //
    //  This is the declaration of all functionality exposed to
    // end users. Once again, a global struct variable has been
    // used to remove the ugly local declaration, and textmacros
    // have been used for efficient functional decomposition.
    //
    
    globals//locals
        private Link data
    endglobals
    
    //===========================================================
    // Interface Snippets
    //
    
    //! textmacro LGHT_I__Unit1
    set X1 = GetUnitX(from)
    set Y1 = GetUnitY(from)
    call MoveLocation(LOC, X1, Y1)
    //! endtextmacro
    
    //! textmacro LGHT_I__Unit2
    set X2 = GetUnitX(toUnit)
    set Y2 = GetUnitY(toUnit)
    call MoveLocation(LOC, X2, Y2)
    //! endtextmacro
    
    //! textmacro LGHT_I__Start takes WHICH
    set data.r = 1.0
    set data.g = 1.0
    set data.b = 1.0
    set data.ticks = R2I(duration / T32_PERIOD)
    if fade then
        set data.a = 1.0
        set data.aSlide = 1 / duration * T32_PERIOD
        call Link$WHICH$a(data).startPeriodic()
    else
        call Link$WHICH$(data).startPeriodic()
    endif
    //! endtextmacro
    
    //===========================================================
    // Interface
    //
    
    public function UnitUnit takes string whichCode, unit from, unit toUnit, real duration, boolean fade returns nothing
        set data = Link.alloc()
        set data.sU = from
        set data.eU = toUnit 
        
        //! runtextmacro LGHT_I__Unit1()
        set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
        //! runtextmacro LGHT_I__Unit2()
        
        set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(toUnit))
        //! runtextmacro LGHT_I__Start("UU")
    endfunction
    public function CoordsUnit takes string whichCode, real x, real y, real z, unit toUnit, real duration, boolean fade returns nothing
        set data = Link.alloc()
        set data.x = x
        set data.y = y
        set data.z = z
        set data.eU = toUnit
        
        call MoveLocation(LOC, x, y)
        set Z1 = GetLocationZ(LOC) + z
        //! runtextmacro LGHT_I__Unit2()
        
        set data.link = AddLightningEx(whichCode, true, x, y, Z1, X2, Y2, GetLocationZ(LOC) + GetUnitFlyHeight(toUnit))
        //! runtextmacro LGHT_I__Start("XYU")
    endfunction
    public function UnitCoords takes string whichCode, unit from, real x, real y, real z, real duration, boolean fade returns nothing
        set data = Link.alloc()
        set data.sU = from
        set data.x = x
        set data.y = y
        set data.z = z
        
        //! runtextmacro LGHT_I__Unit1()
        set Z1 = GetLocationZ(LOC) + GetUnitFlyHeight(from)
        call MoveLocation(LOC, x, y)
        
        set data.link = AddLightningEx(whichCode, true, X1, Y1, Z1, x, y, GetLocationZ(LOC) + z)
        //! runtextmacro LGHT_I__Start("UXY")
    endfunction
    
    // Let's not clutter our interfaces.
    public function ColorLast takes real r, real g, real b returns nothing
        set data.r = r
        set data.g = g
        set data.b = b
        call SetLightningColor(data.link, r, g, b, 1.0)
    endfunction
    
    //===========================================================
    // Note to users:
    //
    //  Keep smiling. God loves you. :D
    //  Happy mapping.
endlibrary
 
Level 6
Joined
Jun 16, 2007
Messages
235
New Version.

//=====================================
// 2012-01-06
//=====================================
* removed FILEPP preprocessor (not enough public support for it)
* done some optimizations, jasshelper is now about 3x faster
* progress bar now shows global progres
 
Level 6
Joined
Jun 16, 2007
Messages
235
//=====================================
// 2012-01-07
//=====================================
* removed WEWarlock support (outdated)
* more speed improvements
* added full display of external tool calls (ObjectMerger)
 
Level 6
Joined
Jun 16, 2007
Messages
235
Is anyone going to use this LUA feature except you?

I thought you could write LUA scripts as external and than just call them from jass? Why you bother with //! i anyways?

This all sounds like a job for //! external

In any case if you want me to do anything you will have to give me more info of what is it exactly that you need.
Don't just assume I can read your mind. (you have to be inside 500m for that to work)

So next time you post make sure you do it with a lot of links and explanations.
Similarly if you want a new grammar feature try to suggest some syntax for it.
 
When vJASS runs, first it does proprocessor commands like textmacros and imports. Then it runs Lua. Then it runs the vJASS.


With Lua, you can dynamically write JASS or vJASS code, but the problem is that you currently have to write it to a file and then import. Because imports run before Lua, right now you have to run the Lua script to generate the file, disable that script, and then save the map to import that file, which is sort of a pain.


For Lua scripts, you still have to write installation scripts that generate Lua files or vJASS files. You can't just write to an Lua file and import, it isn't that simple. Furthermore, asking the user to cnp a file to a specific location and then cnp some code into their map to execute that file is much harder on the user. It's easier to just provide better syntax for writing Lua scripts in WE.


My suggestion is an Lua block similar to zinc block.

JASS:
//! lua
//! endlua

Furthermore, it would be nice if you could tell the Lua block exactly which exe to use. By default, it should use the ObjectMerger (I think).

JASS:
//! lua ObjectMerger
//! endlua
 
Level 6
Joined
Jun 16, 2007
Messages
235
Would be nice to see nested textmacros...
Give me one good example where nested textmacros would be useful.

When vJASS runs, first it does proprocessor commands like textmacros and imports. Then it runs Lua. Then it runs the vJASS.
Actually it goes like this:
  • 1. preprocessor runs (this collects //! directives)
  • 2. structs are parsed
  • 3. return fixer, inliner...
  • 4. (first pass only) if any //! external, execute them all and then go to step 1.
  • 5. save the map

So basically when there are no external tools used:
1, 2, 3, 5
and when there are external tools used:
1, 2, 3, 4, 1, 2, 3, 5

The reason for this maniac behavior is this:
In order to parse any script text (including the //! directives) you have to open the map (sfmpq.dll) and extract war3map.j,

and than if you find any external calls inside war3map.j you have to save the map file before you can call external tools on it (because they work on map.w3x not on war3map.j)

and then because your map was modified with external tools,
you have to do it all again, extract war3map.j and go to step 1...


As you can see it is impossible to put LUA before preprocessor because it is impossible to put any external tools before preprocessor because calling external tools is dependent on preprocessor parsing external directives.

=========================
One way I can think of this working is this(this is how C preprocessor worked):
Before any jass preprocessing is done war3map.j is saved as logs\input_war3map.j
Than external preprocessor is called on that file to generate processed_war3map.j,
and than all vJass stuff is done on that file instead.

This way you are free to generate any vJass code you wish
(but you would have to extract LUA parts from whole map script yourself)

=========================
Another way would be to make //! externalblock directives save //! i text inside logs folder, than call external tools on that script files and than import their output files back instead of original //! externalblock contents

This can be done between stages 1 and 2, so you could not generate code for libraries, textmacros and includes, but structs would work fine.

=========================
Can I get some links with concrete examples so I can better understand what exactly are you trying to do with this LUA crazynes?
 
Level 6
Joined
Jun 16, 2007
Messages
235
I don't get it why you people use LUA at all.
I made Bonus system 4 years ago without it.

http://www.thehelper.net/forums/sho...fication)?highlight=State Modification System

In any case:
Creating abilities with ObjectMerger modifies the whole map, so all we talked before about doing just .j processing is meaningless.
You will always have to save/disable/save that kind of triggers.

And leasts now jasshelper gives you a nice warning dialog about this, (and external tool progress) so there is no risk of people forgetting to do it.

Sorry Nestharus but BBQ nailed it right:
http://www.hiveworkshop.com/forums/1932780-post2.html
 
I believe that I'm done with wc3 dev : P

I'm going to finish up all of my currently released systems before leaving. I'm not so much of a jerk that I'd just leave everything half baked ^)^.

Creating abilities with ObjectMerger modifies the whole map, so all we talked before about doing just .j processing is meaningless.
You will always have to save/disable/save that kind of triggers.

Due to the masses of generated abilities, object collision risk increases. Furthermore, by depending on an Lua script, you can let the user have more control over customization : ).
 
Level 6
Joined
Jun 16, 2007
Messages
235
- more powerfull loops (like C/Java ones)
What in the name of smurf are you talking about?

- fix this madness initializer priority : module intitalizer are done before any other ones, which is actually breaking the whole requirements system.
Ok, this is the third time someone mentioned this, but I still don't get what is the issue. Please explain this to me in detail.
How exactly does it work now?
How do you think it is supposed to work?
It would be ideal if you could make a test map example where you show me this ''Bad" initialization order (with BJDebugMsg prints maybe?)
 
JASS:
library Poop initializer Init
    private function Init takes nothing returns nothing
        call BJDebugMsg("Poop Init")
    endfunction
endlibrary

library Dog requires Poop
    private struct InitStruct extends array
        static method onInit takes nothing returns nothing
            call BJDebugMsg("Dog Init")
        endmethod
    endstruct
endlibrary

Will print:

Dog Init
Poop Init

Even though library Dog requires Poop, library Dog initializes first because it has a struct initializer. The thing we have been trying to work around by using module initializers for our resources is this: all initializers in a library should fire before any initializers in a library which requires it.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I mean for the for loop : for (<variable init>; <condition>; <iteration statement>). // or even "variable declaration" instead of just "variable init" but maybe it's just too much.
Now again, maybe it's just too much for vJass, i don't care that much, just a suggestion.

For the initializers orders i will make a demo script.
 
Level 6
Joined
Jun 16, 2007
Messages
235
For the initializers orders i will make a demo script.
Bribe's example was going in good direction.

Make sure the script includes all possible initializers(library, struct, module) and their relative order.

Also submit the current and desired order output.
Since changing this orders is potential compatibility hazard I would like as many as possible other people to acknowledge that your suggestion is a desired one.

I can't do anything until saturday morning, so you have a plenty of time to refine your ideas.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
That's already done.
However, i don't use that much module and struct initializers myself, so coders who actually really use them could tell more about how the init should be done.

Just be aware though, that almost all recent (or even older ones) vJass resources here, already use module initializers, just because of the actual initialization order (backward compatibility is so fun)
 

Attachments

  • vJassInitializers.w3x
    14.2 KB · Views: 116
Anonymous functions are very useful.

Here's a snippet of code from one of my maps that uses anonymous functions:

JASS:
            RegisterRectEvent(null, function() { hash.boolean[ITEM_HAMMER]       = true; }, function() { hash.boolean[ITEM_HAMMER]       = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_SCREWDRIVER]  = true; }, function() { hash.boolean[ITEM_SCREWDRIVER]  = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_KEY1]         = true; }, function() { hash.boolean[ITEM_KEY1]         = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_KEY2]         = true; }, function() { hash.boolean[ITEM_KEY2]         = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_KEY3]         = true; }, function() { hash.boolean[ITEM_KEY3]         = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_KNIFE]        = true; }, function() { hash.boolean[ITEM_KNIFE]        = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_LIGHTER]      = true; }, function() { hash.boolean[ITEM_LIGHTER]      = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_INK_LIGHT]    = true; }, function() { hash.boolean[ITEM_INK_LIGHT]    = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_BLOODSTONE]   = true; }, function() { hash.boolean[ITEM_BLOODSTONE]   = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_REMOTE]       = true; }, function() { hash.boolean[ITEM_REMOTE]       = false; });
            RegisterRectEvent(null, function() { hash.boolean[ITEM_PUZZLE_PIECE] = true; }, function() { hash.boolean[ITEM_PUZZLE_PIECE] = false; });

Imagine what this would be without anonymous functions.
 
Level 6
Joined
Jun 16, 2007
Messages
235
Ok I explored the initialization problem in detail and I found this out:

Initialization sequence is this:
All module initializers go first (totally random).
All struct initializers go second (ordered by library/scope precedence)
All library/scope initializers go third.

ONLY module onInit method that is private is a real module onInit.
module onInit method that is not private is actually a struct onInit method.
(remember that modules are basically textmacros)

BUT, struct onInit method created with module will NOT be ordered by library/scope and will in fact fuck up ordering of normal struct onInit stuff.

The reason for this crazy behavior is this:
modules and structs are parsed after libraries/scopes (at that point all information about ordering is already lost)

This is going to be a nightmare to fix, but it is definitely something that needs fixing.
 
Level 13
Joined
May 11, 2008
Messages
1,198
troll-brain, the new jasshelpers do not support cjass, so they keep adding excessive functionality which isn't necessary and doesn't exist in cjass. cjass is supposed to be vjass + cjass, but now with latest jasshelper updates, we have vjass that is incompatible with cjass.

there are many examples, mostly it's things having to do with changes/"improvements"/additions to the way you can define requirements. it's like you guys are building up a huge mountain of errors for jasshelper involving requirements. it baffles me that you guys think it's useful.

i can typically download the newest jasshelper, but usually i find no good reason to, other than to allow me to compile somebody's relatively worthless code.
yet that doesn't typically work, unless i want to compile it stand-alone, since obviously the newfangled vjass isn't compatible with cjass anymore.
 
Level 13
Joined
May 11, 2008
Messages
1,198
cJass doesn't compile my re-write of the Table library, which was a big WTF moment.

i don't know...there are so many systems out there, i sometimes get confused which is which. did your re-write look anything like this?

JASS:
library Table
//***************************************************************
//* Table object 3.0
//* ------------
//*
//*   set t=Table.create() - instanceates a new table object
//*   call t.destroy()     - destroys it
//*   t[1234567]           - Get value for key 1234567
//*                          (zero if not assigned previously)
//*   set t[12341]=32      - Assigning it.
//*   call t.flush(12341)  - Flushes the stored value, so it
//*                          doesn't use any more memory
//*   t.exists(32)         - Was key 32 assigned? Notice
//*                          that flush() unassigns values.
//*   call t.reset()       - Flushes the whole contents of the
//*                          Table.
//*
//*   call t.destroy()     - Does reset() and also recycles the id.
//*
//*   If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//*  You can use Table on structs' onInit  if the struct is
//* placed in a library that requires Table or outside a library.
//*
//*  You can also do 2D array syntax if you want to touch
//* mission keys directly, however, since this is shared space
//* you may want to prefix your mission keys accordingly:
//*
//*  set Table["thisstring"][ 7 ] = 2
//*  set Table["thisstring"][ 5 ] = Table["thisstring"][7]
//*
//***************************************************************

//=============================================================
    globals
        private constant integer MAX_INSTANCES=8100 //400000
        //Feel free to change max instances if necessary, it will only affect allocation
        //speed which shouldn't matter that much.

    //=========================================================
        private hashtable ht
    endglobals

    private struct GTable[MAX_INSTANCES]

        method reset takes nothing returns nothing
            call FlushChildHashtable(ht, integer(this) )
        endmethod

        private method onDestroy takes nothing returns nothing
            call this.reset()
        endmethod

        //=============================================================
        // initialize it all.
        //
        private static method onInit takes nothing returns nothing
            set ht = InitHashtable()
        endmethod

    endstruct

    //Hey: Don't instanciate other people's textmacros that you are not supposed to, thanks.
    //! textmacro Table__make takes name, type, key
    struct $name$ extends GTable

        method operator [] takes $type$ key returns integer
            return LoadInteger(ht, integer(this), $key$)
        endmethod

        method operator []= takes $type$ key, integer value returns nothing
            call SaveInteger(ht,  integer(this)  ,$key$, value)
        endmethod

        method flush takes $type$ key returns nothing
            call RemoveSavedInteger(ht, integer(this), $key$)
        endmethod

        method exists takes $type$ key returns boolean
            return HaveSavedInteger( ht,  integer(this)  ,$key$)
        endmethod

        static method flush2D takes string firstkey returns nothing
            call $name$(- StringHash(firstkey)).reset()
        endmethod

        static method operator [] takes string firstkey returns $name$
            return $name$(- StringHash(firstkey) )
        endmethod

    endstruct
    //! endtextmacro

    //! runtextmacro Table__make("Table","integer","key" )
    //! runtextmacro Table__make("StringTable","string", "StringHash(key)" )
    //! runtextmacro Table__make("HandleTable","handle","GetHandleId(key)" )

endlibrary
 
I just want to confirm if this jasshelper ensures compatibility with the features of version 0.2.A.B

IF that's the case, then I'll update my JNGP with this JH version.

According to Cohadar and others, it is fully compatible. Cohadar said he didn't break any backwards compatibility, so there shouldn't be any problems on that end.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Probably the only real compatibility broken is due to the new keywords but that shouldn't be too much of a problem as a simple replace can easily fix it.

Anyway I have something like this:
JASS:
        local integer lvl = GetUnitAbilityLevel(SpellEvent.CastingUnit, SPELL_ID)
        local unit u   
        
        call GroupEnumUnitsInArea(ENUM_GROUP, SpellEvent.TargetX, SpellEvent.TargetY, Area(lvl), null)
        for u in ENUM_GROUP
            if AffectedTargets(u, GetTriggerPlayer()) then
                call buffType.apply(u, SpellEvent.CastingUnit, lvl, Duration(lvl))            
            endif
        endfor
The problem is that it compiles to this:
JASS:
        local integer lvl= GetUnitAbilityLevel(s__SpellEvent___spellEvent_CastingUnit[SpellEvent], ShadowStride___SPELL_ID)
        local unit u
        call GroupEnumUnitsInArea(ENUM_GROUP , s__SpellEvent___spellEvent_TargetX[SpellEvent] , s__SpellEvent___spellEvent_TargetY[SpellEvent] , ShadowStride___Area(lvl) , null)
            if ShadowStride___AffectedTargets(u , GetTriggerPlayer()) then
                call s__ShadowStride_buffType_apply(u , s__SpellEvent___spellEvent_CastingUnit[SpellEvent] , lvl , ShadowStride___Duration(lvl))
            endif
        endloop // endfor
It basically looks like the compiler ignored the first for statement.
From my testing, it looks like functions that follow a function interface break the new loops (In my case, the code was in a function that had to follow the function interface for SpellEvent, takes nothing and returns nothing).

Shorter example:
JASS:
    private function SpellActions takes nothing returns nothing
        // This doesn't compile!   
        while true
        endwhile
    endfunction
    
    private function Init takes nothing returns nothing
        call RegisterSpellEffectResponse(SPELL_ID, SpellActions)        
    endfunction
 
Level 6
Joined
Jun 16, 2007
Messages
235
Shorter example:
JASS:
    private function SpellActions takes nothing returns nothing
        // This doesn't compile!   
        while true
        endwhile
    endfunction
It works for me just fine. What version of jasshelper are you using?
Do you use anything besides jasshelper?

I also was not able to reproduce that function-interface + for error,
post a demo map with error please.

=============================
I would like to ask people who talk about cJass to go somewhere else.
jasshelper has nothing to do with cJass and any problems you have with cJass should be directed to the makers of cJass.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Test map
Just to be clear, I'm only talking about the new loops having a problem with function interfaces that get registered. If call RegisterSpellEffectResponse(0, SpellActions) is commented out, the map compiles successfully.

I do have the latest JassHelper. (2012-01-07)
I was also able to reproduce the error by trying to compile a test script with Jasshelper alone.
 
Last edited:
Could you please make it so that "FunctionName.name" only converts the string, instead of also writing up all the duplicated "prototype" functions?

FunctionName.name is a good trick to using ExecuteFunc, because ExecuteFunc avoids handles, allows TriggerSleepAction, and ".name" allows the function to be private or within a struct. Never mind the speed, because I really could care less.

What I want it to do, and what JassHelper manual says it does, is just to compile the string, and not adding the extra proxy function + trigger + condition as well. Because the way JassHelper has it set up now, is that it gains absolutely no advantage to use ".name" instead of ".execute".
 
Level 6
Joined
Jun 16, 2007
Messages
235
When ever jasshelper detects function.something it adds function to the list of prototyped ones, so everything is generated.

Sure I could add one more boolean to check if you only used .name, so yes what you ask could be done.

But I have no time atm, and your request is not critical.

I will do it in the next big release when I fix initialization orders,
and that will happen in about 15 days. (when I expect I will have free time)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Could you please make it so that "FunctionName.name" only converts the string, instead of also writing up all the duplicated "prototype" functions?

FunctionName.name is a good trick to using ExecuteFunc, because ExecuteFunc avoids handles, allows TriggerSleepAction, and ".name" allows the function to be private or within a struct. Never mind the speed, because I really could care less.

What I want it to do, and what JassHelper manual says it does, is just to compile the string, and not adding the extra proxy function + trigger + condition as well. Because the way JassHelper has it set up now, is that it gains absolutely no advantage to use ".name" instead of ".execute".

I'm not sure that spamming strings is a good idea in jass though, i would still use .execute, or even ForForce if i care about generated handles and script size.
 
Level 6
Joined
Jun 16, 2007
Messages
235
This is a development version.
Meaning more updates are coming and more testing will be needed before it can be declared stable to use by community.
 
Level 6
Joined
Jun 16, 2007
Messages
235
New Version: 2012-02-06

//=====================================
// 2012-02-06
//=====================================
* Fixed library, scope, struct and module initialization orders.
* Fixed initialization order for structs not inside scope or library.
* InitTrig functions are no longer valid inside scopes and libraries.

New initialization order goes like this:
  • Library Blocks
  • Scope Blocks
  • Anonymous jass
  • GUI

Inside Library or Scope blocks order is like this:
  • struct1-module1 init
  • struct1-module2 init
  • struct1 init
  • struct2-module1 init
  • struct2-module2 init
  • struct2 init
  • block init

Functions with InitTrig prefix are NO LONGER VALID inside libraries and scopes.
This is now an error: (implicit InitTrig calls are reserved for GUI triggers)
JASS:
scope ScopeName

//========ERROR==============================================================
function InitTrig_ScopeName takes nothing returns nothing
    set gg_trg_ScopeName = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_ScopeName, 5 )
    call TriggerAddCondition( gg_trg_ScopeName, Condition( function Trig_ScopeName_Conditions ) )
    call TriggerAddAction( gg_trg_ScopeName, function Trig_ScopeName_Actions )
endfunction
endscope

This is correct:
JASS:
scope ScopeName initializer Init

//===========================================================================
function Init takes nothing returns nothing
    set gg_trg_ScopeName = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_ScopeName, 5 )
    call TriggerAddCondition( gg_trg_ScopeName, Condition( function Trig_ScopeName_Conditions ) )
    call TriggerAddAction( gg_trg_ScopeName, function Trig_ScopeName_Actions )
endfunction
endscope
 
Status
Not open for further replies.
Top