bug: animation :wait doesn't work with 'built-in' animations #52

Closed
opened 2023-04-02 18:17:52 +08:00 by luiz00martins · 4 comments
luiz00martins commented 2023-04-02 18:17:52 +08:00 (Migrated from github.com)

Description

Using :wait before one of the build-in animations (:size, :position, offset, etc) will not wait before executing the animation.

Minimal Working Example

-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
		shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))

local main = basalt.createFrame("mainFrame")
local W, H = main:getSize()

-- Frame using built-in animation (size) will not properly wait.
local frame_not_working = main:addFrame("frame_not_working")
	frame_not_working:setSize(math.floor(W/2)-2, H-2)
	frame_not_working:setPosition(2, 2)
	frame_not_working:setBackground(colors.black)
	frame_not_working:setBorder(colors.white)

local animation_not_working = main:addAnimation("animation_not_working")
	:setObject(frame_not_working)
	:setMode("linear")
	-- This will fail. It will not wait 3 seconds.
	:wait(3)
	:size(math.floor(W/2)-2, 0, 0.5)
	:onDone(function()
		frame_not_working:remove()
	end)

-- Frame avoiding built-in animation (manually resizing) will wait.
local frame_working = main:addFrame("frame_working")
	frame_working:setSize(math.floor(W/2)-2, H-2)
	frame_working:setPosition(math.floor(W/2)+1, 2)
	frame_working:setBackground(colors.black)
	frame_working:setBorder(colors.white)

local animation_working = main:addAnimation("animation_working")
	:setObject(frame_working)
	-- This will succeed, it will wait 3 seconds.
	:wait(3)

for _ = 1, H-3 do
	animation_working:add(function()
		frame_working:setSize(0, -1, 'r')
	end)
		:wait(0.01)
end
animation_working:onDone(function()
		frame_working:remove()
	end)

-- Execute.
animation_not_working:play()
animation_working:play()

basalt.autoUpdate()

https://user-images.githubusercontent.com/43142209/229346737-91242951-ec2a-460f-8bcc-60f164278367.mp4

Expected behavior

Wait the amount specified in :wait before starting built-in animation.

Checklist

[✔️] I am running the latest version.

### Description Using `:wait` before one of the build-in animations (`:size`, `:position`, `offset`, etc) will not wait before executing the animation. ### Minimal Working Example ```lua -- Basalt configurated installer local filePath = "/basalt.lua" --here you can change the file path default: basalt if not(fs.exists(filePath))then shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command end local basalt = require(filePath:gsub(".lua", "")) local main = basalt.createFrame("mainFrame") local W, H = main:getSize() -- Frame using built-in animation (size) will not properly wait. local frame_not_working = main:addFrame("frame_not_working") frame_not_working:setSize(math.floor(W/2)-2, H-2) frame_not_working:setPosition(2, 2) frame_not_working:setBackground(colors.black) frame_not_working:setBorder(colors.white) local animation_not_working = main:addAnimation("animation_not_working") :setObject(frame_not_working) :setMode("linear") -- This will fail. It will not wait 3 seconds. :wait(3) :size(math.floor(W/2)-2, 0, 0.5) :onDone(function() frame_not_working:remove() end) -- Frame avoiding built-in animation (manually resizing) will wait. local frame_working = main:addFrame("frame_working") frame_working:setSize(math.floor(W/2)-2, H-2) frame_working:setPosition(math.floor(W/2)+1, 2) frame_working:setBackground(colors.black) frame_working:setBorder(colors.white) local animation_working = main:addAnimation("animation_working") :setObject(frame_working) -- This will succeed, it will wait 3 seconds. :wait(3) for _ = 1, H-3 do animation_working:add(function() frame_working:setSize(0, -1, 'r') end) :wait(0.01) end animation_working:onDone(function() frame_working:remove() end) -- Execute. animation_not_working:play() animation_working:play() basalt.autoUpdate() ``` https://user-images.githubusercontent.com/43142209/229346737-91242951-ec2a-460f-8bcc-60f164278367.mp4 ### Expected behavior Wait the amount specified in `:wait` before starting built-in animation. ### Checklist [✔️] I am running the latest version.
NoryiE commented 2023-04-02 18:42:15 +08:00 (Migrated from github.com)

Hello, the :wait method is meant to be used with :add and :rep but doesn't work with the built-in animations. Bult-in animations also have a way to wait before actually start the animations: size(1, 1, 0.5, 2) <- the last parameter. This should work with all builtin animations

Hello, the :wait method is meant to be used with :add and :rep but doesn't work with the built-in animations. Bult-in animations also have a way to wait before actually start the animations: size(1, 1, 0.5, 2) <- the last parameter. This should work with all builtin animations
luiz00martins commented 2023-04-02 19:17:36 +08:00 (Migrated from github.com)

btw @NoryiE, :rep doesn't seem to be documented in the Animation page.

btw @NoryiE, `:rep` doesn't seem to be documented in the [Animation](https://basalt.madefor.cc/#/objects/Animation) page.
NoryiE commented 2023-04-02 19:32:23 +08:00 (Migrated from github.com)

Oh wow, thank you. :rep is just the short form for repeat and it just means to repeat the last function which got added with :add. This only makes sense when you use for example :setPosition(1, 0, true) <- true means adding the amount to the current position instead of setting it to 1, 0. add/rep and wait was my first try to create a way to animate object. But nobody used it because you had to do everything yourself. Then i decided to create pre-made animations but didn't want to remove :add/:rep and :wait, because maybe someone wanted to create something more complicated. Still, i dislike the current way of how much you have to do to animate something. So i've decided to create a better animation system which will be available in 1.7, where you're able to just do button:animatePosition(5, 10, 2) and it will be animated as soon as the command gets called. I think this is the most comfortable solution. Which means :rep will become obsolete in the future.

Oh wow, thank you. :rep is just the short form for repeat and it just means to repeat the last function which got added with :add. This only makes sense when you use for example :setPosition(1, 0, true) <- true means adding the amount to the current position instead of setting it to 1, 0. add/rep and wait was my first try to create a way to animate object. But nobody used it because you had to do everything yourself. Then i decided to create pre-made animations but didn't want to remove :add/:rep and :wait, because maybe someone wanted to create something more complicated. Still, i dislike the current way of how much you have to do to animate something. So i've decided to create a better animation system which will be available in 1.7, where you're able to just do button:animatePosition(5, 10, 2) and it will be animated as soon as the command gets called. I think this is the most comfortable solution. Which means :rep will become obsolete in the future.
luiz00martins commented 2023-04-02 19:39:52 +08:00 (Migrated from github.com)

Sounds nice! I'll be on the :waitlist :)

Sounds nice! I'll be on the `:wait`list :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GitHub/Basalt#52
No description provided.