• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=NeatNit;52890085]The [url=http://wiki.garrysmod.com/page/Category:debugoverlay]debugoverlay[/url] library can be used to draw stuff like this on the screen without having to fuck around with render hooks. It has no built-in cone shape, but you can approximate it with the existing shapes (box/triangles).[/QUOTE] [URL="https://github.com/Kefta/gs_lib/blob/master/lua/code_gs/lib/debugoverlay.lua#L209-L246"]These might also lend useful.[/URL]
Do files with the same names, in different addons conflict? I have two addons (non-workshop) in my "addons" folder. Each have a file in "autorun" called sh_init.lua. If they're the same name, only the first loaded addon gets called. I assume this issue is present in the workshop as well? Am I doing something wrong? Or do I need to take note about naming my autorun files, not to conflict with other addons?
Yeah, i had to change my weed config name to sh_weed_config.lua from sh_config.lua since it wouldn't load
[QUOTE=code_gs;52890119][URL="https://github.com/Kefta/gs_lib/blob/master/lua/code_gs/lib/debugoverlay.lua#L209-L246"]These might also lend useful.[/URL][/QUOTE] There is an issue I am having in debugoverlay.CircleAngles. attempt to call method 'Matrix' (a nil value)
[QUOTE=residualgrub;52891670]There is an issue I am having in debugoverlay.CircleAngles. attempt to call method 'Matrix' (a nil value)[/QUOTE] This method needs to be defined in the angle metatable: [url]https://github.com/Kefta/gs_lib/blob/master/lua/code_gs/lib/angle.lua#L60[/url]
(EDITED) - Previous issue fixed. Any ideas how I could make the axe rotate correctly around the gasoline can based on the cursors X and Y position? (Make it point out in the direction the cursor is at) The gas can is always in the middle of the screen. [IMG]https://i.imgur.com/xRwS4kD.png[/IMG]
What's "Rotate correctly" for you
[QUOTE=code_gs;52891692]This method needs to be defined in the angle metatable: [url]https://github.com/Kefta/gs_lib/blob/master/lua/code_gs/lib/angle.lua#L60[/url][/QUOTE] Totally my bad on that one. I was using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Angle/Forward]Angle:Forward[/url] and forgot that it returned a vector not an angle. But now I am getting this error [code][ERROR] addons/gs_lib-master/lua/code_gs/lib/debugoverlay.lua:222: attempt to perform arithmetic on field 'tau' (a nil value) 1. Circle - addons/gs_lib-master/lua/code_gs/lib/debugoverlay.lua:222 2. CircleAngles - addons/gs_lib-master/lua/code_gs/lib/debugoverlay.lua:214 3. unknown - addons/warchest_cas/lua/entities/wc_cas_si_suu66.lua:59 [/code] The line that is causing this error. [code]local flRadStep = math.tau / iSegments[/code] it looks like math.tau isn't defined in the math lua file and isn't stock so I am not sure what it is. Its the only instance of it in the entire library.
[QUOTE=residualgrub;52895518]Totally my bad on that one. I was using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Angle/Forward]Angle:Forward[/url] and forgot that it returned a vector not an angle. But now I am getting this error [code][ERROR] addons/gs_lib-master/lua/code_gs/lib/debugoverlay.lua:222: attempt to perform arithmetic on field 'tau' (a nil value) 1. Circle - addons/gs_lib-master/lua/code_gs/lib/debugoverlay.lua:222 2. CircleAngles - addons/gs_lib-master/lua/code_gs/lib/debugoverlay.lua:214 3. unknown - addons/warchest_cas/lua/entities/wc_cas_si_suu66.lua:59 [/code] The line that is causing this error. [code]local flRadStep = math.tau / iSegments[/code] it looks like math.tau isn't defined in the math lua file and isn't stock so I am not sure what it is. Its the only instance of it in the entire library.[/QUOTE] Change it to math.pi * 2 / iSegments, forgot the GitHub version isn't updated.
[QUOTE=gonzalolog;52894613]What's "Rotate correctly" for you[/QUOTE] To make the axe head always point to the direction the cursor is at. If you mean the way of rotating, It's supposed to have physics and not be able to go through objects.
[code]local bDmgInfo = DamageInfo() bDmgInfo:SetDamage(dmg) bDmgInfo:SetAttacker(self.Owner) bDmgInfo:SetInflictor(self) bDmgInfo:SetDamageType(DMG_DISSOLVE) bDmgInfo:SetDamageForce(aimVec*1000) bDmgInfo:SetMaxDamage(dmg)[/code] [code]util.BlastDamageInfo( bDmgInfo, tr.HitPos + tr.HitNormal, 96+8*self:GetChargeAmmo() )[/code] Is there a way to get a report on what entities get damaged by this, and how much damage each of them took?
Not really a lua question but oh well, installed a GMod dedicated server using SteamCMD, the server starts fine but when I try joining locally, it kind of gets stuck on Sending Client Info. I can press cancel and the game doesn't freeze. Just doesn't go past it. Anyone got any clue?
[QUOTE=Persious;52896698]Not really a lua question but oh well, installed a GMod dedicated server using SteamCMD, the server starts fine but when I try joining locally, it kind of gets stuck on Sending Client Info. I can press cancel and the game doesn't freeze. Just doesn't go past it. Anyone got any clue?[/QUOTE] Check your console and the server console, you could probably find some info there
[QUOTE=JasonMan34;52896705]Check your console and the server console, you could probably find some info there[/QUOTE] Forgot to mention that, can't seem to find anything on the console. Says that I connected and everything, and as soon as I cancel on Sending Client Info it says I disconnected.
[QUOTE=Persious;52896721]Forgot to mention that, can't seem to find anything on the console. Says that I connected and everything, and as soon as I cancel on Sending Client Info it says I disconnected.[/QUOTE] Is it only with your server? Are you connecting through the server menu or through IP address? What about your client console? Sometimes a bad addon could cause issues Could never hurt to paste it here
[QUOTE=JasonMan34;52896734]Is it only with your server? Are you connecting through the server menu or through IP address? What about your client console? Sometimes a bad addon could cause issues Could never hurt to paste it here[/QUOTE] Works fine with other servers, and I tried connecting through both. My client console also looks fine. I'll see which addons I have. Server [code] Console initialized. ConVarRef mat_dxlevel doesn't point to an existing ConVar Game.dll loaded for "Garry's Mod" Initializing Steam libraries for Workshop.. WS: No +host_workshop_collection or it is invalid! Changing gamemode to Trouble in Terrorist Town (terrortown) Network: IP 192.168.1.87, mode MP, dedicated Yes, ports 27015 SV / 27005 CL Error loading cfg/trusted_keys_base.txt Error loading cfg/pure_server_minimal.txt PREP OK Included TTT language file: chef.lua Included TTT language file: english.lua Included TTT language file: german.lua Included TTT language file: portuguese.lua Included TTT language file: russian.lua Included TTT language file: spanish.lua Included TTT language file: swedish.lua Included TTT language file: tradchinese.lua Trouble In Terrorist Town gamemode initializing... This is TTT version 2017-04-20 Executing dedicated server config file server.cfg Using map cycle file cfg/mapcycle.txt. Nav File is wrong or something (4) Initializing Steam libraries for secure Internet server No account token specified; logging into anonymous game server account. (Use sv_setsteamaccount to login to a persistent account.) Unknown command "logging" Unknown command "sbox_allownpcs" Unknown command "sbox_plpldamage" Unknown command "sbox_playergod" Unknown command "sbox_maxspawners" Unknown command "sbox_maxturrets" 'banned_ip.cfg' not present; not executing. 'banned_user.cfg' not present; not executing. Connection to Steam servers successful. Public IP is not needed for this. Assigned anonymous gameserver Steam ID [A-1:3159713800(9305)]. VAC secure mode is activated. [/code] Client [code] Connecting to 192.168.1.87:27015... Connected to 192.168.1.87:27015 Trouble in Terrorist Town Map: gm_flatgrass Players: 1 / 16 Build: 6948 Server Number: 1 TTT Dev terrortown gm_flatgrass 16 76561198005281129 Requesting 150 lua files from the server PREP OK [/code]
[QUOTE=DarkDragonLov;52896570]Click my name at the top of this 'quote' to view my first question. I didn't want to re-ask it.[/QUOTE] And second question... I don't want to use autorun scripts, or my own gamemode, to scale the damage my SWEP does to its owner. Is it an [b]ok[/b] idea to hook [b]GM:ScalePlayerDamage[/b] or [b]GM:EntityTakeDamage[/b] in a SWEP?
[QUOTE=DarkDragonLov;52897320]And second question... I don't want to use autorun scripts, or my own gamemode, to scale the damage my SWEP does to its owner. Is it an [b]ok[/b] idea to hook [b]GM:ScalePlayerDamage[/b] or [b]GM:EntityTakeDamage[/b] in a SWEP?[/QUOTE] Yes
Lua logic question: Trying to find a matching value from a table to a string and print that result. So far I have: [CODE] local RankList = {} RankList[1] = "Recruit" RankList[2] = "Private" RankList[3] = "Corporal" RankList[4] = "Sergeant" RankList[5] = "Lieutenant" RankList[6] = "Captain" RankList[7] = "Commander" local targetName = ply:Name() --Let's pretend this returns "Recruit Bob" for k, v in ipairs(RankList) do local getRank = string.match(targetName, v, 1) print(getRank) end [/CODE] This prints: [CODE] Recruit nil nil nil nil nil nil [/CODE] I just want it to print "Recruit" without the nil's. Anyone know how to do that?
[QUOTE=pilot;52897518]Lua logic question: Trying to find a matching value from a table to a string and print that result. So far I have: :snip: I just want it to print "Recruit" without the nil's. Anyone know how to do that?[/QUOTE] [code] for k, v in ipairs(RankList) do if string.match(targetName, v) then print(v) break end end [/code] Edit: To explain, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/match]string.match[/url] returns the match it found or nil if it couldn't find one. Because we're using a straight string search it'll return `v` as that's what we're searching for. Also [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/find]string.find[/url] is probably better suited for this case as you're not searching for a pattern.
I guess cus new page I'll [URL="https://facepunch.com/showthread.php?t=1548067&p=52896570&viewfull=1#post52896570"]ask again[/URL], rephrased. I want a list or table of entities that are harmed by a util.BlastDamageInfo Is there a way to get this? Is there a way to get how much damage each of those entities took?
[QUOTE=DarkDragonLov;52898880]I guess cus new page I'll [URL="https://facepunch.com/showthread.php?t=1548067&p=52896570&viewfull=1#post52896570"]ask again[/URL], rephrased. I want a list or table of entities that are harmed by a util.BlastDamageInfo Is there a way to get this? Is there a way to get how much damage each of those entities took?[/QUOTE] I don't think so, you would just have to add them all through various hook calls.
[QUOTE=DarkDragonLov;52898880]I guess cus new page I'll [URL="https://facepunch.com/showthread.php?t=1548067&p=52896570&viewfull=1#post52896570"]ask again[/URL], rephrased. I want a list or table of entities that are harmed by a util.BlastDamageInfo Is there a way to get this? Is there a way to get how much damage each of those entities took?[/QUOTE] here's how i'd approach this: 1. Generate a unique id for your blast, math.random() or something. 2. Before you create the blast use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] with the same position and radius as your explosion, this is the entities that may be hit. Store the table someplace you can access it, probably a global table of blasts... Then run through the ents in the table from ents.FindInSphere and add the values .blastID and .blastTime to each entity. Set .blastID to the unique id, and set .blastTime to CurTime() 3. Do the util.BlastDamageInfo 4. Then in the hook [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM:EntityTakeDamage[/url] you'll check each incoming target for a blastID and check if that blast table exists, if it does then make sure the blast isn't too old, if CurTime() > .blastTime + 1( or whatever number/fraction of seconds) then it's too old. If all is well then check the damageType, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CTakeDamageInfo/IsDamageType]CTakeDamageInfo:IsDamageType[/url] to check if it's a blast damageInfo:IsDamageType(DMG_BLAST ). If it is then add it to another table table, delete it from the global blast table, add up all blast damage (for that blastID), or do whatever with it now that it's been identified as an entity in that blast, all damage info is on the damageInfo, object, damage, pos, type, inflictor, attacker, etc. I don't know if this is the best way, It's just how I'd approach it. Hope this helps.
:snip: maybe should refresh the page before replying to day old posts.
I'm trying to spawn/dispatch effect from server, but it doesnt work (it works from client):[code]local edata = EffectData() edata:SetOrigin(pos) edata:SetScale(32) edata:SetEntity(ent) util.Effect("custom_effect12", edata, true, true)[/code] Btw, can I render entity which is parented to the effect in its render hook? I don't understand how to work with render :frown:
[QUOTE=LoweChaser;52903577]I'm trying to spawn/dispatch effect from server, but it doesnt work (it works from client):[code]local edata = EffectData() edata:SetOrigin(pos) edata:SetScale(32) edata:SetEntity(ent) util.Effect("custom_effect12", edata, true, true)[/code] Btw, can I render entity which is parented to the effect in its render hook? I don't understand how to work with render :frown:[/QUOTE] It's my understanding util.Effect only calls clientside... but I am [B]FAR[/B] from a pro. Thing is, I think if you're calling it serverside but NOT clientside then it won't show up. Oh. This also depends on what custom_effect12 is. Assuming it is a 'custom' effect, it would help to see the code for the effect.
What would be the best way to network a gigantic table formatted like so: [code]{ -- int = any number [int] = { int, int, int, int, } [int] = { int, int, int, int, int, int, int, int, }, [int] = { int, int, int, }, } [/code] The actual table would have well over 5000 values. At the moment I'm converting the table to a string with util.TableToJSON, compressing it with util.Compress, then sending it to the server in chunks.
[QUOTE=DarkDragonLov;52905293]It's my understanding util.Effect only calls clientside... but I am [B]FAR[/B] from a pro. Thing is, I think if you're calling it serverside but NOT clientside then it won't show up. Oh. This also depends on what custom_effect12 is. Assuming it is a 'custom' effect, it would help to see the code for the effect.[/QUOTE]Effect works when I spawn it on client, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/Effect]util.Effect[/url] says that I can network (my understanding, I'm not really good in english) an effect from server and it doesn't work
You probably could serialize this data manually into a string more efficiently than util.TableToJSON could ever hope to. Or you could just send the raw data in chunks like so:(or construct a string with such structure instead of using JSON) write number of sub-tables for number of sub-tables read: ---write id of sub-table ---write number of sub entires ---for number of sub entries, read: ------read int --probably some bit/byte for start-end of the series of messages I don't know which will be more efficient in terms of bytes transferred. You will also need to measure how much tables can fit into a single net.Send for the second method. [editline]19th November 2017[/editline] [QUOTE=txike;52905881]What would be the best way to network a gigantic table formatted like so: [code]{ -- int = any number [int] = { int, int, int, int, } [int] = { int, int, int, int, int, int, int, int, }, [int] = { int, int, int, }, } [/code] The actual table would have well over 5000 values. At the moment I'm converting the table to a string with util.TableToJSON, compressing it with util.Compress, then sending it to the server in chunks.[/QUOTE]
Uh. So...I want to make physically simulated particles without creating a .pcf file. In other words, I want to script an effect in Lua that features falling and bouncing particles, but I have no clue how to do this without writing my own fake physics simulation... Is there an easier way to simulate particle physics in Lua effects?
Sorry, you need to Log In to post a reply to this thread.