Results 1 to 4 of 4

Thread: Change UI image element name property with lua function in global

  1. #1
    Join Date
    Sep 2020
    Location
    USA
    Posts
    3

    Question Change UI image element name property with lua function in global

    Scenario: I'm building a baccarat table and I have a UI element that operates as a hand tracker. It's the board you'd see over a casino table that tells you the hand history and who won, etc. It's just the "bead plate". I'm not messing with the Big Road or anything else right now.

    It's a 20x6 grid filled with transparent images.

    The idea is to update the image name by passing in a value after the hand is decided. As the game progresses, the bead corresponding to the previous hand will "flip" to the correct value. Each XML item will be classed with a number that corresponds to a hand number.

    Pseudo code would be something like:

    Code:
    function updateTracker(decision, handNumber)
      UI.setAttribute(handNumber, image, decision)  
    end
    Except I can't for the life of me get anything from the global script to touch the UI elements. I attached some test scripts to a button to see if I could fire a change, but nothing happens. No bugs or errors, just no response.

  2. #2
    Join Date
    Sep 2020
    Location
    USA
    Posts
    3
    Figured it out. Here's the code if anyone wants to test it.

    Code:
    -- (id, attribute, value)
    self.UI.setAttribute("1","image","playerBead")
    Last edited by PlayArchitect; 09-17-2020 at 11:14 AM. Reason: Wrong syntax

  3. #3
    Join Date
    Sep 2020
    Location
    USA
    Posts
    3
    Final function that will iterate through all of the images in that grid and flip them to "off".

    Note, you have to target the children object of the xmltable you're grabbing from the UI in order to get the attributes of those images. The first object is always the attributes of the containing element (in this case it's a gridLayout containing a bunch of images).

    Code:
    function shuffleShoe()
      beadGrid = UI.getXmlTable("gridLayout")
      for i, v in pairs(beadGrid[1]['children']) do -- because the table we want is is actually nested inside of the other one
        self.UI.setAttribute(i,"image","blank")
      end
    end

  4. #4
    Thanks for sharing!

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2020, 04:10 PM
  2. Replies: 4
    Last Post: 01-19-2017, 08:04 PM
  3. Replies: 6
    Last Post: 08-17-2016, 12:28 PM
  4. Call a global function from a local script
    By enigma in forum Scripting
    Replies: 2
    Last Post: 08-09-2016, 02:14 AM
  5. Object Function Using Global Function
    By LordAshes in forum Scripting
    Replies: 6
    Last Post: 07-11-2016, 05:18 AM

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
  •