Tabletop Simulator

Tabletop Simulator

Sushi Go Party! [Scripted]
Trixelian 26 Jun, 2022 @ 9:08am
Script fixing hand rotation (based on Lix's comments)
The following is code which replaces the Rotate Clockwise script and should fix issues with hand rotation. Testing with four players, the last player's hand now correctly goes into the white player's hand, and everything seems to work.

This is all based on Lix's comments detailing the fix, and it would be great if the script could be updated in the workshop mod, with credit to them.

-- By Blitzmann, based on Hand Rotator by Richy_s <https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=630448128> function onload() thisRotation = self.getRotation() local buttonParameters = {} buttonParameters.click_function = 'rotateHands' buttonParameters.label = 'Rotate\nHands' buttonParameters.function_owner = self buttonParameters.position = {0,0.5,0} buttonParameters.rotation = {0,0,0} buttonParameters.width = 620 buttonParameters.height = 620 buttonParameters.font_size = 100 self.createButton(buttonParameters) end function nothing() --This function, it does nothing end function rotateHands() --We'll be spawning things and using them, and we need yield startLuaCoroutine(self, 'rotateCoroutine') end function rotateCoroutine() --Code to nullify the button, removing issues related to double-presses self.clearButtons() nullButtonParameters = {} nullButtonParameters.click_function = 'nothing' nullButtonParameters.label = 'Rotating' nullButtonParameters.function_owner = self nullButtonParameters.position = {0,0.5,0} nullButtonParameters.rotation = {0,0,0} nullButtonParameters.width = 620 nullButtonParameters.height = 620 nullButtonParameters.font_size = 100 self.createButton(nullButtonParameters) local allPlayers = {White = 1, Brown = 2, Red = 3, Orange = 4, Yellow = 5, Green = 6, Teal = 7, Blue = 8, Purple = 9, Pink = 10} local sortedSeatedPlayers = {} local debug = false -- false removes unseated players from the list. true doesn't, allowing easier testing -- determine who's playing for color, i in pairs(allPlayers) do if Player[color].getHandCount() > 0 then if debug or Player[color].seated then table.insert(sortedSeatedPlayers,color) end end end local nToDeal = #Player[sortedSeatedPlayers[1]].getHandObjects() -- by lix for colIndex,color in pairs(sortedSeatedPlayers) do -- determine who to pass it to local target = nil if colIndex < #sortedSeatedPlayers then target = sortedSeatedPlayers[colIndex+1] else target = sortedSeatedPlayers[1] end local fullHand = Player[color].getHandObjects() -- local thisHand = {} -- commented out by lix local cardsMoved = 0 -- by lix for _,item in pairs(fullHand) do -- following if-else added by lix if cardsMoved < nToDeal then if item.tag == "Card" then wait(1) item.deal(1, target) end else break end cardsMoved = cardsMoved + 1 end wait(5) end --[[Return the button to normal, just reuse onload() here. If something else were in there, we'd need to setup a makebutton--]] self.clearButtons() coroutine.yield(0) onload() return 1 end function wait(delay) --[[simple quality of life function for pausing--]] for n=1,delay do coroutine.yield(0) end end
Last edited by Trixelian; 26 Jun, 2022 @ 9:11am
< >
Showing 1-1 of 1 comments
Tarnest 19 Jul, 2022 @ 4:34pm 
As far as I can tell, 2 player games don't work with this script.
< >
Showing 1-1 of 1 comments
Per page: 1530 50