Results 1 to 4 of 4

Thread: Turns for one player

  1. #1

    Turns for one player

    Using the Turns class in my game, I kept getting "Attempt to index a nil value" at around line 1766 in my script when the number of players is one. (The script has less than 1000 lines.)
    This game works just the same with one player or many.
    The offending code is something like

    Code:
    function onPlayerTurnEnd(old, new)
        if (old and old.seated) then
            deck.deal(2, old)
        end
    end
    After considerable fumbling, I saw that new was empty; then I found this seems to fix it.

    Code:
    if #Turns.order == 1 then
        Turns.order[2] = Turns.order[1]
    end
    It would be nice if the Turns class handled this case better...

  2. #2
    Are you using #include?

  3. #3

    I needed custom Turns order

    @ onelivesleft: AHA! I am.

    I also learned that in order to affect Turns.order you must set Turns.type=2; otherwise it doesn't complain, it just doesn't work.
    I don't even need to set Turns.order[2], just set the type to 2 (custom)

    Hence, the actual working code looks like

    Code:
    function onLoad()
         .
         .
         .
        -- take control of Turns
        Turns.enable = false -- will generate a turn end event if Turns were enabled, so do this before initializing any Players' data.
        Turns.type = 2 -- custom
        Turns.order = getSeatedPlayers()
        Turns.enable = true
    
        -- other set up ...
    Now Turns works correctly for me with 1 or more players.

  4. #4
    So as you've probably worked out, #include just adds the included code, thus bumping the line count. The TTS plugin's Goto Line (ctrl-g) and Goto Last Error (ctrl-e) commands know this, so if you use goto line and type 1766 it should take you to the correct file and line number.

Similar Threads

  1. Using Turns under the Options Menu
    By Ajkiger1 in forum General Discussion
    Replies: 0
    Last Post: 01-14-2018, 04:11 PM
  2. Replies: 0
    Last Post: 09-03-2017, 01:08 PM
  3. [UPDATE] Update v9.4 Steam Sale, New DLC: Cavern Tavern, & Revamped Turns
    By Kimiko in forum Announcements
    Replies: 1
    Last Post: 06-24-2017, 01:00 PM
  4. Turns and Promotions
    By Dr_Zaius in forum General Discussion
    Replies: 1
    Last Post: 11-29-2015, 09:18 AM
  5. Addition Turns Types
    By Ranma Saotome in forum General Discussion
    Replies: 3
    Last Post: 03-19-2015, 04:03 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
  •