Tabletop Simulator

Tabletop Simulator

Mothership: Tabletop Combat - All Expansions (Scripted)
kensuaga  [udvikler] 12. aug. 2017 kl. 12:42
Mothership Scripting Devlopment
Working on Scripting
< >
Viser 1-15 af 15 kommentarer
kensuaga  [udvikler] 12. aug. 2017 kl. 12:44 
Video explanation - https://youtu.be/njvgO5cnznY
1) Control Board Counter
2) Layout Setup
MrStump 12. aug. 2017 kl. 13:22 
Hey, let us start with number 1. There are a few ways to do what you want, but I am choosing one based on the fact that I do not think your cards will move.

The concept: Put a script zone over each row on each card. So each card gets about 5 script zones. Then the script, once per second (using a repeating timer) is run to count the number of objects in each of those zones. That total is then used to display your results as a button label (without any clickable button under it).

You can look at my Learning More Lua companion table for an example of finding things in zones and using information like tags to identify them. Alternatively, you could name your markers and use their name to identify them in the scripting zone (for counting).

You can look at my counting bowl for an example of a repeating 1 second timer.

Finally, you can refer to this dummy code I mocked up. I designed it to be 1 global script to operate all of the script zone counting for each player, once per second. https://pastebin.com/hiu3URHf
MrStump 12. aug. 2017 kl. 13:25 
An additional example can be found here, where I use the name of cards in an area. http://steamcommunity.com/sharedfiles/filedetails/?id=773385313

One last thing, You can make another "dictionary" style table for turning those 'total' values into the thing they represent on the card. Then put the value into that table to get the value. If you get the rest of this working but aren't clear on this last step, I can make a separate example for you based off of your final code.
MrStump 12. aug. 2017 kl. 13:33 
2) For number two, it breaks down into two steps. Detection of Cards Changing and Layout.

DETECTION OF CARDS CHANGING:
A script zone over the "active" could be used. You could use the repeating tool to keep checking on what is in the zone, or use the global events of onObjectEnterScriptingZone and onObjectLeaveScriptingZone.

Alternatively, you could make a board with the images for each setup on it and a button underneath. If they click on the button, this could trigger the change. I would recommend this method as it would be much easier, but those other methods are also fully possible if you prefer them.
kensuaga  [udvikler] 12. aug. 2017 kl. 13:41 
thank you! I will start digging into these as soon as I can.
MrStump 12. aug. 2017 kl. 13:43 
LAYOUT:
This is much simpler. You create a table tied to each selection. Whenever a selection is triggered by the previous step, you just reference the table and move the objects into place.

I have a lot of scripts that do this, but it won't be clear how I did it using them, so I'm going to kind of walk you through my process.

First, format a table. Here is the one I made as an example of how I would set this data table up: https://pastebin.com/tBgMUkaM

Then you need to fill that table with positions. The easiest way to do this is to put the pieces into place and record the position using the gizmo tool (there is a little thing you can click next to the position that copies it to your clipboard to paste into the table). You also copy the GUID of the item it is going to be moving, and set the reference of the "trigger" that will cause this layout change. The trigger is coming from DETECTION OF CARDS CHANGING and it depends on how you handle that what it will look like.

Then in that function being activated by the trigger, all you need to do is reference that table to place the objects to the positions listed.
kensuaga  [udvikler] 19. aug. 2017 kl. 13:38 
Oprindeligt skrevet af MrStump:
...

The concept: Put a script zone over each row on each card. So each card gets about 5 script zones. ...

I am unable to create zones small enough for each row. The smallest I can go is about the whole size of the card. :(

If possible. I could tag the snap points with a different name for each row then run a count on per snap point that is attached?
MrStump 19. aug. 2017 kl. 17:41 
Make a zone of larger size then re-size it using one of the two scaling gizmos =)
MrStump 19. aug. 2017 kl. 17:41 
And you cannot interact with snap points with lua
kensuaga  [udvikler] 19. aug. 2017 kl. 20:11 
Ahhh I see - will this work even if there is clipping?
http://i.imgur.com/cDecW5s.png
Sidst redigeret af kensuaga; 19. aug. 2017 kl. 20:11
MrStump 20. aug. 2017 kl. 0:55 
The zone placement looks fine in that picture, sure.
kensuaga  [udvikler] 26. aug. 2017 kl. 0:00 
I'm getting some head way in learning the basics. I'm sure there is a better way to approach some of this and I am open to feedback. Soon I will start implementing your code.

Screen Capture [http//blob%3Ahttp]

Here is the code.

-- 4 player position {0.00, 26.79, -0.33}
-- 6 Player position {-0.02, 1.03, 0.39}


ylControlPanel_GUID = '0e46ea'

ylZoneSpeed_GUID = '18c7ed'
ylZoneWeapon_GUID = '88fcfc'
ylZoneShield_GUID = 'b73789'
ylZoneLife_GUID = '45ac57'
ylZoneColony_GUID = '06a0e3'


label_speed_parameters = {
click_function="none", function_owner=nil, label='',
position={-1.71,0.12,-0.32}, rotation={0,0,0}, height=00, width=0,
font_size=110
}

label_weapon_parameters = {
click_function="none", function_owner=nil, label='',
position={-1.57,0.12,-0.09}, rotation={0,0,0}, height=00, width=0,
font_size=110
}

label_shield_parameters = {
click_function="none", function_owner=nil, label='',
position={-1.71,0.12,0.16}, rotation={0,0,0}, height=00, width=0,
font_size=110
}

label_life_parameters = {
click_function="none", function_owner=nil, label='',
position={-1.57,0.12,0.38}, rotation={0,0,0}, height=00, width=0,
font_size=110
}

button_parameters = {
click_function='runStatusReport', function_owner=nil, label='Status\nReport',
position={1.5,0.2,1.1}, rotation={0,0,0}, height=350, width=400,
font_size=100
}



function onload()

ylControlPanel = getObjectFromGUID(ylControlPanel_GUID)



ylControlPanel.createButton(label_speed_parameters)
ylControlPanel.createButton(label_weapon_parameters)
ylControlPanel.createButton(label_shield_parameters)
ylControlPanel.createButton(label_life_parameters)

ylControlPanel.createButton(button_parameters)

runStatusReport()
end

function runStatusReport()



local totalValueSpeed = 0
local totalValueWeapon = 0
local totalValueShield = 0
local totalValueLife = 0

local lyZoneSpeed = getObjectFromGUID(ylZoneSpeed_GUID)
local lyZoneWeapon = getObjectFromGUID(ylZoneWeapon_GUID)
local lyZoneShield = getObjectFromGUID(ylZoneShield_GUID)
local lyZoneLife = getObjectFromGUID(ylZoneLife_GUID)

local objectsInZoneSpeed = lyZoneSpeed.getObjects()
local objectsInZoneWeapon = lyZoneWeapon.getObjects()
local objectsInZoneShield = lyZoneShield.getObjects()
local objectsInZoneLife = lyZoneLife.getObjects()

--Counts Objects named Energy in Speed Zone
for _, object in ipairs(objectsInZoneSpeed) do
if object.getName() == "Energy" then
totalValueSpeed = totalValueSpeed + 1
end
end

--Counts Objects named Energy in Weapon Zone
for _, object in ipairs(objectsInZoneWeapon) do
if object.getName() == "Energy" then
totalValueWeapon = totalValueWeapon + 1
end
end

--Converts the numeric vaule to dice value
if totalValueWeapon == 0 then

else
if totalValueWeapon < 4 then
totalValueWeapon = "D2"
else
if totalValueWeapon < 6 then
totalValueWeapon = "D4"
else
if totalValueWeapon < 8 then
totalValueWeapon = "D6"
else
if totalValueWeapon < 10 then
totalValueWeapon = "D8"
else
if totalValueWeapon < 12 then
totalValueWeapon = "D10"
else
totalValueWeapon = "D12"
end
end
end
end
end
end

--Counts Objects named Energy in Shield Zone
for _, object in ipairs(objectsInZoneShield) do
if object.getName() == "Energy" then
totalValueShield = totalValueShield + 1
end
end

--Counts Objects named Energy in Life Zone
for _, object in ipairs(objectsInZoneLife) do
if object.getName() == "Life" then
totalValueLife = totalValueLife + 1
end
end

-- Prints values
print ("Speed is at " .. totalValueSpeed)
print ("Weapons are at " .. totalValueWeapon)
print ("Shilds are at " .. totalValueShield)
print ("Life is at " .. totalValueLife)

--Updates the Displayes on the Control Panel
ylControlPanel.editButton({index=0, label=totalValueSpeed})
ylControlPanel.editButton({index=1, label=totalValueWeapon})
ylControlPanel.editButton({index=2, label=totalValueShield})
ylControlPanel.editButton({index=3, label=totalValueLife})
print('Status Report Finished')

end
kensuaga  [udvikler] 10. sep. 2017 kl. 14:41 
I got part 1 all warped up and published. It's running real smooth thanks to your code. Any advice on the nested if statements? https://pastebin.com/Zd8ZcGFq
kensuaga  [udvikler] 23. sep. 2017 kl. 21:16 
Need help with scripting zone not reading names.
https://youtu.be/ttEdzuXNtwQ
kensuaga  [udvikler] 25. sep. 2017 kl. 15:52 
Current Lua code - https://pastebin.com/gcfvffJH

pseudo code

gameBox_GUID = '03ceb9'
astNebBag_GUID = '59ff75'
expTokenBag_GUID = '011cd7'
currentBdZone_GUID = '248cd5'
activeLayoutZone_GUID = '3b9c80'

ref_layoutPositions {guid, position, rotation}

onButtonPress()
clearPlayZone()
setupPlayZone()
end

clearPlayZone()
get objects from playzone
for every object in the zone do
put objects away according to their name
end
end

setupPlayZone()
get object name in layoutZone
get table for that object from ref_table by name
for every object in table do
if the object name is not planet then
place object on board
lock object
Else
take artifact token from bag and place it under planet location
place planet
end
end
end

Sidst redigeret af kensuaga; 20. okt. 2017 kl. 20:38
< >
Viser 1-15 af 15 kommentarer
Per side: 1530 50