Results 1 to 3 of 3

Thread: Make note card's description into a table

  1. #1

    [SOLVED] Make note card's description into a table

    I'm trying to let players actively add in their own message that will then be randomly picked when a button is pressed.
    The note card's description will be set up as follows:
    'user inputted message 1',
    'user inputted message 2',
    'you get the idea'

    Codes reads as follows:

    Code:
      local noteCard = getObjectFromGUID('#####')
      local tableR = {noteCard.getDescription()}
      broadcastToAll(tableR [math.random(#tableR)], {r=1,g=1,b=1})
    And of course it prints out all messages as one big string.
    How can I get it to read each 'message' individually if at all possible?
    Last edited by Mr. Crzy; 12-03-2019 at 08:25 PM. Reason: Solved

  2. #2
    Quote Originally Posted by Mr. Crzy View Post
    I'm trying to let players actively add in their own message that will then be randomly picked when a button is pressed.
    The note card's description will be set up as follows:
    'user inputted message 1',
    'user inputted message 2',
    'you get the idea'

    Codes reads as follows:

    Code:
      local noteCard = getObjectFromGUID('#####')
      local tableR = {noteCard.getDescription()}
      broadcastToAll(tableR [math.random(#tableR)], {r=1,g=1,b=1})
    And of course it prints out all messages as one big string.
    How can I get it to read each 'message' individually if at all possible?
    The description is one big string... what you want to do is split the string into substrings based off a character. You can probably split on /n (new line)... but you might need them to add something at the start or end of each line they add, like maybe two @@ symbols or w/e and use @@ to split the sting.

    try this...

    Code:
    str = noteCard.getDescription()
    lines = {}
    for s in str:gmatch("[^\n]+") do
        table.insert(lines, s)
    end
    the + should skip empty line... but code not tested, just of top of my head. Something like this will make an list of string with a single string for each key... using /n to split the source string....
    My Boardgame uTube chan - Tragic's Table Top
    BGG Guild of BoardGame uTubers - Tube Tables

  3. #3
    awesome that worked. I had just started looking at that and getting way to confused.
    for anyone else reading this my final code looks like this.

    Code:
    noteCard = getObjectFromGUID('####')
      str = noteCard.getDescription()
      lines = {}
      for s in str:gmatch("[^\n]+") do
          table.insert(lines, s)
    end
    printToAll(lines[math.random(#lines)], {r=0, g=0, b=0})
    user writes w/e in the note card description separates each line by pressing Enter i.e \n
    when the buttons is pressed it will randomly select one of the lines and broadcast it to the whole table.

Similar Threads

  1. Replies: 2
    Last Post: 08-25-2017, 06:40 PM
  2. I want to display a description when I mouse over the card.
    By wallpang in forum General Discussion
    Replies: 5
    Last Post: 08-21-2017, 12:20 AM
  3. Is it possible to make a card clickable?
    By GrayDwarf in forum Scripting
    Replies: 12
    Last Post: 01-22-2017, 07:26 PM
  4. Make Peek also show the name of the card.
    By Mark in forum Suggestions
    Replies: 0
    Last Post: 10-02-2016, 06:49 PM
  5. Replies: 2
    Last Post: 07-09-2016, 12:42 PM

Posting Permissions

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