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

Need help regarding vjass system

Status
Not open for further replies.
Level 7
Joined
Aug 19, 2009
Messages
278
Hi everyone....

I had a made a multiboard interface system before. But I later noticed that the multiboard were leaking. So I decided to use a multiboard system to make my system.

I used this http://www.wc3c.net/showthread.php?t=108150

Now the problem is I know jass but no good in vjass specially structures.
I also don't want to learn it from beginning.

So basiccaly in my system, there is an array of multiboards.
I used this
JASS:
    local integer n = 0
    loop
    exitwhen (n>=udg_totalplayers)
        call CreateMultiboardBJ( 21, 4, "Test" )
        set udg_multiboard[n] = GetLastCreatedMultiboard()
    set n = n + 1
    endloop

But when i do the samething in vjass multiboard system, It shows me error.
I tried doing something like this
JASS:
function Trig_tests_Actions takes nothing returns nothing
local Board multiplayer[0] = Board.create()
set multiplayer[0].title = "string"
endfunction

The error is "title is not a member of Board__ItemHelper"
 
I'll show you how to simulate that loop you did there:
JASS:
globals
    Board array boards
endglobals

function Test takes nothing returns nothing 
    local integer n = 0
    local Board board
    local BoardItem bitem

    loop
        exitwhen (n >= udg_totalplayers)
        
        set board = Board.create()
        set board.title = "Your Title"

        set board.visible = false 
        set board.visible[Player(n)] = true // will only show this board for player n

        set board.row.count = 5 // example row count
        set board.col.count = 5 // example column count

        set bitem = board[0][1] // the item at row 0, column 1   
        set bitem.text = "Hello"
        set bitem.width = 0.08 // width to 8%

        set boards[n] = board // add the board to the global array

        set n = n + 1
    endloop
endfunction

P.S. When you refer to the global array "boards" later on, you may want to assign it to a local at first for two reasons:
(1) When you get a board item, it will look really weird: boards[5][0][1] // for player 4 (purple), row 0, col 1
(2) Not entirely sure if jasshelper is smart enough to decipher that. Maybe they do--I'm not really sure. Regardless, it looks ugly. So I would do:
JASS:
local Board board = boards[5]
set board[0][1].text = "ooga boogah"
Instead.
 
Level 7
Joined
Aug 19, 2009
Messages
278
Thanks... I guess I understood it really well :goblin_good_job:

JASS:
local Board function1 = boards[5]
set function1[0][1].text = "ooga boogah"

If I do something like this while assigning to the local variable or in the original trigger which makes the mutliboard, it wont have any problem right? Or there is a need to initialize it as "board"?


---edit---

I have loops where there will be struct something like this

Multiple assigning the same same local function would have any problem?

JASS:
set n = 0
loop
   exitwhen (n >= udg_totalplayers)
   local Board function1 = boards[n]
   set function1[0][1].text = "ooga boogah"
   set n = n + 1
endloop
 
If I do something like this while assigning to the local variable or in the original trigger which makes the mutliboard, it wont have any problem right? Or there is a need to initialize it as "board"?

As long as that "board" had Board.create() before, then it should be fine. If it is empty, then you have to initialize it first with Board.create(). For example:
JASS:
globals
    Board boards1
    Board boards2
    Board boards3
endglobals

function Test takes nothing returns nothing 
    set boards1 = Board.create()
    set boards2 = Board.create()
endfunction

// ... later on

set boards1.title = "Hello 1" // works
set boards2.title = "Hello 2" // works
set boards3.title = "Hello 3" // won't work 
// you have to have "set boards3 = Board.create()" 
// at some point

Multiple assigning the same same local function would have any problem?
That will be fine, but you have to write it properly. You can't have local declarations inside the loop. Local declarations can only be at the start of a function:
JASS:
local Board function1
set n = 0
loop
   exitwhen (n >= udg_totalplayers)
   set function1 = boards[n]
   set function1[0][1].text = "ooga boogah"
   set n = n + 1
endloop

Make sure that boards[n] have been initialized before with Board.create(). If they weren't, then just set function1 = Board.create(), and before "n = n + 1", simply set it set boards[n] = function1.

Although, just a note--Board is simply a wrapper for vJASS programmers to use. It doesn't add any functionality or efficiency. If you are comfortable with GUI, then use GUI. If you want to use vJASS or JASS, I highly recommend looking at a tutorial first. ;)

edit: Moved to Triggers & Scripts.
 
Level 7
Joined
Aug 19, 2009
Messages
278
As long as that "board" had Board.create() before, then it should be fine. If it is empty, then you have to initialize it first with Board.create(). For example:
JASS:
globals
    Board boards1
    Board boards2
    Board boards3
endglobals

function Test takes nothing returns nothing 
    set boards1 = Board.create()
    set boards2 = Board.create()
endfunction

// ... later on

set boards1.title = "Hello 1" // works
set boards2.title = "Hello 2" // works
set boards3.title = "Hello 3" // won't work 
// you have to have "set boards3 = Board.create()" 
// at some point


That will be fine, but you have to write it properly. You can't have local declarations inside the loop. Local declarations can only be at the start of a function:
JASS:
local Board function1
set n = 0
loop
   exitwhen (n >= udg_totalplayers)
   set function1 = boards[n]
   set function1[0][1].text = "ooga boogah"
   set n = n + 1
endloop

Make sure that boards[n] have been initialized before with Board.create(). If they weren't, then just set function1 = Board.create(), and before "n = n + 1", simply set it set boards[n] = function1.

Although, just a note--Board is simply a wrapper for vJASS programmers to use. It doesn't add any functionality or efficiency. If you are comfortable with GUI, then use GUI. If you want to use vJASS or JASS, I highly recommend looking at a tutorial first. ;)

edit: Moved to Triggers & Scripts.

I guess I understood how to use this. I am not a GUI user i generally use jass. When I was learning jass a few months back, I skipped the vjass parts cause I didn't have patience. lol..

Anyway how efficient are multiboards? I used this system to prevent leaks that happens when we use multiboards. Already implemented this system on map works great.
 
Status
Not open for further replies.
Top