Results 1 to 5 of 5

Thread: Dice - determining number of faces

  1. #1

    Question Dice - determining number of faces


    Lets assume I have 3 objects: fooA, fooB and fooC.
    They are a chess piece, a 6-sided dice and a 20-sided dice.

    By using fooX.tag=='dice' I can tell dice from non-dice.

    But how can one tell 6-sided and 20-sided apart?

    There is some residual information since I can use print(fooX) to get "Die_6_Rounded(Clone) (LuaGameObjectScript)", "Die_20(Clone) (LuaGameObjectScript)" in the chat window, but so far I found nothing that I could use in an if statement...

    Like some sort of typeOf, any ideas?

    type(fooX) returns "userdata" for both.

  2. #2
    Join Date
    May 2016
    tostring(fooX) will give you that string: "Die_6_Rounded(Clone) (LuaGameObjectScript)"

    if tostring(fooX) == ""Die_6_Rounded(Clone) (LuaGameObjectScript)" then
        --six sided

  3. #3
    yea and that's how print() gets it too... :3

  4. #4
    Join Date
    May 2016
    Also, if it is a custom die, using getCustomObject() will give you access to its type, which knowledge base says is the numer of faces

  5. #5
    yea I figured that one out, your tostring() approach was the needed breakthrough to get it rolling - thanks

Posting Permissions

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