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

[vJASS] Syntax Error

Status
Not open for further replies.
Level 20
Joined
Jul 12, 2010
Messages
1,717
I'm a beginner, i don't even know if what im trying to do is jass/vjass although i use the NewGen WE for coding, here is my problem:
JASS:
//! runtextmacro Variables()
unit u
//! runtextmacro Actions()
set u = unit Paladin 0001
//                                    unit       item name       slot
native UnitAddItemToSlotById takes unit u, integer "0001", integer 2 returns boolean

Syntax Error:
vJass%20Syntax%20Errors%200001.jpg


What did i do wrong? Did i do anything else wrong?

optional:
How can i choose WHEN i want the trigger to run?

additional information:
I tried participating at the jass class but i still don't understand anything, it still is a lot confusing so i decided to learn it myself >_<
 
Level 33
Joined
Apr 24, 2012
Messages
5,113
you have created the textmacro
like
[jass=]
//! textmacro Variables
//! endtextmacro()
[/code]

You can run a trigger in a few ways:
adding an initializer function on the lib:
[jass=]
library Ex initializer Init
function Init takes nothing returns nothing
endfunction
endlibrary[/code]
Using structs
[jass=]
struct Init
method onInit takes nothing returns nothing
endmethod
endstruct[/code]
or module
[jass=]
module Init
method onInit takes nothing returns nothing
endmethod
endmodule
[/code]

But you need to put the initializer (as i have metioned)

edit

Textmacros are for implementing,you are implementing an empty group of functions or functions calls or whatev
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
1) The textmacros have to exist;
2) That's not the way you do function/native calls; it should be:

JASS:
call UnitAddItemToSlotById(u,'I001',1)
//you need to pass the rawcode of the item, which you can get by pressing Ctrl+D in the object editor; it has to be passed between apostrophes;
//"1" is equal to the second slot.

EDIT: also, you can't give variables a value like that; it has to be done like this, for example:

JASS:
set u=CreateUnit(Player(0),'Hpal',0.,0.,0.)
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Here is an example of textmacros:

JASS:
//! textmacro locals_block
    local unit t // Target
    local unit s // Source
    local integer tid = GetHandleId(t) // Target ID
    local integer sid = GetHandleId(s) // Source ID
    local integer n
    local integer i
//! endtextmacro

function f1 takes nothing returns nothing
    //! runtextmacro locals_block()
    // Some Actions that use the above variables
endfunction

function f2 takes nothing returns nothing
    //! runtextmacro locals_block()
    // Some other Actions but use the same variables
endfunction
This will give you result as if you Copy whats inside the textmacro block above then do 2 pastes in each function. It is useful if you have lots of function that uses the same block, you even could set parameters (keywords) that change to the values you give them, like that:

JASS:
//! textmacro f_block takes num
function func$num$ takes nothing returns nothing
    local player p$num$
    local force pf$num$
//! endtextmacro


    //! runtextmacro f_block("1")
    // Some Actions that use the above variables
endfunction



    //! runtextmacro f_block("2")
    // Some other Actions but use the same variables
endfunction
 
Status
Not open for further replies.
Top