question about these structs and methods

SanKakU

Member
Reaction score
21
so there's this system for your multiboard i was trying to figure out.
i seemed to have found some bugs with it. i solved one, but still haven't figured out the other one.

as a way of working around the bug, in the meantime what i did was make another global. i'm just typing in code without understanding what i'm doing. but some of it is working. i just don't understand why.

i have a theory though.
JASS:
    struct jBoard
//! runtextmacro jBoardDefaults()
        
        multiboard MB
        string boardName
        string boardNameColour = "ffffcc"
        
        integer selectionLevel = 0
        integer selectionSpecial = 0
        integer selectionAmount = 0
        
        integer array playerRow[12]
        integer array playerCol[12]
        
        static method create takes string boardName returns jBoard
            local integer i = 0
                set jB = thistype.allocate()
            set  jB.MB = CreateMultiboard()
            set  jB.boardName = boardName
            call MultiboardSetTitleText(jB.MB,boardName)
            call MultiboardDisplay(jB.MB,false)
                
            return jB
        endmethod


so first i made this MyBoard jBoard_TDHT thing a global. otherwise, i could not change the values from other triggers! this was a big problem! i'm not sure if my solution was the correct one, but it did work.

but then i found out i could not change the icons! only values.
i do not have a reasonable explanation for this, but a way i figured out how to change the icons using the native (call MultiboardSetItemIcon(MultiboardGetItem(jB.MB,0,0),iconP)) was to make another global, jBoard jB
initially it was a local variable in the static method create
but that got me thinking...what's the deal with this static method create?
how did that get called?

was it called just by creating an object which is done by declaring it and defining it as i appear to have done in the following trigger?
and then adding on that .create(string) stuff to call the method.

JASS:
globals
MyBoard jBoard_TDHT
jBoard jB
endglobals
    //! runtextmacro jBoardCreate("MyBoard","12","2")
    
    private function Actions takes nothing returns nothing
set jBoard_TDHT = MyBoard.create("TDHT 0.96e")


i don't understand because... it sounds weird. isn't there another system somewhere with a method called create? if so, wouldn't this conflict with that system? that's my main question i guess. how was the method called?

i'm wondering if progressing further with editing the code if i can make it change icons, but right now the way the system has been without me modifying anything, it's totally broken.

as it is, i'm using a regular native to change the icons and then the jboard method stuff to change values.

what do you guys think i should do? try to fit in icons into this jboard or just forget about it and use the native? i don't really want to use the native because i like the jboard stuff, if it'll just work.

as a reference... this is from the original example for the system.
JASS:
    private function Actions takes nothing returns nothing
        local MyBoard mb = MyBoard.create("Some jBoard")
        call mb.setPlayerRow(0,0).setValue("1").setColourR("ff0000")
        call mb.setPlayerRow(1,1).setValue("2").setColourR("00ff00")
        call mb.setPlayerRow(2,2).setValue("3").setColourR("ffff00")
        call mb.setPlayerRow(3,3).setValue("4").setColourR("ff00ff")
        call mb.getField(3).setValueR("Sup").getField(14).setValueR("Dawg?")
    endfunction

when you look at that, you can see that you cannot access the MyBoard from outside that function because it is a local object, i guess. the create method seems to make the object and then you can start working with it. the interesting thing to note is that to date i cannot figure out why this system doesn't seem to be working with icons. you can set a default icon and that will display properly with the native in there for icon for every item in the multiboard. rather silly if you ask me. [ljass]call MultiboardSetItemsIcon(.MB,.defaultIconPath)[/ljass] so i was able to figure i might as well throw in the native for individual item icon changing. that's how i eventually decided that i should set that other thing as a global. you can hide and show icons just fine but only the setIconPath method isn't working. it looks almost exactly like the setValue method so i don't know why it isn't working.
 

tooltiperror

Super Moderator
Reaction score
231
Just a question, wasn't jBoard updated to use a module?
 

Sevion

The DIY Ninja
Reaction score
413
What's the question now?

From what I can see, you've asked about the create method. The create method is struct specific.

Basically, it'll turn into a function called STRUCTNAME__create or something. So no, it will not conflict.

I'm not sure if there are any other questions in there.
 

SanKakU

Member
Reaction score
21
edit2: ok so i needed to add that i think making the jboard object global isn't necessary unless you need to do something to the multiboard items without using the jboard commands(like using a native function). this was just a temporary workaround for the bug that i found. it isn't meant for you do be doing this with your jboard systems. as such, i've left it out of the official jboard thread. i did, though, post a fix in the thread for that suspicious bit of code i just found.

yeah that was my primary question...thanks. ok the other question was how should i change the multiboard(jboard) icons? like i said, i figured out how to change them using a native function, but i think you're supposed to be able to change them using jboard's method. but it's not working.
the method in question should be somewhere in that huge textmacro. like i mentioned, i didn't notice anything wrong with that method, but i'm stupid, so don't trust my opinion.

there's a resource on this site that has all the code for jBoard. it's in a thread created by Magentix. search for threads he posted in. there it is: http://www.thehelper.net/forums/showthread.php?t=148072

edit: oh i think i see why it isn't working! near the beginning of the code there is a certain bit of code that doesn't match up!

JASS:
private method updateField takes nothing returns nothing
call MultiboardSetItemValue(.mbi,"|cff"+.colour+.prefix+.content+.suffix+"|r")
endmethod
//more code...
method setValue takes string s returns nothing
set .content = s
call .updateField()
endmethod
//more code...
method setIconPath takes string s returns nothing
set .iconpath = s
endmethod

there is no call for a method in setIconPath as there was for setValue.
i think i need to write a new method to fix it.

it was the code far below that looked basically identical. this bit near the top i noticed this difference in the lack of a method call in the icon method.
 

Sevion

The DIY Ninja
Reaction score
413
In his system, change this:
JASS:
//code...
        method setIconPath takes string s returns nothing
            set .iconpath = s
        endmethod
//code...

To this:

JASS:
//code...
        method setIconPath takes string s returns nothing
            set .iconpath = s
            call .updateField()
        endmethod
//code...


I would think that would fix it.
 

SanKakU

Member
Reaction score
21
In his system, change this:
JASS:
//code...
        method setIconPath takes string s returns nothing
            set .iconpath = s
        endmethod
//code...

To this:

JASS:
//code...
        method setIconPath takes string s returns nothing
            set .iconpath = s
            call .updateField()
        endmethod
//code...


I would think that would fix it.

uhmm...if you read my post you'd see i already posted the fix. your idea was the first thing that came to my mind as a possible solution, but was quickly discarded. that's not the correct solution. the correct solution is [ljass]call MultiboardSetItemIcon(.mbi,.iconpath)[/ljass] rather than [ljass]call .updateField()[/ljass]
edit2: ok so i needed to add that i think making the jboard object global isn't necessary unless you need to do something to the multiboard items without using the jboard commands(like using a native function). this was just a temporary workaround for the bug that i found. it isn't meant for you do be doing this with your jboard systems. as such, i've left it out of the official jboard thread. i did, though, post a fix in the thread for that suspicious bit of code i just found.
you were correct in supposing that the method was missing a line, though, so good job on that, at least.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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