maintenance
This commit is contained in:
parent
8c8ceaaf47
commit
d27c1fa39a
23 changed files with 1977 additions and 1564 deletions
25
scripts/libs/SquAPI_modules/animateTexture.lua
Normal file
25
scripts/libs/SquAPI_modules/animateTexture.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---@class animateTexture
|
||||
local animateTexture = {}
|
||||
|
||||
---Easy-use Animated Texture.
|
||||
---@param element ModelPart The part of your model who's texture will be aniamted.
|
||||
---@param numberOfFrames number The number of frames.
|
||||
---@param framePercent number What percent width/height the uv takes up of the whole texture. For example: if there is a 100x100 texture, and the uv is 20x20, this will be .20
|
||||
---@param slowFactor? number Defaults to `1`, increase this to slow down the animation.
|
||||
---@param vertical? boolean Defaults to `false`, set to true if you'd like the animation frames to go down instead of right.
|
||||
---@class SquAPI.AnimateTexture
|
||||
function animateTexture:new(element, numberOfFrames, framePercent, slowFactor, vertical)
|
||||
assert(element,
|
||||
"§4Your model path for animateTexture is incorrect.§c")
|
||||
|
||||
vertical = vertical or false
|
||||
slowFactor = slowFactor or 1
|
||||
|
||||
function events.tick()
|
||||
local time = world.getTime()
|
||||
local frameshift = math.floor(time / slowFactor) % numberOfFrames * framePercent
|
||||
if vertical then element:setUV(0, frameshift) else element:setUV(frameshift, 0) end
|
||||
end
|
||||
end
|
||||
|
||||
return animateTexture
|
||||
Loading…
Add table
Add a link
Reference in a new issue