This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
--[[
Rotation Puzzle 001 [V1] (03/02/2015)
Written by AFRLme [Lee Clarke]
-- + --
afrlme@outlook.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
-- * variables * --
local size, pos
-- * tables * --
local t = {0, 60, 120, 180, 240, 300}
-- * function which rotates the tiles * --
function rotateObject(obj, delay, direction)
obj = Objects[obj]
obj.RotationCenter = { x = -1, y = -1 }
obj.Rotation = obj.Rotation
if direction then
if math.floor(math.deg(obj.Rotation)) == 0 or math.ceil(math.deg(obj.Rotation)) == 0 then obj:to(delay, {Rotation = math.rad(60)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 60 or math.ceil(math.deg(obj.Rotation)) == 60 then obj:to(delay, {Rotation = math.rad(120)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 120 or math.ceil(math.deg(obj.Rotation)) == 120 then obj:to(delay, {Rotation = math.rad(180)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 180 or math.ceil(math.deg(obj.Rotation)) == 180 then obj:to(delay, {Rotation = math.rad(240)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 240 or math.ceil(math.deg(obj.Rotation)) == 240 then obj:to(delay, {Rotation = math.rad(300)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 300 or math.ceil(math.deg(obj.Rotation)) == 300 then obj:to(delay, {Rotation = math.rad(0)}, easeLinearOut)
end
else
if math.floor(math.deg(obj.Rotation)) == 0 or math.ceil(math.deg(obj.Rotation)) == 0 then obj:to(delay, {Rotation = math.rad(300)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 60 or math.ceil(math.deg(obj.Rotation)) == 60 then obj:to(delay, {Rotation = math.rad(0)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 120 or math.ceil(math.deg(obj.Rotation)) == 120 then obj:to(delay, {Rotation = math.rad(60)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 180 or math.ceil(math.deg(obj.Rotation)) == 180 then obj:to(delay, {Rotation = math.rad(120)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 240 or math.ceil(math.deg(obj.Rotation)) == 240 then obj:to(delay, {Rotation = math.rad(180)}, easeLinearOut)
elseif math.floor(math.deg(obj.Rotation)) == 300 or math.ceil(math.deg(obj.Rotation)) == 300 then obj:to(delay, {Rotation = math.rad(240)}, easeLinearOut)
end
end
end
-- * function which randomizes tile degrees at begin of scene * --
function initPzl_1(obj)
for i = 1, 3 do
-- + --
obj = Objects["pzl-001_"..i]
obj.RotationCenter = { x = -1, y = -1 }
obj.Rotation = obj.Rotation
-- + --
obj:to(0, { Rotation = math.rad( t[math.random(6)] ) }, easeLinearOut)
end
end
-- * function which checks if tiles rotation value is 0 * --
function checkPzl_1(o)
if math.floor(math.deg(Objects[o].Rotation)) == 0 or math.ceil(math.deg(Objects[o].Rotation)) == 0 then
return true
end
end
wheel = Scenes["room_mill_outside"].Objects["gfx_waterwheel"]
function rotateWheel()
wheel.Rotation = wheel.Rotation + 0.01
if wheel.Rotation > 2 * math.pi then wheel.Rotation = wheel.Rotation - 2 * math.pi end
end
registerEventHandler("mainLoop", "rotateWheel")
local obj =
game.CurrentScene.SceneObjects["water_wheel"]
obj.RotationCenter = {x = -1, y = -1} -- define rotation center as center of sprite
obj:to(3000, {Rotation = math.rad(360)}, easeCircInOut, true, false)
to(delay in ms, {actions, separated, by, commas}, easing, loop, reverse)
Objects["button1"]:to(300, {Visibility = 0}) -- set button1 to 0% opacity over 300ms