サンプル:あかずきんはねむらない

解説:
適当なカードを1枚出して、それをstartCardに使う。
 
 
startCardGUID = "a086c9"
 
deckGUIDs = {"1d9575", "49f259", "6b0d6b", "f27541"}//赤ずきん、狼、親豚、子豚カード
trapGUID = "bd16da"//トラップカード
sleepGUID = "5e723e"//おやすみカード
 
startGUID = "0ecb17"
 
function onload()
local p = {}//スタートボタンを押したときに「startGame」と表示する用
p.click_function = "startGame"
p.label = "Start Game"
p.position = {0, -1, 0}
p.rotation = {180, 90, 0}
p.width = 1600
p.height = 500
p.font_size = 300
getObjectFromGUID(startGUID).createButton(p)
end
 
function onObjectPickUp(color, object)
if object.guid == startCardGUID then
if Player[color].admin and object.guid == startCardGUID and #getSeatedPlayers() >= 3 and #getSeatedPlayers() <= 6 then
//席に座っている人数=プレイヤーの色数で3~6人でないならエラーを表示
startGame()
elseif #getSeatedPlayers() < 4 then print("ERROR: Less than 3 players!")
elseif #getSeatedPlayers() > 6 then print("ERROR: Greater than 6 players!") end
end
end
 
function startGame()
for _, v in ipairs(getAllObjects()) do
if v.tag == "Card" and v.guid ~= trapGUID and v.guid ~= sleepGUID and v.guid ~= startGUID then v.destruct() end
end
 
local deck = getObjectFromGUID(deckGUIDs[6-#getSeatedPlayers()+1]).clone({position={0,5,0}})
deck.shuffle()
//6-プレイヤー人数+1
 
for _, v in ipairs(getSeatedPlayers()) do
local hand = Player[v].getPlayerHand()
deck.takeObject({position={hand.pos_x, hand.pos_y, hand.pos_z}, rotation={hand.rot_x, 360-hand.rot_y, hand.rot_z}})
getObjectFromGUID(trapGUID).clone({position={hand.pos_x, hand.pos_y, hand.pos_z}, rotation={hand.rot_x, hand.rot_y, hand.rot_z}})
getObjectFromGUID(sleepGUID).clone({position={hand.pos_x, hand.pos_y, hand.pos_z}, rotation={hand.rot_x, hand.rot_y, hand.rot_z}})
end
deck.destruct()
end

タグ:

+ タグ編集
  • タグ:
最終更新:2019年10月07日 20:36