• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
I've set up a method for rendering character portraits to png and then reading them based on steamid64. The only problem is, on the right side, i'm rendering it every frame in the configuration i want, and i'm doing the exact same on the left for the frame that it's being generated. For some reason it won't render anything onto it https://files.facepunch.com/forum/upload/241600/8eea315d-53c3-4db0-a631-4f8fa44be3ad/ass.JPG [code]local oldW, oldH = ScrW(), ScrH() local oldRT = render.GetRenderTarget()   //s64 is a steamID64 local rt = GetRenderTarget( "11"..s64, 128, 128, false )  render.SetRenderTarget( rt ) render.SetViewPort( 0,0,128,128 )    render.ClearDepth()  render.Clear( 0, 0, 0, 1,true )    surface.SetDrawColor(Color(255,255,255,255))  render.SetColorModulation(1,1,1)  render.SetBlend(1)   cam.Start3D(Vector(30,0,68),Angle(0,180,0),30,128,0,128,128)  render.SuppressEngineLighting(true) local mst = {model=LocalPlayer():GetModel(),pos=Vector(),angle=Angle()}  render.Model( mst )   render.SuppressEngineLighting(false) cam.End3D() local data = render.Capture( { format = "png", quality = 100,  h = 128,  w = 128,  x = 0, y = 0, alpha=true, } )   render.SetRenderTarget( oldRT )  render.SetViewPort( 0, 0, oldW, oldH ) //file write stuff goes after here[/code]
So I have a table of entities. I want it so if an entity gets removed, it will also get removed from the table completely - I was wondering if it's good practice/enough to do table[ent] = ent, in the case that I don't care about the key itself
You could remove it from the table on GM/EntityRemoved, something easier you could try is weak tables (Lua 5.1 Reference Manual).
Not really an issue, but is there anyway for tables to act similarly to strings when it comes to meta methods? For example, the function [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/len]string.len[/url] can be written as a function-argument: print( string.len( "TEST_STRING" ) ) and it can also be written as a metamethod ex: print( "TEST_STRING":len() ) With table functions such as [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/Count]table.Count[/url], they can only be written as a function-argument ex: print( table.Count( {} ) ) Doing something like local t = {} print( t:Count() ) will always get "attempt to call method xxxxx" I can get the actual meta table with getmetatable( "ANY_STRING_HERE" ) However, with tables this always returns nil. I'm honestly just curious why strings have this but tables don't :@
Because strings have a metatable that points to the string library, and plain tables do not unless you give them one. You can mimic the functionality like this. local t = setmetatable({}, {__index = table}) t:insert(true) print(t:Count())
What should I put in my custom chatbox code to get Player:IsTyping() function working properly?
I was trying to print the value of a specific math_counter called "TestEnt" to the chat, but nothing is printed. The entity is the only one labeled TestEnt and the chat printing works, as it only prints nothing when I try to print the current value of it. Here is the code: function tget() for k, v in pairs(ents.GetAll()) do if v:GetName() == "TestEnt" then BroadcastMsg(Color(255,0,0),v.value) end end end timer.Create("testget", 10, 0, tget)
sorry for taking so long to respond, after trying v:GetKeyValues().value I still get nothing being outputted.
Is it possible to create a larger Marlett (the Windows symbol font)? Or for that matter, use any symbolic font other than Wingdings? This is what I first tried, but it seems setting symbol to true just makes the font Wingdings. surface.CreateFont( "Marlett25",     {         font = "Marlett",         size = 25,         weight = 0,         symbol = true     } ) Without symbol (or explicitly setting it to false) the font appears to be just a default font, probably Arial.
sadly that did not work either
how would I go about checking if the math_counter has changed?
I'm 100% sure you have (some of) the calculations wrong. Through testing I can definitely say your DistFromVel function does not return the correct distance. With gravity set to 600, dropping from a height of 100 units my final velocity was 441 and dropping from a height of 200 units my final velocity was 558 (as reported by the GM/OnPlayerHitGround hook). Your function gave me 162.0675 and 259.47 for those velocities. Your VelFromDmg function seems to work fine, so if you just figure out the correct formula for getting from final velocity to distance you should be good to go. I tried messing around with the numbers, but I've lost my grasp on physics so I didn't get very far.
Anyone know how I'd go about creating animated particles like those fire ones at the 0:20 mark? https://www.youtube.com/watch?v=SOZA89frZqQ
maybe ParticleEffectAttach or ParticleEffect
This might be what I wanted, but please correct me if I'm wrong: do these particle effects create the entire flame (composed of several particles) rather than individual particles? Because I want to have control over every individual particle, like the ones available from ParticleEmitter's. I need a way to change their material after spawning them.
As far as I know, you cannot control engine particles. If you would want that you will need to indeed setup a ParticleEmitter
Trying to wrap my head around how to calculate the light-angle on the moon, from 3 variables https://files.facepunch.com/forum/upload/107119/8f8f756d-e7e5-4c0f-94c7-ea405da01311/image.png The 3 varables are; moon_angle, sun_angle and moon_to_sun_angle. The problem lies with it being 3D-space and I need the roll between the two positions, relative to the moon angle.
You'll probably want to fuck around with vector:Dot(). This might also help: http://wiki.garrysmod.com/page/Trigonometry At any rate you should try to remember that the moon is definitely closer to Earth than the sun is so you can't really see it if it's anywhere near the sun. "Because of the Earth's rotation, the moon is above the horizon roughly 12 hours out of every 24. Since those 12 hours almost never coincide with the roughly 12 hours of daylight in every 24 hours, the possible window for observing the moon in daylight averages about 6 hours a day." And when they're close to one another the moon stops reflecting anything. The only way you could see them be close to each other is due to an eclipse. Also the moon is pretty fucking tiny in the sky in real life. For some reason the moon is always huge in video games...
Trying to make a TTT addon. Would like to allow users/server owners to be able to translate my addon using their language file. However, seems that calling LANG.AddToLanguage() outside of scripts/addons running inside of gamemodes/terrortown/gamemode does not work (LANG is undefined). My addons is not a weapon or entity, so I can't put it in gamemodes/terrortown/gamemode/weapons or entities. Any other ideas?
The issue is probably that it just isn't defined *yet*. Try using LANG.AddToLanguage() in an Initialize or InitPostEntity hook
Thanks that seems to have fixed it!
I love how I accidently bumped a 9 month old thread and people are still using it
This is a megathread that people have been actively using for a long time...
This is v5, there is a v6
[ERROR] gamemodes/zombiesurvival/entities/weapons/weapon_zs_base/shared.lua:194: attempt to index a nil value   1. unknown - gamemodes/zombiesurvival/entities/weapons/weapon_zs_base/shared.lua:194 I'm trying to play a voice line on reload. it works just fine in singleplayer but on my server I get this error every reload function SWEP:Reload() if self.Owner:IsHolding() then return end if self:GetIronsights() then self:SetIronsights(false) end if self:GetNextReload() <= CurTime() and self:DefaultReload(ACT_VM_RELOAD) then self.IdleAnimation = CurTime() + self:SequenceDuration() self:SetNextReload(self.IdleAnimation) self.Owner:DoReloadEvent() if self.ReloadSound then self:EmitSound(self.ReloadSound) if (VoiceSets[self.Owner.VoiceSet].ReloadSounds) then local rlsnd = VoiceSets[self.Owner.VoiceSet].ReloadSounds if rlsnd then local nig = self timer.Simple(0.2, function () if IsValid(nig) then self:EmitSound(rlsnd[math.random(1, #rlsnd)]) end end) end end end end end
oops, edited and commented line 194 The VoiceSet table is defined in shared.lua right before SWEP:Initialize. Also for some reason it only plays for certain weapons but I'm assuming this has to do with the fact that some weapons like shotguns use other animations in ZS alongside ACT_VM_RELOAD
How does ents.FindInBox work internally? Does it iterate over all entities and calculates distance? I need to obtain all entities around my SENT in its ENT:Draw() hook and want to keep it optimized.
It iterates over groups of points (entities) using a spacial partition tree. It's relatively quick, but if you're calling it in a Draw hook, I would benchmark it and look into caching.
Is there anyway to get cam.Start3D2D to work with cam.PushModelMatrix? When I push a matrix the origin, scale, and angles all become based on the world. I'm guessing it replaces the cam.Start3D2D model matrix. I can setup the matrix with the same conditions as cam.Start3D2D, and it'll work out the same (with some adjusting), though it feels like a bit of a hack. I'm using cam.PushModelMatrix to rotate some text, so if there's another option I'd be open ears.
Is there a way to refresh a client's menu without having to reload it? For example, if I have a server-side table that consists of X information, and that information is updated every minute, can I change that information on the client's information display (F4 in my gamemode), without them having to be forced to close and reopen? Server: Table has 5 items. 30 seconds later, a player updates it by adding 2 more items for 7 total. Client: Table still has 5 items from the time player opened the window. Server: Sends all clients a notification that the table was updated. Client: Receives update and updates the F4 window automatically. As for right now, Client step #2 is "Client: Window gets closed and automatically reopens" in order for this to work.
Sorry, you need to Log In to post a reply to this thread.