Skip to content

Commit

Permalink
Updated BoDaN state 2 code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Dolan committed Feb 10, 2021
1 parent 362a0d0 commit 6a766b3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions objects/606f23/object.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"Description": "Base",
"GMNotes": "",
"ColorDiffuse": {
"r": 0.200274974,
"g": 0.160320252,
"b": 0.151758522
"r": 0.200274825,
"g": 0.1603201,
"b": 0.151758373
},
"Tags": [
"Spirit"
Expand Down Expand Up @@ -156,9 +156,9 @@
"Description": "Base",
"GMNotes": "",
"ColorDiffuse": {
"r": 0.200279981,
"g": 0.160325259,
"b": 0.151763529
"r": 0.200279921,
"g": 0.1603252,
"b": 0.151763469
},
"Tags": [
"Spirit"
Expand Down Expand Up @@ -188,7 +188,7 @@
"Stretch": true
}
},
"LuaScript": "-- Spirit Tile for Bone White's Spirit Island Mod v2 --\nuseProgression = false\nprogressionCard = nil\nuseAspect = 2\naspect = nil\n\nfunction onLoad()\n Color.Add(\"SoftBlue\", Color.new(0.45,0.6,0.7))\n if Global.getVar(\"gameStarted\") then return end\n self.createButton({\n click_function = \"SetupSpirit\",\n function_owner = self,\n label = \"Choose Spirit\",\n position = Vector(0.7, -0.1, 0.9),\n rotation = Vector(0,0,180),\n scale = Vector(0.2,0.2,0.2),\n width = 1800,\n height = 500,\n font_size = 300,\n })\n self.createButton({\n click_function = \"ToggleProgression\",\n function_owner = self,\n label = \"\",\n position = Vector(-0.7, -0.1, 0.9),\n rotation = Vector(0,0,180),\n scale = Vector(0.2,0.2,0.2),\n width = 0,\n height = 0,\n font_size = 300,\n tooltip = \"Enable/Disable Progression Deck\",\n })\n self.createButton({\n click_function = \"ToggleAspect\",\n function_owner = self,\n label = \"\",\n position = Vector(0.7, -0.2, 0.4),\n rotation = Vector(0,0,180),\n scale = Vector(0.2,0.2,0.2),\n width = 0,\n height = 0,\n font_size = 300,\n tooltip = \"Enable/Disable Aspect Deck\",\n })\n local castObjects = upCast(self,1,0.5)\n for _,obj in pairs (castObjects) do\n if string.find(obj.getName(),\"Progression\") then\n progressionCard = obj\n self.editButton({\n index = 1,\n label = \"No Progression\",\n width = 2000,\n height = 500,\n })\n elseif string.find(obj.getName(),\"Aspects\") then\n self.editButton({\n index = 2,\n label = \"Include Aspects\",\n width = 2000,\n height = 500,\n })\n end\n end\n Global.call(\"addSpirit\", {spirit=self})\nend\n\nfunction PickSpirit(params)\n if params.aspect then\n if params.aspect == \"Random\" then\n useAspect = 1\n elseif params.aspect == \"\" then\n useAspect = 0\n else\n useAspect = 3\n aspect = params.aspect\n end\n end\n SetupSpirit(nil, params.color)\nend\nfunction SetupSpirit(object_pick,player_color)\n local xPadding = 1.3\n local xOffset = 1\n local PlayerBag = getObjectFromGUID(Global.getTable(\"PlayerBags\")[player_color])\n if #PlayerBag.getObjects() ~= 0 then\n local castObjects = upCast(self,1,0.5)\n local hpos = Player[player_color].getHandTransform().position\n self.setPosition(Vector(hpos.x,0,hpos.z) + Vector(0,1.05,11.8))\n self.setRotation(Vector(0,180,0))\n self.setLock(true)\n self.clearButtons()\n local spos = self.getPosition()\n local snaps = self.getSnapPoints()\n local placed = 0\n\n -- Setup Presence\n for i = 1,13 do\n local p = snaps[i]\n if i <= #snaps then\n PlayerBag.takeObject({position = self.positionToWorld(p.position)})\n else\n PlayerBag.takeObject({position = Vector(spos.x,0,spos.z) + Vector(-placed*xPadding+xOffset,1.1,10)})\n placed = placed + 1\n end\n end\n\n -- Setup Ready Token\n local ready = PlayerBag.takeObject({\n position = Vector(spos.x,0,spos.z) + Vector(6, 1.1, 7),\n rotation = Vector(0, 180, 180),\n })\n\n Global.call(\"removeSpirit\", {spirit=self.guid, color=player_color, ready=ready})\n\n -- Setup Energy Counter\n local counter = getObjectFromGUID(Global.getVar(\"counterBag\")).takeObject({position = Vector(spos.x,0,spos.z) + Vector(-5,1,5)})\n counter.setLock(true)\n\n -- Setup Progression Deck if enabled\n if useProgression then\n local minorPowerDeck = getObjectFromGUID(Global.getVar(\"minorPowerZone\")).getObjects()[1]\n local majorPowerDeck = getObjectFromGUID(Global.getVar(\"majorPowerZone\")).getObjects()[1]\n local progressionDeck = progressionCard.getVar(\"progressionDeck\")\n for i,card in pairs(progressionDeck) do\n if card[2] then\n majorPowerDeck.takeObject({\n position = Vector(spos.x,i,spos.z) + Vector(0,1.1,14),\n rotation = Vector(0,180,180),\n guid = card[1],\n })\n else\n minorPowerDeck.takeObject({\n position = Vector(spos.x,i,spos.z) + Vector(0,1.1,14),\n rotation = Vector(0,180,180),\n guid = card[1],\n })\n end\n end\n end\n\n -- Setup objects on top of board\n for i,obj in pairs (castObjects) do\n obj.setLock(false)\n if obj.type == \"Deck\" then\n if string.find(obj.getName(),\"Aspects\") then\n HandleAspect(obj, player_color)\n else\n obj.deal(#obj.getObjects(),player_color)\n end\n elseif obj.type == \"Card\" and string.find(obj.getName(),\"Progression\") then\n if useProgression then\n obj.setPositionSmooth(Vector(spos.x,8,spos.z) + Vector(0,1.1,14))\n else\n obj.destruct()\n end\n else\n obj.setPositionSmooth(Vector(spos.x,0,spos.z) + Vector(-placed*xPadding+xOffset,1.1,10))\n placed = placed + 1\n end\n end\n else\n Player[player_color].broadcast(\"You already picked a spirit\", \"Red\")\n end\nend\nfunction HandleAspect(deck, player_color)\n if useAspect == 0 then\n deck.destruct()\n elseif useAspect == 1 then\n local index = math.random(0,#deck.getObjects())\n if index == 0 then\n Player[player_color].broadcast(\"Your random Aspect is no Aspect\", Color.SoftBlue)\n deck.destruct()\n else\n deck.takeObject({\n index = index - 1,\n position = deck.getPosition() + Vector(0,2,0),\n callback_function = function(obj) obj.deal(1, player_color) deck.destruct() Player[player_color].broadcast(\"Your random Aspect is \"..obj.getName(), Color.SoftBlue) end,\n })\n if deck.remainder then deck = deck.remainder end\n end\n elseif useAspect == 3 then\n local found = false\n for index, data in pairs(deck.getObjects()) do\n if data.name == aspect then\n found = true\n deck.takeObject({\n index = data.index,\n position = deck.getPosition() + Vector(0,2,0),\n callback_function = function(obj) obj.deal(1, player_color) deck.destruct() end,\n })\n if deck.remainder then deck = deck.remainder end\n break\n end\n end\n if not found then\n deck.destruct()\n Player[player_color].broadcast(\"Unable to find aspect \"..aspect, \"Red\")\n end\n else\n deck.deal(#deck.getObjects(), player_color)\n end\nend\n\nfunction ToggleProgression()\n useProgression = not useProgression\n if useProgression then\n self.editButton({\n index = 1,\n label = \"Progression\",\n })\n else\n self.editButton({\n index = 1,\n label = \"No Progression\",\n })\n end\nend\nfunction ToggleAspect(_, _, alt_click)\n if alt_click then\n useAspect = (useAspect - 1) % 3\n else\n useAspect = (useAspect + 1) % 3\n end\n if useAspect == 0 then\n self.editButton({\n index = 2,\n label = \"No Aspects\",\n })\n elseif useAspect == 1 then\n self.editButton({\n index = 2,\n label = \"Random Aspect\",\n })\n else\n self.editButton({\n index = 2,\n label = \"Include Aspects\",\n })\n end\nend\n-----\nfunction upCast(obj,dist,offset,multi)\n local dist = dist or 1\n local offset = offset or 0\n local multi = multi or 1\n local oPos = obj.getPosition()\n local oBounds = obj.getBoundsNormalized()\n local oRot = obj.getRotation()\n local orig = Vector(oPos[1],oPos[2]+offset,oPos[3])\n local siz = Vector(oBounds.size.x*multi,dist,oBounds.size.z*multi)\n local orient = Vector(oRot[1],oRot[2],oRot[3])\n local hits = Physics.cast({\n origin = orig,\n direction = Vector(0,1,0),\n type = 3,\n size = siz,\n orientation = orient,\n max_distance = 0,\n --debug = true,\n })\n local hitObjects = {}\n for i,v in pairs(hits) do\n if v.hit_object ~= obj then table.insert(hitObjects,v.hit_object) end\n end\n return hitObjects\nend\n",
"LuaScript": "-- Spirit Tile for Bone White's Spirit Island Mod v2 --\nuseProgression = false\nprogressionCard = nil\nuseAspect = 2\naspect = nil\n\nfunction onLoad()\n Color.Add(\"SoftBlue\", Color.new(0.45,0.6,0.7))\n if Global.getVar(\"gameStarted\") then return end\n self.createButton({\n click_function = \"SetupSpirit\",\n function_owner = self,\n label = \"Choose Spirit\",\n position = Vector(0.7, -0.1, 0.9),\n rotation = Vector(0,0,180),\n scale = Vector(0.2,0.2,0.2),\n width = 1800,\n height = 500,\n font_size = 300,\n })\n self.createButton({\n click_function = \"ToggleProgression\",\n function_owner = self,\n label = \"\",\n position = Vector(-0.7, -0.1, 0.9),\n rotation = Vector(0,0,180),\n scale = Vector(0.2,0.2,0.2),\n width = 0,\n height = 0,\n font_size = 300,\n tooltip = \"Enable/Disable Progression Deck\",\n })\n self.createButton({\n click_function = \"ToggleAspect\",\n function_owner = self,\n label = \"\",\n position = Vector(0.7, -0.2, 0.4),\n rotation = Vector(0,0,180),\n scale = Vector(0.2,0.2,0.2),\n width = 0,\n height = 0,\n font_size = 300,\n tooltip = \"Enable/Disable Aspect Deck\",\n })\n local castObjects = upCast(self,1,0.5)\n for _,obj in pairs (castObjects) do\n if string.find(obj.getName(),\"Progression\") then\n progressionCard = obj\n self.editButton({\n index = 1,\n label = \"No Progression\",\n width = 2000,\n height = 500,\n })\n elseif string.find(obj.getName(),\"Aspects\") then\n self.editButton({\n index = 2,\n label = \"Include Aspects\",\n width = 2000,\n height = 500,\n })\n end\n end\n Global.call(\"addSpirit\", {spirit=self})\nend\n\nfunction PickSpirit(params)\n if params.aspect then\n if params.aspect == \"Random\" then\n useAspect = 1\n elseif params.aspect == \"\" then\n useAspect = 0\n else\n useAspect = 3\n aspect = params.aspect\n end\n end\n SetupSpirit(nil, params.color)\nend\nfunction SetupSpirit(object_pick,player_color)\n local xPadding = 1.3\n local xOffset = 1\n local PlayerBag = getObjectFromGUID(Global.getTable(\"PlayerBags\")[player_color])\n if #PlayerBag.getObjects() ~= 0 then\n local castObjects = upCast(self,1,0.5)\n local hpos = Player[player_color].getHandTransform().position\n self.setPosition(Vector(hpos.x,0,hpos.z) + Vector(0,1.05,11.8))\n self.setRotation(Vector(0,180,0))\n self.setLock(true)\n self.clearButtons()\n local spos = self.getPosition()\n local snaps = self.getSnapPoints()\n local placed = 0\n\n -- Setup Presence\n for i = 1,13 do\n local p = snaps[i]\n if i <= #snaps then\n PlayerBag.takeObject({position = self.positionToWorld(p.position)})\n else\n PlayerBag.takeObject({position = Vector(spos.x,0,spos.z) + Vector(-placed*xPadding+xOffset,1.1,10)})\n placed = placed + 1\n end\n end\n\n -- Setup Ready Token\n local ready = PlayerBag.takeObject({\n position = Vector(spos.x,0,spos.z) + Vector(6, 1.1, 7),\n rotation = Vector(0, 180, 180),\n })\n\n Global.call(\"removeSpirit\", {spirit=self.guid, color=player_color, ready=ready})\n\n -- Setup Energy Counter\n local counter = getObjectFromGUID(Global.getVar(\"counterBag\")).takeObject({position = Vector(spos.x,0,spos.z) + Vector(-5,1,5)})\n counter.setLock(true)\n\n -- Setup Progression Deck if enabled\n if useProgression then\n local minorPowerDeck = getObjectFromGUID(Global.getVar(\"minorPowerZone\")).getObjects()[1]\n local majorPowerDeck = getObjectFromGUID(Global.getVar(\"majorPowerZone\")).getObjects()[1]\n local progressionDeck = progressionCard.getVar(\"progressionDeck\")\n for i,card in pairs(progressionDeck) do\n if card[2] then\n majorPowerDeck.takeObject({\n position = Vector(spos.x,i,spos.z) + Vector(0,1.1,14),\n rotation = Vector(0,180,180),\n guid = card[1],\n })\n else\n minorPowerDeck.takeObject({\n position = Vector(spos.x,i,spos.z) + Vector(0,1.1,14),\n rotation = Vector(0,180,180),\n guid = card[1],\n })\n end\n end\n end\n\n -- Setup objects on top of board\n for i,obj in pairs (castObjects) do\n obj.setLock(false)\n if obj.type == \"Deck\" then\n if string.find(obj.getName(),\"Aspects\") then\n HandleAspect(obj, player_color)\n else\n obj.deal(#obj.getObjects(),player_color)\n end\n elseif obj.type == \"Card\" and string.find(obj.getName(),\"Progression\") then\n if useProgression then\n obj.setPositionSmooth(Vector(spos.x,8,spos.z) + Vector(0,1.1,14))\n else\n obj.destruct()\n end\n else\n obj.setPositionSmooth(Vector(spos.x,0,spos.z) + Vector(-placed*xPadding+xOffset,1.1,10))\n placed = placed + 1\n end\n end\n else\n Player[player_color].broadcast(\"You already picked a spirit\", \"Red\")\n end\nend\nfunction HandleAspect(deck, player_color)\n if useAspect == 0 then\n deck.destruct()\n elseif useAspect == 1 then\n local index = math.random(0,#deck.getObjects())\n if index == 0 then\n Player[player_color].broadcast(\"Your random Aspect is no Aspect\", Color.SoftBlue)\n deck.destruct()\n else\n deck.takeObject({\n index = index - 1,\n position = deck.getPosition() + Vector(0,2,0),\n callback_function = function(obj) obj.deal(1, player_color) deck.destruct() Player[player_color].broadcast(\"Your random Aspect is \"..obj.getName(), Color.SoftBlue) end,\n })\n if deck.remainder then deck = deck.remainder end\n end\n elseif useAspect == 3 then\n local found = false\n for index, data in pairs(deck.getObjects()) do\n if data.name == aspect then\n found = true\n deck.takeObject({\n index = data.index,\n position = deck.getPosition() + Vector(0,2,0),\n callback_function = function(obj) obj.deal(1, player_color) deck.destruct() end,\n })\n if deck.remainder then deck = deck.remainder end\n break\n end\n end\n if not found then\n deck.destruct()\n Player[player_color].broadcast(\"Unable to find aspect \"..aspect, \"Red\")\n end\n else\n deck.deal(#deck.getObjects(), player_color)\n end\nend\n\nfunction ToggleProgression()\n useProgression = not useProgression\n if useProgression then\n self.editButton({\n index = 1,\n label = \"Progression\",\n })\n else\n self.editButton({\n index = 1,\n label = \"No Progression\",\n })\n end\nend\nfunction ToggleAspect(_, _, alt_click)\n if alt_click then\n useAspect = (useAspect - 1) % 3\n else\n useAspect = (useAspect + 1) % 3\n end\n if useAspect == 0 then\n self.editButton({\n index = 2,\n label = \"No Aspects\",\n })\n elseif useAspect == 1 then\n self.editButton({\n index = 2,\n label = \"Random Aspect\",\n })\n else\n self.editButton({\n index = 2,\n label = \"Include Aspects\",\n })\n end\nend\n-----\nfunction upCast(obj,dist,offset,multi)\n local dist = dist or 1\n local offset = offset or 0\n local multi = multi or 1\n local oPos = obj.getPosition()\n local oBounds = obj.getBoundsNormalized()\n local oRot = obj.getRotation()\n local orig = Vector(oPos[1],oPos[2]+offset,oPos[3])\n local siz = Vector(oBounds.size.x*multi,dist,oBounds.size.z*multi)\n local orient = Vector(oRot[1],oRot[2],oRot[3])\n local hits = Physics.cast({\n origin = orig,\n direction = Vector(0,1,0),\n type = 3,\n size = siz,\n orientation = orient,\n max_distance = 0,\n --debug = true,\n })\n local hitObjects = {}\n for i,v in pairs(hits) do\n if v.hit_object ~= obj then table.insert(hitObjects,v.hit_object) end\n end\n return hitObjects\nend",
"LuaScriptState": "",
"XmlUI": "",
"AttachedSnapPoints": [
Expand Down

0 comments on commit 6a766b3

Please sign in to comment.