Results 1 to 8 of 8

Thread: Properly using isOn and animation SlideIn_Right in XML UI?

  1. #1

    Question Properly using isOn and animation SlideIn_Right in XML UI?

    Hey everyone... I've been having a few difficulties again and I was hoping you could help me out.

    1) When using a ToggleButton with the isOn attribute; how exactly do I use it in the called function? The api says...

    "If the toggle is "on" or not. Is the value sent to onValueChanged's function"

    I've tried acquiring this bool value from within the function, but have had no success.

    2) When trying to create a UI window that slides in from a direction (in this case testing from the right)...

    Is there a way to specify the starting position and the ending position of the slide? Currently, the slide only seems to move around a millimeter on screen from start to finish. I'd like the window to be completely off screen, and then smoothly slide in to a desired position; is this possible, or is the animation confined to set parameters?

    3) This is just an added question here in case you guys can answer it for me without needing to create a separate thread for every small question... When using an input function such as a button, is there any way to disable the click sound?.. Since I have two buttons set up on different parts of my UI which call the same function, the click noise is heard twice after pressing one of the buttons.

    Thanks for all the help guys, and as always, your time and effort is much appreciated.
    Last edited by Hiram Abiff; 08-12-2018 at 10:52 PM.

  2. #2
    Join Date
    Sep 2017
    Posts
    397
    isOn is the attribute you can set at UI initialization.
    onValueChanged() apparently has two undocumented parameters.

    On my workbench mod, [url]https://steamcommunity.com/sharedfiles/filedetails/?id=1445564625[/url] you can try it.

    Global.xml:
    Code:
    <ToggleButton isOn="false" onValueChanged="toggled" width="200" height="100" >
        My button
    </ToggleButton>
    Global.ttslua:
    Code:
    function toggled(player, value)
        print(string.format("%s pressed my button; now I am %s", player.color, value))
    end
    Successive presses of the button produce

    Blue pressed my button; now I am True
    Blue pressed my button; now I am False
    Blue pressed my button; now I am True
    Blue pressed my button; now I am False

    I also noticed that the "False" state is bright, and the "True" state is dim... not what I would have expected.
    Last edited by cche; 08-13-2018 at 11:14 AM. Reason: another thought

  3. #3
    Quote Originally Posted by cche View Post
    I also noticed that the "False" state is bright, and the "True" state is dim... not what I would have expected.
    Yeah didn't expect it to be that way either... and trying to use colorblock or color to change color scheme failed terribly too if you try to reverse (with your own colors) what state is bright/dim.

  4. #4
    Quote Originally Posted by cche View Post
    isOn is the attribute you can set at UI initialization.
    onValueChanged() apparently has two undocumented parameters.

    On my workbench mod, [url]https://steamcommunity.com/sharedfiles/filedetails/?id=1445564625[/url] you can try it.

    Global.xml:
    Code:
    <ToggleButton isOn="false" onValueChanged="toggled" width="200" height="100" >
        My button
    </ToggleButton>
    Global.ttslua:
    Code:
    function toggled(player, value)
        print(string.format("%s pressed my button; now I am %s", player.color, value))
    end
    Successive presses of the button produce

    Blue pressed my button; now I am True
    Blue pressed my button; now I am False
    Blue pressed my button; now I am True
    Blue pressed my button; now I am False

    I also noticed that the "False" state is bright, and the "True" state is dim... not what I would have expected.
    Thank you for your example cche. I was trying just about everything except for using "value"... Makes me feel silly.

  5. #5
    Join Date
    Sep 2017
    Posts
    397
    Hmmm had a thought about the siding in issue:
    Perhaps the effect is limited to the containing elements? Maybe put it in its own transparent panel bigger than the screen?
    Just a thought, no time to test. sorry!

  6. #6
    Quote Originally Posted by cche View Post
    Hmmm had a thought about the siding in issue:
    Perhaps the effect is limited to the containing elements? Maybe put it in its own transparent panel bigger than the screen?
    Just a thought, no time to test. sorry!
    Well, I gave this a try by placing a smaller panel within a large panel, but it still does exactly the same thing. And, when using isOn, I tried adding an if statement to rotate between two options when the value results in either true or false, but other than stating the value within print, I can't use it otherwise.

    something like the below doesn't seem to work for me... if you can, could you please explain..

    Code:
    function returnedToggleButton(White, value)
         if value == false then
              print("Hello World!")
         else
              print("GoodbyeWorld!")
         end
    end
    Using "value" by itself within print gives the correct result of printing True or False, but trying something like the above doesn't seem to work. I've tried a few variations by switching out, if value==false with if value=="false" to see if it checked for a string, but still no go...

  7. #7
    I think it's either "True" or "False", both capitalized strings. That should reeeeally be cast to normal boolean internally IMO but well, it is what it is.

  8. #8
    Quote Originally Posted by dzikakulka View Post
    I think it's either "True" or "False", both capitalized strings. That should reeeeally be cast to normal boolean internally IMO but well, it is what it is.
    You're exactly right, thank you dzikakulka; All I needed to do was capitalize False. Once again, it feels silly to have not caught this, so familiar with using lowercase true or false.

Similar Threads

  1. Adding idle animation to model?
    By Resuru in forum General Discussion
    Replies: 1
    Last Post: 01-22-2018, 12:55 PM
  2. Animation for bag shuffle
    By Unreal_Ed in forum Suggestions
    Replies: 6
    Last Post: 06-26-2017, 09:38 AM
  3. Accessing AssetBundle Animation Component
    By Velian in forum Scripting
    Replies: 2
    Last Post: 04-22-2017, 12:46 PM
  4. Asset Bundle Animation
    By RiceKun in forum General Discussion
    Replies: 8
    Last Post: 02-01-2017, 02:24 AM
  5. Asset Bundle Animation
    By MrStump in forum General Discussion
    Replies: 11
    Last Post: 12-30-2016, 12:59 PM

Tags for this Thread

Posting Permissions

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