Results 1 to 8 of 8

Thread: Help with 1v1 Turn-Based Scripting

  1. #1
    Join Date
    Mar 2017
    Location
    Michigan
    Posts
    3

    Help with 1v1 Turn-Based Scripting

    Hello, I'm new here to the forum, as well as Lua scripting but I've been trying to learn as much as I can. I've had this interesting idea as a bit of a remake for a card game that seats two players. Anyway, I've hit a bit of a roadblock when it came to figuring out how turn-based things work. I've tried many things on my own and then resorted to trying to edit other games' scripts that had player turns. I want to know if this will be easily possible and/or if anyone with experience in Lua could give me a kick-start for this part of my idea. What I want to do is that when a player presses the "Start" button for the game, it will randomize who gets to go first. I know it's just a 50/50 chance but it gives variation and would be neat to have instead of always having the host start (or White, as that's the hosts color when they load up). After it chooses who goes first, the player plays their hand or turn however they wish, then after they press the "Stay" button it will end their turn and switch to the opponent so they can play their turn. However, during a player's turn, I want it so the opposing player cannot draw cards or play cards (or tokens, coming later) until it is their turn. I hope that came across clear enough. Thanks for reading and extra thanks to anyone who can offer advice or help

    TL;DR: I need help with creating a turn-based system for two players, randomizing who gets to go first on game start, and disabling actions for players when it is not their turn. Thanks!

    P.S. There is a "Start" button, "Draw" button, and "Stay" button, mostly functioning except for the "Stay" button but I'm figuring it out once I get the turn system down lol.

  2. #2
    Couple questions about your scenario:

    Are the players drawing from the same deck of cards?

    Are they players making use of the "hand" area?

  3. #3
    Join Date
    Mar 2017
    Location
    Michigan
    Posts
    3
    Quote Originally Posted by Tanners View Post
    Couple questions about your scenario:

    1. Are the players drawing from the same deck of cards?

    2. Are they players making use of the "hand" area?
    1. Yes.

    2. Yes. However at the moment the hand area is used only for one "hidden" card that only the player of the hand can see, then the second card is drawn to a spot on the table for all to see. I want extra cards to be drawn on the table slightly off to the side of each other with each "hit", like they are spread out (not stacking) which I haven't figured out yet. The only other option would be to draw one "hidden" card to a hidden zone on the table for the player, then draw every other "hit" card to the hand, which I will enable all/both players to see. But I didn't really want to do that because of the hidden zone beinga slightly visible and ugly little platform :P

  4. #4
    Join Date
    Mar 2017
    Location
    Michigan
    Posts
    3
    If anyone has any idea if it's possible to randomize who gets to go first in a game between two people, and give an example, I can probably figure out the rest.

  5. #5
    Join Date
    May 2016
    Posts
    1,072
    Sure, search "Player Picker" in the workshop is a working example.

    The basic concept is use getPlayers() to get a table that has 2 entries (one for each color, the entry is the color name).

    Then do math.random(1, 2) to pick a random number from 1-2, and that entry in getPlayers() is picked as going first.

    There is more than can be said, but that's the basics

  6. #6
    Join Date
    Sep 2016
    Posts
    219
    Quote Originally Posted by MrGravey View Post
    I want it so the opposing player cannot draw cards or play cards
    Unfortunately you cannot make something interactable by one player, but not interactable by other players. What I would do is make it non-interactable for all players, then add a draw button that only the current player can press.

    You can see Huffel's Settlers of Catan mod for an example of only allowing the current player to press a button, or you can look at Carcassonne where I basically copied what he did.

    On a related note, [URL="http://www.berserk-games.com/forums/showthread.php?3431-Turn-control"]it sure would be nice if we could use the built in turn system since all the events you need are already in the game, but we don't have the ability to change whose turn it currently is.[/URL]

  7. #7
    Join Date
    May 2016
    Posts
    1,072
    There were some ideas thrown around before too regarding blocking players from drawing. Making a deck noninteractable and having a button to draw, which you could restrict, was one. Or hiding a deck in the table or some such.

  8. #8
    Join Date
    Sep 2016
    Posts
    219
    Just wanted to point out that the turn system has been re-done, and you can now disable interactions for players when it is not their turn.

Similar Threads

  1. dealToColor issue based on deck placement
    By Zero3ffect in forum Scripting
    Replies: 2
    Last Post: 05-05-2016, 06:21 PM
  2. Text based Cards (maybe using XML)
    By Seggo in forum Suggestions
    Replies: 8
    Last Post: 08-28-2015, 10:48 AM
  3. New game deeply based on another, can i?
    By tochjunin in forum General Discussion
    Replies: 3
    Last Post: 07-25-2015, 10:15 PM
  4. Image based lighting
    By PsiComa in forum General Discussion
    Replies: 3
    Last Post: 07-10-2015, 11:54 AM

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
  •