[QUOTE=EthanTheGreat;48791781]I am looking for a clientside hook.
This hook should run constantly, similar to the [B][U]Think Hook.[/U][/B]
Except, the hook needs to be constant. (Think hook varies depending on CurTime( ), AKA, FPS drops will drain it's run time).
Can anyone think of a hook that is clientside that doesn't drop speed regardless of FPS drop?
This a tough request, I don't think anything like this exists in gmod.
I need the hook to run constantly, and without fail.[/QUOTE]
And why wouldn't the "Tick" hook work?
FPS is a variable that can be very unpredictable.
One client may get 30fps, another 60fps, another 45fps.
Sure, everything has to run according to each frame.
However, I'm wondering if it's possible to bypass this by having something that doesn't depend on FPS to be constant.
Here's an example:
Each delta is between each call. The time it takes for each call to occur....
Think and delta seconds: (FPS Varies, so does the delta time)
[B][0.3] [0.31] [0.5] [1] [0.3][/B]
Tick and delta seconds:
[B][0.5] [0.3] [0.9] [0.3] [0.25][/B]
What I want:
Think and delta (unfps affected):
[B][0.3] [0.3] [0.3] [0.3] [0.3][/B]
Tick and delta seconds: (unfps affected)
[B][0.3] [0.3] [0.3] [0.3] [0.3][/B]
I need constant ticking because without it, I can't fully match clientside physics on clients that have different FPSes.
An alternative method is to check the time, and regulate the physics depending on the delta-time. But that may be unreliable.
[B]EDIT:[/B]
I need this [url=http://wiki.garrysmod.com/page/ENTITY/PhysicsSimulate]PhysicsSimulate[/url] hook,
in a GAMEMODE format.
I'm Still thinking about the method...
Well system times like system.AppTime() shouldn't be affected by FPS. Just store the current system time to a variable, and the next time you do your calculation subtract the current system from the stored system time and you get pretty much the same functionality of PhysicsSimulate.
Hmmm.. I was thinking about it...
Thanks for helping me think out the problem..
Tomorrow, I'm going to tackle this issue head on..
Only today was I confronted with this issue...
I did a test using the code below:
[code]
lua_run_cl local oldR = RealTime( ) hook.Add( "Think", "Z", function( ) print( RealTime( ) - oldR ) oldR = RealTime( ) end )
[/code]
Output on 300FPS: 0.003~~
Output on 20FPS: 0.05~~
The Think hook is highly dependent on the FPS.
I have two points in space, and the distance between them.
The distance will occasionally increase or decrease.
How can I divide up a line between these two points into equal-length "segments", and get ALL of the points in space that correspond to the start/end of a segment?
Basically like a chain of sausage links, where I want to know the coordinates of all the joints, and how many joints there are.
[QUOTE=EthanTheGreat;48791983]Hmmm.. I was thinking about it...[/QUOTE]
what do you need this for? why can't you just use a delta variable?
[QUOTE=Z0mb1n3;48792105]Basically like a chain of sausage links, where I want to know where the joint will be.[/QUOTE]
that's [url=https://en.wikipedia.org/wiki/Inverse_kinematics]inverse kinematics[/url] (good luck)
I've got a question, I'm running a Garry's mod server and I'm using Exho's Chatbox <3
and I've modified it slightly to add chat tags within the chat.AddText() function for players.
Now I'm not sure why but its thinking the player messaging is a string, so its just displaying:
[ LittleBigBug_ ]: Message
as a string
[CODE]
elseif type(obj) == "string" then -- Where its going
eChat.chatLog:AppendText( obj )
table.insert( msg, obj )
elseif obj:IsPlayer() then -- Where its supposed to be
local ply = obj
[/CODE]
I have no idea. I'm running my server on Windows Server (If that makes a difference, but I bet not actually) and it is darkrp. I will try removing all addons besides ULX and the chatbox of course, to test it.
So I'm thinking its making the player's chat a string with the OnPlayerChat Hook somewhere but I can't seem to find it.
[B]Edit:[/B]
Just tested with no addons besides ULX and eChat. Still wont work for me.
[QUOTE=PortalGod;48792147]what do you need this for? why can't you just use a delta variable?
that's [URL="https://en.wikipedia.org/wiki/Inverse_kinematics"]inverse kinematics[/URL] (good luck)[/QUOTE]
Really? There's no way to simply do something like
[t]http://puu.sh/ktayc.jpg[/t]
and add a point every x units?
If the segment length would go beyond the point given, no new segment is started.
[QUOTE=Z0mb1n3;48792194]Really? There's no way to simply do something like
[t]http://puu.sh/ktayc.jpg[/t]
and add a point every x units?
If the segment length would go beyond the point given, no new segment is started.[/QUOTE]
ohh, when you were talking about joints and stuff I thought you meant you wanted IK. for that, couldn't you just do math.floor(length/segmentlength) to find out how many segments you need?
[QUOTE=PortalGod;48792221]ohh, when you were talking about joints and stuff I thought you meant you wanted IK. for that, couldn't you just do math.floor(length/segmentlength) to find out how many segments you need?[/QUOTE]
Oh. Does this look right to you, then?
[code]
function GetSegments(p1, p2, seglength, inclusive)
local points = {}
local distance = p1:Distance(p2)
local norm = (p2 - p1):GetNormalized()
local total = math.floor(distance/seglength)
local npos = p1
if inclusive then
table.insert(points, p1)
end
for i = 1, total do
npos = npos + norm * seglength
table.insert(points, npos)
end
return points
end
[/code]
edit:
Yay, that actually works. Thank you for your input!
i'm now getting this error
[code][ERROR] lua/weapons/weapon_launchcannon.lua:144: '<name>' expected near '<eof>'
1. unknown - lua/weapons/weapon_launchcannon.lua:0
[/code]
with this code
[code]if SERVER then
AddCSLuaFile()
resource.AddFile("materials/VGUI/ttt/icon_destroyer_launchcannon.vmt")
end
if CLIENT then
SWEP.PrintName = "Prop Cannon"
SWEP.Slot = 3 -- add 1 to get the slot number key
SWEP.ViewModelFOV = 54
SWEP.ViewModelFlip = false
end
-- Always derive from weapon_tttbase.
--- Standard GMod values
SWEP.Base = "weapon_tttbase"
SWEP.Primary.Automatic = false
SWEP.Primary.Damage = 0
SWEP.Primary.Ammo = "HelicopterGun"
SWEP.Kind = WEAPON_EQUIP1
SWEP.Primary.NumShots = 1
SWEP.Primary.Delay = 1
SWEP.Primary.ClipSize = 3
SWEP.Primary.ClipMax = 3
SWEP.Primary.DefaultClip = 3
SWEP.ViewModel = "models/weapons/c_rpg.mdl"
SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
function SWEP:Initialize()
self:SetHoldType("rpg")
canShoot = 1
end
--- TTT config values
-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8
SWEP.Kind = WEAPON_EQUIP2
-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false
-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }
-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil
-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = false
-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = true
-- Equipment menu information is only needed on the client
if CLIENT then
-- Path to the icon material
SWEP.Icon = "VGUI/ttt/icon_destroyer_launchcannon.vmt"
-- Text shown in the equip menu
SWEP.EquipMenuData = {
type = "Launch Cannon",
desc = "Aim at the ground to launch yourself!"
};
end
function SWEP:shootEnt()
local tr = self.Owner:GetEyeTrace()
self:EmitSound(Sound("weapons/grenade_launcher1.wav"))
if (!SERVER) then return end
prop = ents.Create("prop_physics")
prop:SetModel("models/props_junk/wood_crate001a.mdl")
prop:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector()* 32))
prop:SetAngles(self.Owner:EyeAngles())
prop:Spawn()
color = Color( math.random(0,255),math.random(0,255),math.random(0,255),math.random(100,255))
prop:SetColor(color)
prop:SetHealth(1)
local phys = prop:GetPhysicsObject()
if !(phys && IsValid(phys)) then prop:Remove() return end
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()* math.pow(tr.HitPos:Length(), 5))
prop:AddCallback("PhysicsCollide", function(self, data)
local ent = data.HitEntity
local explode = ents.Create("env_explosion")
if IsValid(ent) or (not IsValid(ent)) then -- check for whatever you want here, really
self:TakeDamage(100, self, self)
ent:TakeDamage(1000, self, self)
explode:SetPos( prop )
--This will be where the player is looking (using)
explode:SetOwner( self.Owner ) -- this sets you as the person who made the explosion
explode:Spawn() //this actually spawns the explosion
explode:SetKeyValue( "iMagnitude", "220" ) --the magnitude
explode:Fire( "Explode", 100, 100 )
end
end)
end
function SWEP:PrimaryAttack()
if canShoot == 1 then
canShoot = 0
timer.Simple(1, (function() canShoot = 1 end))
self.Owner:MuzzleFlash()
self:shootEnt()
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
end
end
function SWEP:Think()
end
function SWEP:Reload()
end[/code]
explode doesn't want to work for me ive been at it for about 2 hours now and it never does anything
[QUOTE=343N;48793108]i'm now getting this error
[code][ERROR] lua/weapons/weapon_launchcannon.lua:144: '<name>' expected near '<eof>'
1. unknown - lua/weapons/weapon_launchcannon.lua:0
[/code]
with this code
[code]if SERVER then
AddCSLuaFile()
resource.AddFile("materials/VGUI/ttt/icon_destroyer_launchcannon.vmt")
end
if CLIENT then
SWEP.PrintName = "Prop Cannon"
SWEP.Slot = 3 -- add 1 to get the slot number key
SWEP.ViewModelFOV = 54
SWEP.ViewModelFlip = false
end
-- Always derive from weapon_tttbase.
--- Standard GMod values
SWEP.Base = "weapon_tttbase"
SWEP.Primary.Automatic = false
SWEP.Primary.Damage = 0
SWEP.Primary.Ammo = "HelicopterGun"
SWEP.Kind = WEAPON_EQUIP1
SWEP.Primary.NumShots = 1
SWEP.Primary.Delay = 1
SWEP.Primary.ClipSize = 3
SWEP.Primary.ClipMax = 3
SWEP.Primary.DefaultClip = 3
SWEP.ViewModel = "models/weapons/c_rpg.mdl"
SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
function SWEP:Initialize()
self:SetHoldType("rpg")
canShoot = 1
end
--- TTT config values
-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8
SWEP.Kind = WEAPON_EQUIP2
-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false
-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }
-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil
-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = false
-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = true
-- Equipment menu information is only needed on the client
if CLIENT then
-- Path to the icon material
SWEP.Icon = "VGUI/ttt/icon_destroyer_launchcannon.vmt"
-- Text shown in the equip menu
SWEP.EquipMenuData = {
type = "Launch Cannon",
desc = "Aim at the ground to launch yourself!"
};
end
function SWEP:shootEnt()
local tr = self.Owner:GetEyeTrace()
self:EmitSound(Sound("weapons/grenade_launcher1.wav"))
if (!SERVER) then return end
prop = ents.Create("prop_physics")
prop:SetModel("models/props_junk/wood_crate001a.mdl")
prop:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector()* 32))
prop:SetAngles(self.Owner:EyeAngles())
prop:Spawn()
color = Color( math.random(0,255),math.random(0,255),math.random(0,255),math.random(100,255))
prop:SetColor(color)
prop:SetHealth(1)
local phys = prop:GetPhysicsObject()
if !(phys && IsValid(phys)) then prop:Remove() return end
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized()* math.pow(tr.HitPos:Length(), 5))
prop:AddCallback("PhysicsCollide", function(self, data)
local ent = data.HitEntity
local explode = ents.Create("env_explosion")
if IsValid(ent) or (not IsValid(ent)) then -- check for whatever you want here, really
self:TakeDamage(100, self, self)
ent:TakeDamage(1000, self, self)
explode:SetPos( prop )
--This will be where the player is looking (using)
explode:SetOwner( self.Owner ) -- this sets you as the person who made the explosion
explode:Spawn() //this actually spawns the explosion
explode:SetKeyValue( "iMagnitude", "220" ) --the magnitude
explode:Fire( "Explode", 100, 100 )
end
end)
end
function SWEP:PrimaryAttack()
if canShoot == 1 then
canShoot = 0
timer.Simple(1, (function() canShoot = 1 end))
self.Owner:MuzzleFlash()
self:shootEnt()
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
end
end
function SWEP:Think()
end
function SWEP:Reload()
end[/code]
explode doesn't want to work for me ive been at it for about 2 hours now and it never does anything[/QUOTE]
[img]http://puu.sh/ktk9H.png[/img]
bad
since you're using it in a swep, too, you should pick a different name for 'self' inside the addcallback.
Here you go, just swap this in for the callback you already have
[code]
prop:AddCallback("PhysicsCollide", function(crate, data)
local ent = data.HitEntity
local explode = ents.Create("env_explosion")
if IsValid(ent) or (not IsValid(ent)) then
-- check for whatever you want here, really
crate:TakeDamage(100, crate, crate)
ent:TakeDamage(1000, crate, crate)
explode:SetPos(crate:GetPos())
--This will be where the player is looking (using)
explode:SetOwner(self.Owner)
-- this sets you as the person who made the explosion
explode:Spawn()
--this actually spawns the explosion
explode:SetKeyValue("iMagnitude", "220")
--the magnitude
explode:Fire("Explode", 100, 100)
end
end)
[/code]
How do I retrieve the nice "Team Blue" string?
[code]
team.SetUp( TEAM_BLUE, "Team Blue", Color( 52, 152, 219 ), true )
[/code]
team.GetName(ply:Team()) is giving me nothing/blank
[QUOTE=NiandraLades;48793450]How do I retrieve the nice "Team Blue" string?
[code]
team.SetUp( TEAM_BLUE, "Team Blue", Color( 52, 152, 219 ), true )
[/code]
team.GetName(ply:Team()) is giving me nothing/blank[/QUOTE]
Have you assigned the player to a team before calling that?
[QUOTE=Hoffa1337;48793504]Have you assigned the player to a team before calling that?[/QUOTE]
I am indeed - could it be a sort of shared/server/client state related issue?
[QUOTE=NiandraLades;48793544]I am indeed - could it be a sort of shared/server/client state related issue?[/QUOTE]
could be, team should be synced but make sure you setup the teams shared.
I swear to god I've read up on how for loops work 100 times and I still don't get them. Can somebody give me a basic explanation please?
[QUOTE=Zelpa;48793938]I swear to god I've read up on how for loops work 100 times and I still don't get them. Can somebody give me a basic explanation please?[/QUOTE]
Depends on what you are trying to loop through.
You can run a loop 100 times like this:
[lua]for i=1,100 do
print(i)
end[/lua]
Or you can loop through a table of things like this:
[lua]local tableofthings = {"A","b","C","Dog","Things"}
for k,v in pairs(tableofthings) do
print(k,v)
end[/lua]
There's a few other uses as well.
[QUOTE=Revenge282;48794088]stuff[/QUOTE]
I'm trying to iterate through a table and run a DarkRP function to create an entity. I have a table full of food items like this
[code]foodItems.watermelon = { Name = "Watermelon", Model = "models/props_junk/watermelon01.mdl", Cost = 8, AppetiteLevel = 25, FoodHealth = 10, TextOffset = -100 }
foodItems.banana = { Name = "Banana", Model = "models/props/cs_italy/bananna.mdl", Cost = 3, AppetiteLevel = 15, FoodHealth = 7 }[/code]
I want to find an element in that table, like watermelon, and then run this code.
[code]DarkRP.createEntity(FoodData.Name, {
ent = "zelpa_basefood",
model = FoodData.Model,
price = FoodData.Cost,
max = 10,
cmd = "buy" .. FoodData.Name,
})[/code]
Using the data from those elements in foodItems.
[QUOTE=Zelpa;48794137]I'm trying to iterate through a table and run a DarkRP function to create an entity. I have a table full of food items like this
[code]foodItems.watermelon = { Name = "Watermelon", Model = "models/props_junk/watermelon01.mdl", Cost = 8, AppetiteLevel = 25, FoodHealth = 10, TextOffset = -100 }
foodItems.banana = { Name = "Banana", Model = "models/props/cs_italy/bananna.mdl", Cost = 3, AppetiteLevel = 15, FoodHealth = 7 }[/code]
I want to find an element in that table, like watermelon, and then run this code.
[code]DarkRP.createEntity(FoodData.Name, {
ent = "zelpa_basefood",
model = FoodData.Model,
price = FoodData.Cost,
max = 10,
cmd = "buy" .. FoodData.Name,
})[/code]
Using the data from those elements in foodItems.[/QUOTE]
Is it tables or for loops you don't understand?
[QUOTE=>>oubliette<<;48794409]Is it tables or for loops you don't understand?[/QUOTE]
I think I understand tables well enough, but actually implementing that in a for loop I just can't understand.
Edit: There's some more code related to the foodItems table if that helps
[code]function ENT:SetupDataTables()
self:NetworkVar( "String", 0, "FoodType" )
end
local FoodData = foodItems[ self:GetFoodType() ][/code]
[QUOTE=Zelpa;48794417]I think I understand tables well enough, but actually implementing that in a for loop I just can't understand.
Edit: There's some more code related to the foodItems table if that helps
[code]function ENT:SetupDataTables()
self:NetworkVar( "String", 0, "FoodType" )
end
local FoodData = foodItems[ self:GetFoodType() ][/code][/QUOTE]
Like Revenge mentioned above, to loop through a table you use structure:
[CODE]for key,value in pairs(table) do
--do some stuff here. you can use key and value to reference the current key or value.
end[/CODE]
In your example, you could do something like this:
[CODE]for k,v in pairs(foodItems) do
DarkRP.createEntity(v.Name, {
ent = "zelpa_basefood",
model = v.Model,
price = v.Cost,
max = 10,
cmd = "buy" .. v.Name,
})
end[/CODE]
[QUOTE=roastchicken;48794635]Like Revenge mentioned above, to loop through a table you use structure:
[CODE]for key,value in pairs(table) do
--do some stuff here. you can use key and value to reference the current key or value.
end[/CODE]
In your example, you could do something like this:
[CODE]for k,v in pairs(foodItems) do
DarkRP.createEntity(v.Name, {
ent = "zelpa_basefood",
model = v.Model,
price = v.Cost,
max = 10,
cmd = "buy" .. v.Name,
})
end[/CODE][/QUOTE]
Sweet, now it's almost working. Got a couple more errors, but I'm sure I can work these ones out myself.
[QUOTE=Zelpa;48794417]-post-[/QUOTE]
Since you wanted to understand rather than have your problem fixed, I'll explain rather than fixing your problem.
Tables are very simple, they contain a list of keys and values. The keys and values are paired, with every value there is a key and with every key there is a value. The fact they're paired would make you assume that whenever you look for something in the table you'd need to compare a key you're looking for with every key to get the paired value, but you don't because Lua uses hashtables. The implementation of hashtables is not important for you to know now, all you need to know is indexing (that is to search for a value in a table via index) is a very fast operation.
In Lua, the key and value can be ANYTHING and the keys and values can be different types inside the same table. You could have 3 string, a integer key and a player key if you wanted. In the example table you provided the key for both entries is a string and the value for both entries is another table (that has varying key and value types).
In Lua there are two syntaxs for indexing a table.
[lua]
-- get
local value = table[key]
-- set
table[key] = value
[/lua]
or
[lua]
-- get
local value = table.key
-- set
table.key = value
[/lua]
Another important thing to know is that with Lua tables you don't always tell Lua what key to use, in which case it will usually make one itself, here is an example:
[lua]
local table = {"a", "b", "c"}
[/lua]
In this example, Lua will automatically assign integer-one-based keys to each value. So that the key paired with "a" is 1, the key paired with "b" is 2 and so on. The inbuilt Lua function table.insert will also automatically assign an integer-one-based key to every value provided.
The last thing to know about tables is the "#" operator. You may have thought, or were told it returns the length of a table, but not really. It actually returns the highest integer key value. That's pretty much all there is to it. Since as Lua tables automatically assign keys when one is not provided and that they start at 1, the aforementioned method is fairly effective at finding the size of the table with no iteration required.
Finally for-loops.
There are three syntaxs to for-loops that I am aware of:
First (intergral):
[lua]
for i = 1, 10 do
-- code, ran 10 times, once for every time "i" is <= to 10
-- "i" is incremented each iteration
end
[/lua]
Second (integral):
[lua]
for i = 10, 0, -1
-- code ran 10 times, once for every time "i" is >= 0
-- "i" is decremented each time
end
[/lua]
Third (generic):
[lua]
for k, v in pairs({"a", "b", "c"}) do
-- code ran 3 times where k and v will represent key-value pairs in the table
-- first repetition: k = 1, v = "a"
-- second: k = 2, v = "b"
-- third: k = 3, v = "c"
end
[/lua]
The first and second loops are essentially the same. Lua will use the third paramter in the for loop as the "step", which can be any number and will continue incrementing/decrementing the
first paramter until it is less than or greater than (depending on whether step is negative or positive) the second parameter.
The third one is the simplest. Pairs is a function that returns a key and a value (one pair from the table), the function is referred to as an "iterator". Each time it is called it should return the next
pair inside the table until there are no more pairs. Pairs is not the only function you can use to get an iterator from a table. Another example is: [url=http://wiki.garrysmod.com/page/Global/SortedPairs]SortedPairs[/url] which will return an iterator that returns pairs in an ordered fashion. The normal pairs function does not promised to do that in any way.
I understand this is probably far more information than you wanted, but a lot of people have troubles with tables and iteration.
Hope someone finds this useful.
how can I do something when a swep is uninitialized aka when the player takes out a different gun/dies/drops it?
also, I want to change something in the primary attack but still do what the entity base does for the primary attack without changing the base.
one last thing, how do I get a sweps ammo count?
the gm13 wiki is either good at hiding this info from me or doesn't contain it and therefore frustrates me :(
[QUOTE=>>oubliette<<;48794834]lodsofwords[/QUOTE]
Wow, lots of writing. I read over it, and I think my main problem is that I didn't really understand what k and v are actually doing, I just kind of thought they were irrelevant :v: After implementing it this way I think I finally understand it.
I'm bad at math, so...
What would I do for a progress bar using FrameTime() if I wanted to give it a duration in [B]seconds[/B] and have it increase/decrease over that time? I don't know where to start.
FrameTime() is how long it took to render the frame (?), so for 60 fps, FrameTime() would be 1 / 60, and draw hooks would get called 60 times a second
that means you can just do var = var + FrameTime() / duration for it to take exactly duration seconds to reach 1
[QUOTE=PortalGod;48796713]FrameTime() is how long it took to render the frame (?), so for 60 fps, FrameTime() would be 1 / 60, and draw hooks would get called 60 times a second
that means you can just do var = var + duration * FrameTime() for it to take exactly duration seconds to reach 1[/QUOTE]
Oh, ok. I'll try that. Thank you yet again for your help.
EDIT:
What if the goal number is something other than 1? 200, perhaps
[QUOTE=Z0mb1n3;48796752]Oh, ok. I'll try that. Thank you yet again for your help.
EDIT:
What if the goal number is something other than 1? 200, perhaps[/QUOTE]
Multiply your increment by 200
Sorry, you need to Log In to post a reply to this thread.