DICE PACKS BUNDLE

Thread: Checkbox issue

  1. #1

    Join Date
    Feb 2009
    Location
    Jacksonville, Florida
    Posts
    153

    Checkbox issue

    I use this script in my numberfields all the time...

    <script>
    function onInit()
    if not User.isHost() then
    setReadOnly(true);
    end
    end
    </script>

    However I want to toss the same effect into a few checkboxes. But when I put the script in, it makes the checkbox disappear :\

    Any advice?

    <checkbox name="deathmagic">
    <anchored>
    <left>
    <anchor>left</anchor>
    <offset>405</offset>
    </left>
    <top>
    <anchor>top</anchor>
    <offset>640</offset>
    </top>
    <size>
    <width>15</width>
    <height>15</height>
    </size>
    </anchored>
    <stateicons>
    <on>indicator_checkon</on>
    <off>indicator_checkoff</off>
    </stateicons>
    <script>
    function onInit()
    if not User.isHost() then
    setReadOnly(true);
    end
    end
    </script>
    </checkbox>
    "Tis better to die on your feet, then live on your knees."

  2. #2

    Join Date
    Feb 2009
    Location
    Jacksonville, Florida
    Posts
    153
    I was thinking, couldn't I just copy the template_checkbox script and make a template_checkbox_gm script and just toss in the


    function onInit()
    if not User.isHost() then
    setReadOnly(true);
    end
    end

    Somewhere on top? Would that work?
    "Tis better to die on your feet, then live on your knees."

  3. #3
    Any time that you are using a template that is already defined with an onInit function, you need to call super.onInit in your new template or override script.

    Also, you'll have to review the checkbox template to see if it supports setReadOnly, which is only predefined for built-in objects. (numbercontrol, stringcontrol, diecontrol, ...).

    Cheers,
    JPG

  4. #4
    The way I figured out how to make a checkbox gm only was to use onClickDown, you might try:

    Code:
    function onClickDown(button, x, y)
       if User.isHost() then
          setState(not getState());
       end
    end
    -kirbol

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
FG Spreadshirt Swag

Log in

Log in