Results 1 to 4 of 4

Thread: Multiple items in a single state

  1. #1

    Multiple items in a single state

    I've been messing around with TTS for a bit and have been trying to find a way to have multiple items in a single state.

    Example: For use with playing things like D&D, a player could be given a weapon figure (sword) that sword could have 3 states: State 1: Sword; State 2: 1d20; State 3: 1d8 & 2d6

    Currently when these individual items are aligned and made into a state it would create 5 states as it sees each item as an individual state.

    This would be handy for people with multiple attacks as they could just keep the weapons and drop them on the table as needed to roll their attacks and damage.

    I searched the forums and couldn't find anything on how to do this, so forgive me if this already exists in some form that I can't find.

    -Montravont

  2. #2
    The major problem I see with this is:

    - How should the game decide where to spawn a new state if the two parts of another state are laying very far away from each other?

    You would probably be better off creating an inventory area for the player and give him the sword model and tell him which dices to place next to it. There are nice small "magic" dice trays on the steam workshop where you can put your dice into and put that next to the weapon, so the player could keep track of which dice to use with what.

  3. #3
    You could do this feature somewhat easily with grouping. You group the 1d8 and 2d6 of Montravon's example and the first selected item when the group was made becomes the "main" object in said group. Now when you make the 3 dice appear, the 1d8 (which is the "main" object in that group) appears where the sword previously was. Vice versa, when we want to make the sword reappear, it reappears where the 1d8 was.

    This isn't the best solution, but it would be made much easier if the "main" object had a symbol or gizmo that appears when we hover over it or have it selected. This symbol could also be next to the "states" symbol above the object's name (though I think we need something on the 3d model itself).

  4. #4
    Join Date
    May 2016
    Posts
    1,072
    You can cheat having multiple items in the same state. Let us imagine you have 3 colors of cube and 3 colors of sphere, and if the state of the cube is changed to X color, you want the sphere to change to X color as well.

    The trick is to, before combining the states, add an "onload" script to each object. In this case, here is what the script for cube 1 would look like:

    Code:
    function onload()
        local sphere2 = getObjectFromGUID("######") --guid of the second color sphere
        local sphere3 = getObjectFromGUID("######") --guid of the third color sphere
        if sphere2 then
            sphere2.setState(1)
        elseif sphere3 then
            sphere3.setState(1)
        end
    end
    The idea here is, any time you change an object's state, it will trigger its onload script. So if the cube of the first color loads, it looks for the sphere of the second or third color. If it finds one of those spheres, it sets its state to match its own (in this case, the first state). The idea is a little sloppy, but I think it would hold up, at least in a basic way. It gets midly more complex if you aren't using GUIDs but I hope you get my point.

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
  •