PDA

View Full Version : Checkbox issue



Visvalor
July 22nd, 2010, 22:19
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>

Visvalor
July 22nd, 2010, 22:24
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?

Moon Wizard
July 22nd, 2010, 23:41
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

kirbol
July 23rd, 2010, 14:17
The way I figured out how to make a checkbox gm only was to use onClickDown, you might try:


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

-kirbol