Game Development Community

2 questions about scripting. (GUI stuff in particular)

by Jason Griffith · in Torque Game Engine · 07/29/2002 (5:12 am) · 14 replies

Hi guys! Is there a way to get the engine to update the gui? I want this to happen because the image paths will change for one particular bitmap. I know reloading the entire gui might be slow, so is there a way to just update one object of it, like a bitmap control? This has nothing todo with mouse events.

My other question is about the scripting language its self. It looks very similar to C++. I just want to know if i can create arrays in the same way (if at all)?

Would it be like this:

%myarray[] = { "some text", "some more text", "etc."};

thx,

-J

About the author

Recent Threads

  • Vechle Scripting

  • #1
    07/29/2002 (5:55 am)
    There is a function you can call in C++,

    setUpdate();

    in script,

    i dont think there really is anything...to find out the functions that a gui object can use..name the gui object and do a dump() on it

    i.e. MyText.dump();

    Arrays work like

    %myarray[0] = "blah";
    %myarray["blah"] = "another blah";

    // multidemensional
    %myarray["blah2",7] = 3;

    -Tim aka Spock
    #2
    07/29/2002 (8:41 am)
    If you're just looking to update the bitmap of a GuiBitmapCtrl you just call setBitmap in script like this:

    GuiBitmapCtrlName.setBitmap("path_to_bitmap");

    You can use dump() like tim said to find out other things you can do for various controls.
    #3
    07/29/2002 (11:00 am)
    Hi again, thanks for the help. I'm tring to call that function and I keep getting a odd error. Here's the function:

    function update_caption(%rtrn_img, %id)
    {
       switch(%id)
       {
            case 0: %imgpath = "~/data/sg1gui/water1.jpg";      //No text
            case 1: %imgpath = "~/data/sg1gui/water2.jpg";      //Start Mission
            case 2: %imgpath = "~/data/sg1gui/water3.jpg";      //Join Mission
            case 3: %imgpath = "~/data/sg1gui/water4.jpg";      //Options
            case 4: %imgpath = "~/data/sg1gui/water5.jpg";      //Recordings
            case 5: %imgpath = "~/data/sg1gui/water6.jpg";      //Credits
            case 6: %imgpath = "~/data/sg1gui/water7.jpg";      //About
            
            default: %imgpath = "~/data/sg1gui/water1.jpg";     //If error, set to blank as default
       }
       
       %Caption_img.setBitmap(%imgpath);
       
       return %rtrn_img;
    }

    and heres the error:

    Unable to find object: '' attempting to call function 'setbitmap'

    This is occoring on the setbitmap line, but why?

    Thx,

    -J
    #4
    07/29/2002 (11:08 am)
    I think you just want this:

    Caption_img.setBitmap(%imgpath);
    #5
    07/29/2002 (2:14 pm)
    No, it comes out with the same error.

    -J
    #6
    07/29/2002 (2:21 pm)
    And "Caption_img" is the name of the GuiBitmapCtrl in your gui correct? Make sure you've spelled them both the same.

    Also, are you exec'ing your gui in some init script?

    Other than that I can't think of any reason it wouldn't work.
    #7
    07/29/2002 (2:46 pm)
    You have %Caption_img referenced as a local variable but you never created it anywhere..now if you named your control that.

    i.e. guiBitmapCtrl(Caption_img)

    then you simply refer to it as Caption_img ....leave off the %

    -Tim aka Spock
    #8
    07/29/2002 (3:15 pm)
    I've done all u guys said, but noe it cant find the Caption_img. This is because the function is decleared at the top of the file, before the gui objects. If i do it after the gui objects, then the function calls are invalid, because the function cant be found. What can i do?

    -J
    #9
    07/29/2002 (4:38 pm)
    Try putting it in a cs file...then look in the client's init.cs and put the cs file where it loads the other gui cs files and put the gui exec where it loads the other .gui files..see if it works then.

    -Tim aka Spock
    #10
    07/30/2002 (5:18 am)
    No, it did work, it came out with the same problems. Is there any way to declare a function prototype, like you can do in C++? If i put one at the top of the gui file, then the function would be found.

    Thx,

    -J
    #11
    07/30/2002 (12:08 pm)
    Which order are you exec'ing your scripts in? You should exec the .gui first, and then exec the .cs. Then your functions in the .cs will be able to find your controls from the .gui.

    I don't know of a way to put a function declaration up top, but there might be one.
    #12
    07/30/2002 (3:00 pm)
    This is a very trivial thing so you must be making a mistake too simple to see. Check back over everything again and make sure you have everything spelled right, all the scripts are executing, etc.

    -Tim aka Spock
    #13
    07/30/2002 (3:02 pm)
    Hmmm, I could have sworn that I wrote a reply to this thread earlier.

    Maybe you could show us the relavent contents of the .gui file?
    #14
    07/30/2002 (5:52 pm)
    Whats happening is that a gui mouseover event is calling my function, which referes to a another gui control. So really they need to be defined at the same time, but a function prototype is an other way to solve this problem. Is there any way. I'll post the full code tommory, 'cos it 2AM here!

    -J