Results 1 to 5 of 5

Thread: Some BUTTON questions.. . . (Colours / Ownership)

  1. #1

    Some BUTTON questions.. . . (Colours / Ownership)

    I have a few button questions....

    Owners

    "button.function_owner = self" ... I have always used that code... but can you use this to set the button to only be able to be clicked by certain colour players.. and if so how?

    The new "colour" functions

    I can not seam to get these to work at all....


    EDIT - yes I can.. I had a stoopid error I didn't see til I was carefully witting out the question!
    My Boardgame uTube chan - Tragic's Table Top
    BGG Guild of BoardGame uTubers - Tube Tables

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    function_owner is just where the click function resiges. So nil/Global or "self". if the script is on an object and the function it activates is on that button too.

    However all buttons pass 2 parameters when pressed to their click function. function yourClickFunctionNameHere(objectButtonIsOn, colorOfWhoPressedTheButton). Using the color, you can determine who pressed the button and then use script logic to decide if they were permitted to or not.

  3. #3
    so I can test "colorOfWhoPressedTheButton" as that is ALWAYS passed to the function without me doing anything?

    So like...

    Code:
    ButtonDiscard.click_function = 'thisIsaTest'
    
    function thisIsaTest()
    
         if colorOfWhoPressedTheButton == getRGBFromColor("Blue")) then
              -- Do Stufff
         end
    
    end
    So basically this button could only be clicked by the blue player?
    Last edited by Tragic; 06-02-2017 at 10:35 PM.
    My Boardgame uTube chan - Tragic's Table Top
    BGG Guild of BoardGame uTubers - Tube Tables

  4. #4
    It's passed as parameters to the function, so you can call it whatever you want.

    Code:
    ButtonDiscard.click_function = 'thisIsaTest'
    
    function thisIsaTest(object_the_button_is_attached_to_sdfgdsfg, player_color_12345blah) --The first parameter is the object the button is attached to, the second parameter is the color of the player pressing.
    
        print(player_color_12345blah .. " is the color of the Player who pressed this button.)
        object_the_button_is_attached_to_sdfgdsfg:setColorTint(stringColorFromRGB(player_color_12345blah))
        
    end
    Personally, I usually use obj & col.

    Code:
    ButtonDiscard.click_function = 'thisIsaTest'
    
    function thisIsaTest(obj, col) --The first parameter is the object the button is attached to, the second parameter is the color of the player pressing.
    
        print(col .. " is the color of the Player who pressed this button.)
        obj:setColorTint(stringColorToRGB(col))
        
    end

  5. #5
    Quote Originally Posted by Tragic View Post
    so I can test "colorOfWhoPressedTheButton" as that is ALWAYS passed to the function without me doing anything?
    (...)
    So basically this button could only be clicked by the blue player?
    Lil corrections:

    Code:
    ButtonDiscard.click_function = 'thisIsaTest'
    
    function thisIsaTest(object, playerColor)
    
         if playerColor == "Blue" then
              -- Do Stufff
         end
    
    end

Similar Threads

  1. Anti-Troll Suggestion: Spawned Object Ownership/Areas
    By Cesar in forum General Discussion
    Replies: 4
    Last Post: 04-12-2017, 07:31 PM
  2. Replies: 1
    Last Post: 02-18-2017, 01:14 PM
  3. Suggestion - GM ownership of tokens
    By Direshadow in forum Suggestions
    Replies: 2
    Last Post: 08-20-2015, 11:43 PM
  4. EULA Content Ownership
    By DaveB in forum General Discussion
    Replies: 4
    Last Post: 01-30-2015, 12:37 AM
  5. *SUGGESTION* Picking seats and colours
    By Renegade in forum General Discussion
    Replies: 0
    Last Post: 04-30-2014, 03:17 AM

Posting Permissions

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