Compare commits
No commits in common. "39d1b9530716305af475241947ce1a2313542f3f" and "4790caffa5645a6e12797606761ab118c091746d" have entirely different histories.
39d1b95307
...
4790caffa5
4210
player_model.bbmodel
4210
player_model.bbmodel
File diff suppressed because one or more lines are too long
110
script.lua
110
script.lua
@ -2,8 +2,7 @@
|
|||||||
-- TODO rewrite variables: armor_model, model
|
-- TODO rewrite variables: armor_model, model
|
||||||
--- Initial definitions ---
|
--- Initial definitions ---
|
||||||
-- player model backwards compatibility
|
-- player model backwards compatibility
|
||||||
MODEL_NAME="player_model"
|
model=models.player_model
|
||||||
model=models[MODEL_NAME]
|
|
||||||
ping=pings
|
ping=pings
|
||||||
-- Texture dimensions --
|
-- Texture dimensions --
|
||||||
TEXTURE_WIDTH = 256
|
TEXTURE_WIDTH = 256
|
||||||
@ -644,113 +643,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
-- Wipers {{{
|
|
||||||
do
|
|
||||||
local wiper_state="STOPPED" -- valid states are "STOPPED", "STARTING", "STARTED", "STOPPING"
|
|
||||||
local wiper_wipe=animations[MODEL_NAME].wiper_wipe
|
|
||||||
local wiper_target_state=false
|
|
||||||
local wiper_deploy=animations[MODEL_NAME].wiper_deploy
|
|
||||||
local wiper=model.Head_Accessory.Wiper
|
|
||||||
assert(type(wiper_wipe)=="Animation")
|
|
||||||
assert(type(wiper_deploy)=="Animation")
|
|
||||||
assert(type(wiper)=="ModelPart")
|
|
||||||
|
|
||||||
wiper_wipe:setPriority(1)
|
|
||||||
wiper_deploy:setPriority(0)
|
|
||||||
wiper:setVisible(false)
|
|
||||||
|
|
||||||
---Check if a HOLD type animation is currently held
|
|
||||||
---@param animation Animation Check if an animation is waiting at the end of a hold
|
|
||||||
local function hold_ended(animation)
|
|
||||||
local anim_time=animation:getTime()
|
|
||||||
local anim_length=animation:getLength()
|
|
||||||
|
|
||||||
return animation:getLoop()=="HOLD" and
|
|
||||||
(anim_time==anim_length or anim_time==0)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Finish and hold an animation on the last frame
|
|
||||||
---@return boolean Whether or not the animation has reached the end of the hold
|
|
||||||
function stop_and_wait(animation)
|
|
||||||
if hold_ended(animation) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
animation:setLoop("HOLD")
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- steps to stop:
|
|
||||||
-- stop wiping animation
|
|
||||||
-- (set to hold, wait for time)
|
|
||||||
-- start retract animation (wiper_deploy, speed: -1)
|
|
||||||
-- wait for end
|
|
||||||
-- finalize state, hide part
|
|
||||||
--
|
|
||||||
-- steps to start:
|
|
||||||
-- show part
|
|
||||||
-- start animation (wiper_deploy, speed: 1)
|
|
||||||
-- wait for end
|
|
||||||
-- start wipe animation, loop
|
|
||||||
local wiper_run_deploy_switch={
|
|
||||||
STOPPED=function(state)
|
|
||||||
if state then
|
|
||||||
wiper_state="STARTING"
|
|
||||||
wiper_deploy:setSpeed(1):stop():play()
|
|
||||||
wiper:setVisible(true)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
STARTING=function(state)
|
|
||||||
if wiper_deploy:getTime()==wiper_deploy:getLength() then
|
|
||||||
wiper_deploy:stop()
|
|
||||||
wiper_wipe:play():setLoop("LOOP")
|
|
||||||
wiper_state="STARTED"
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
STARTED=function(state)
|
|
||||||
if not state then
|
|
||||||
wiper_state="STOPPING"
|
|
||||||
stop_and_wait(wiper_wipe)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
STOPPING=function(state)
|
|
||||||
-- stop process has concluded
|
|
||||||
if wiper_deploy:getPlayState() == "PLAYING" and wiper_deploy:getTime()==0 then
|
|
||||||
wiper_state="STOPPED"
|
|
||||||
wiper:setVisible(false)
|
|
||||||
wiper_deploy:stop()
|
|
||||||
elseif stop_and_wait(wiper_wipe) then
|
|
||||||
wiper_wipe:stop()
|
|
||||||
wiper_deploy:setSpeed(-1):play()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Run deploy action
|
|
||||||
---@param state boolean Should the wiper be deployed?
|
|
||||||
local function wiper_run_deploy(state)
|
|
||||||
wiper_run_deploy_switch[wiper_state](state)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function wiper_sync_state()
|
|
||||||
wiper_run_deploy(wiper_target_state)
|
|
||||||
end
|
|
||||||
--- Set wiper state. Ignores subsequent calls
|
|
||||||
---@param state boolean true to start wiper, false to stop wiper
|
|
||||||
function set_wiper(state)
|
|
||||||
if state ~= wiper_target_state then
|
|
||||||
wiper_target_state=state
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function wiper_tick()
|
|
||||||
set_wiper(player:isInRain())
|
|
||||||
wiper_sync_state()
|
|
||||||
end
|
|
||||||
|
|
||||||
events.TICK:register(wiper_tick, "wiper")
|
|
||||||
end
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- initialize values -- {{{
|
-- initialize values -- {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user