Results 1 to 3 of 3

Thread: trying to broadcast and i get "attempt to call nil value" error

  1. #1

    Unhappy trying to broadcast and i get "attempt to call nil value" error

    I'm trying to put a message on screen so all the players know when the game automatically increments or decrements a players counters.
    When I print it to just the chat box there's no problem but I want it to be more visible so it's not missed and no one thinks someone is trying to cheat.
    Code:
    function onPlayerTurnStart(player_color_start)
      local zone = zones[player_color_start] --gets player's scripting zone
      if zone != nil then --prevents error if turns is turned off
        playerName = Player[player_color_start].steam_name
        local objectsInZone = zone.getObjects() --gets objects in zone
        for _, object in ipairs(objectsInZone) do
          local name = object.getName()
          if name == "(P) Gluttony " then
            for i = 2,1,-1 do hpCounters[player_color_start].Counter.increment() end
            print(playerName.." chowed down and gained 2 Hp")
          end
    when i change print (2nd to last line) to anything else (printToAll, broadcast, broadcastToAll) it gives me a "attempt to call nil value"
    its probably something small but i just can't find it (there's more code that's why there aren't enough ends in this section)

  2. #2
    Join Date
    Apr 2016
    Posts
    174
    printToAll(string message, Color) color = {0.5,0.5,0.5} as example.

    printToColor(string message, string player_color, Color) where string player_color = "White" with a cap on the w

    and if you want to broadcast: change print to broadcast. ie broadcastToAll or broadcastToColor

  3. #3
    Quote Originally Posted by Flolania View Post
    printToAll(string message, Color) color = {0.5,0.5,0.5} as example.

    printToColor(string message, string player_color, Color) where string player_color = "White" with a cap on the w

    and if you want to broadcast: change print to broadcast. ie broadcastToAll or broadcastToColor
    i swore i did this last night.
    Either way it worked thank you

Similar Threads

  1. [SOLVED] "Could not find a part of the path" error
    By Nomaki in forum Technical Support
    Replies: 2
    Last Post: 03-31-2017, 05:10 PM
  2. Replies: 0
    Last Post: 01-24-2017, 03:42 PM
  3. Dropbox "Security Certificate Error"?
    By Tragic in forum General Discussion
    Replies: 4
    Last Post: 12-14-2016, 02:52 PM
  4. Error - "Releasing aborted thread"??
    By dizneyguy in forum Scripting
    Replies: 1
    Last Post: 04-18-2016, 11:21 AM
  5. Replies: 1
    Last Post: 04-06-2016, 10:55 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
  •