diff --git a/lua/entities/gmod_wire_expression2/core/hologram.lua b/lua/entities/gmod_wire_expression2/core/hologram.lua index eff492bc5f..d855e6fc29 100644 --- a/lua/entities/gmod_wire_expression2/core/hologram.lua +++ b/lua/entities/gmod_wire_expression2/core/hologram.lua @@ -328,10 +328,12 @@ local function flush_player_color_queue() net.Broadcast() end + registerCallback("postexecute", function(self) if timer.Exists("wire_hologram_postexecute_"..self.uid) then return end timer.Create("wire_hologram_postexecute_"..self.uid,0.1,1,function() if not IsValid(self.entity) then return end + flush_scale_queue() flush_bone_scale_queue() flush_clip_queue() @@ -1276,6 +1278,170 @@ end -- ----------------------------------------------------------------------------- +local function SetHoloAnim(Holo, Animation, Frame, Rate) + if (Holo and Animation and Frame and Rate) then + if not Holo.ent.Animated then + -- This must be run once on entities that will be animated + Holo.ent.Animated = true + Holo.ent.AutomaticFrameAdvance = true + end + Holo.ent:ResetSequence(Animation) + Holo.ent:SetCycle(math.Clamp(Frame, 0, 1)) + --Something mustve changed between the time holoAnim core was made and now, negative values no longer affect the "Frame" value + Holo.ent:SetPlaybackRate(math.Clamp(Rate, -12, 12)) + end +end + +__e2setcost(15) +e2function void holoAnim(index, string animation) + local Holo = CheckIndex(self, index) + if not Holo then return end + local anim = Holo.ent:LookupSequence(animation) + if anim == -1 then self:throw("'" .. animation .. "' does not exist on this model!", 0) end + + SetHoloAnim(Holo, anim, 0, 1) +end + +e2function void holoAnim(index, string animation, frame) + local Holo = CheckIndex(self, index) + if not Holo then return end + if Holo.ent:LookupSequence(animation) == -1 then self:throw("'" .. animation .. "' does not exist on this model!", 0) end + + SetHoloAnim(Holo, animation, frame, 1) +end + +e2function void holoAnim(index, string animation, frame, rate) + local Holo = CheckIndex(self, index) + if not Holo then return end + if Holo.ent:LookupSequence(animation) == -1 then self:throw("'" .. animation .. "' does not exist on this model!", 0) end + + SetHoloAnim(Holo, animation, frame, rate) +end + +e2function void holoAnim(index, animation) + local Holo = CheckIndex(self, index) + if not Holo then return end + + SetHoloAnim(Holo, animation, 0, 1) +end + +e2function void holoAnim(index, animation, frame) + local Holo = CheckIndex(self, index) + if not Holo then return end + + SetHoloAnim(Holo, animation, frame, 1) +end + +e2function number holoGetAnimFrame(index) + local Holo = CheckIndex(self, index) + if not Holo then return end + + return Holo.ent:GetCycle() +end + +e2function void holoAnim(index, animation, frame, rate) + local Holo = CheckIndex(self, index) + if not Holo then return end + + SetHoloAnim(Holo, animation, frame, rate) +end + +e2function array holoGetAnims(index) + local Holo = CheckIndex(self, index) + if not Holo then return end + + return Holo.ent:GetSequenceList() +end + +e2function number holoAnimLength(index) + local Holo = CheckIndex(self, index) + if not Holo then return end + + return Holo.ent:SequenceDuration() +end + +e2function number holoAnimNum(index, string animation) + local Holo = CheckIndex(self, index) + if not Holo then return end + + return Holo.ent:LookupSequence(animation) or 0 +end + +e2function number holoGetAnimGroundSpeed(index, string animation) + local Holo = CheckIndex(self, index) + if not Holo then return end + local anim = Holo.ent:LookupSequence(animation) + if anim == -1 then self:throw("'" .. animation .. "' does not exist on this model!", 0) end + + return Holo.ent:GetSequenceGroundSpeed(anim) +end + +e2function void holoSetAnimFrame(index, frame) + local Holo = CheckIndex(self, index) + if not Holo then return end + + Holo.ent:SetCycle(math.Clamp(frame, 0, 1)) +end + +e2function void holoSetAnimSpeed(index, rate) + local Holo = CheckIndex(self, index) + if not Holo then return end + + Holo.ent:SetPlaybackRate(math.Clamp(rate, -12, 12)) +end + +e2function number holoGetAnimGroundSpeed(index, animation) + local Holo = CheckIndex(self, index) + if not Holo then return end + + return Holo.ent:GetSequenceGroundSpeed(animation) +end + +e2function void holoSetPose(index, string pose, value) + local Holo = CheckIndex(self, index) + if not Holo then return end + + Holo.ent:SetPoseParameter(pose, value) +end + +e2function number holoGetPose(index, string pose) + local Holo = CheckIndex(self, index) + if not Holo then return end + + local pose_param = Holo.ent:LookupPoseParameter(pose) + if pose_param == -1 then self:throw("'" .. pose .. "' pose parameter does not exist on this model!", 0) end + return Holo.ent:GetPoseParameter(pose_param) +end + +e2function array holoGetPoses(index) + local Holo = CheckIndex(self, index) + if not Holo then return end + + local tbl = {} + for i = 0, Holo.ent:GetNumPoseParameters() - 1 do + table.insert(tbl, Holo.ent:GetPoseParameterName(i)) + end + return tbl +end + +e2function vector2 holoGetPoseRange(index, string pose) + local Holo = CheckIndex(self, index) + if not Holo then return end + + local pose_param = Holo.ent:LookupPoseParameter(pose) + if pose_param == -1 then self:throw("'" .. pose .. "' pose parameter doesn't exist on this model!", 0) end + return { Holo.ent:GetPoseParameterRange(pose_param) } +end + +e2function void holoClearPoses(index) + local Holo = CheckIndex(self, index) + if not Holo then return end + + Holo.ent:ClearPoseParameters() +end + +-- ----------------------------------------------------------------------------- + registerCallback("construct", function(self) if not E2HoloRepo[self.uid] then E2HoloRepo[self.uid] = {} diff --git a/lua/entities/gmod_wire_hologram.lua b/lua/entities/gmod_wire_hologram.lua index 91881e0252..c789e4ce31 100644 --- a/lua/entities/gmod_wire_hologram.lua +++ b/lua/entities/gmod_wire_hologram.lua @@ -426,6 +426,13 @@ function ENT:OnRemove() net.Broadcast() end +function ENT:Think() + if self.Animated then + self:NextThink(CurTime()) + return true + end +end + function ENT:Initialize() self.steamid = "" self:SetSolid(SOLID_NONE) diff --git a/lua/wire/client/e2descriptions.lua b/lua/wire/client/e2descriptions.lua index ac1fc0f7de..39b6a0e5db 100644 --- a/lua/wire/client/e2descriptions.lua +++ b/lua/wire/client/e2descriptions.lua @@ -1302,6 +1302,25 @@ E2Helper.Descriptions["holoClipsAvailable()"] = "Returns the maximum number of c E2Helper.Descriptions["holoInvertModel(nn)"] = "If not 0, inverts the model of the hologram" E2Helper.Descriptions["holoRenderFX(nn)"] = "Changes the RenderFX for a hologram" E2Helper.Descriptions["holoSkin(nn)"] = "Changes the skin of a hologram" +E2Helper.Descriptions["holoAnim(nsnn)"] = "Plays animation on the hologram specified by the index, the speed and starting point of which is determined by frame (ranging from 0 to 1) and rate (ranging from -12 to 12) values respectively" +E2Helper.Descriptions["holoAnim(nnnn)"] = "Plays animation on the hologram specified by the index, the speed and starting point of which is determined by frame (ranging from 0 to 1) and rate (ranging from -12 to 12) values respectively" +E2Helper.Descriptions["holoAnim(ns)"] = "Plays animation on the hologram specified by the index from frame 0 at the speed of 1" +E2Helper.Descriptions["holoAnim(nn)"] = "Plays animation on the hologram specified by the index from frame 0 at the speed of 1" +E2Helper.Descriptions["holoAnim(nnn"] = "Plays animation on the hologram specified by the index from the desired frame (ranging from 0 to 1) at the speed of 1" +E2Helper.Descriptions["holoAnim(nsn"] = "Plays animation on the hologram specified by the index from the desired frame (ranging from 0 to 1) at the speed of 1" +E2Helper.Descriptions["holoAnimLength(n)"] = "Returns the duration of the currently playing animation index hologram" +E2Helper.Descriptions["holoAnimNum(ns)"] = "Returns the number value of the animation string on the index hologram" +E2Helper.Descriptions["holoGetAnimFrame(n)"] = "Returns the current frame of the playing animation (ranging from 0 to 1) on the index hologram" +E2Helper.Descriptions["holoGetAnimGroundSpeed(ns)"] = "Returns the ground speed of the string animation on the index hologram" +E2Helper.Descriptions["holoGetAnimGroundSpeed(nn)"] = "Returns the ground speed of the number animation on the index hologram" +E2Helper.Descriptions["holoGetAnims(n)"] = "Returns the number value of the animation string" +E2Helper.Descriptions["holoSetAnimFrame(nn)"] = "Sets the frame of the active animation of the index hologram (ranging from 0 to 1)" +E2Helper.Descriptions["holoSetAnimSpeed(nn)"] = "Sets the active animation speed of the index hologram (ranging from -12 and 12)" +E2Helper.Descriptions["holoClearPoses(n)"] = "Sets all pose parameters of the hologram specified by the index to 0" +E2Helper.Descriptions["holoGetPose(ns)"] = "Returns the pose parameter specified by the string on the hologram specified by the index" +E2Helper.Descriptions["holoGetPoseRange(ns)"] = "Returns the range of the pose parameter specified by the string on the hologram specified by the index" +E2Helper.Descriptions["holoGetPoses(n)"] = "Returns all existing pose parameters on the hologram specified by the index" +E2Helper.Descriptions["holoSetPose(nsn)"] = "Sets the string pose parameter on the index hologram by the number value, the range of which can be found with holoGetPoseRange()" -- File E2Helper.Descriptions["fileLoaded()"] = "DEPRECATED. Use 'event fileLoaded(FilePath:string, Data:string)' instead! Returns whether or not the file has been loaded onto the server"