• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
I have a table named sosk_songs and the structure is: [CODE] { G6GIdGhxyHw: { length = 353 title = Feed Me - Blood Red suggestion = 0 } } [/CODE] I'm trying to use table.SortByMember(sosk_songs, "title", true) to sort it alphabetically by title, however, it isn't working. I'm sure it's obvious to someone else but to me I can't figure out why it won't sort. Is it because of the key? EDIT: Never mind, got it. Realized I changed keys to strings from numbers, which is why SortByMember doesn't work, and found SortedPairsByMemberValue() which is for keys that are strings. EDIT2: However I cannot sort the table to keep the key a string and actually have it sort. *wrist* I basically need to sort a table out who's keys are strings, by it's members. So song = { [id] = { title = herp derp } which SortedPairsByMemberValue works, but I'm not sure how to insert the key + data to a table.
[QUOTE=WitheredPyre;46837569]My game has a tendency to randomly crash while playing on TTT. I'm not sure if this is related to the server I'm playing on or the gamemode in general, and it seems to have no specific cause; it can happen during a round or when it ends. Whenever. Notably, it only sometimes drops an mdmp, and I don't even know if it's related. You can find the info from the mdmp [URL="http://dumps.metastruct.uk.to/dumper.py?dump=hl2_140713_crash_2014_12_31T21_16_41C0.mdmp"]here[/URL]. Even more notably, when I join the server I crashed on again, it takes a particularly long time to join for no good reason. I'm not sure if there's a way to avoid this or if it occurs when joining another server instead. I've already tried verifying my files, disabling all addons, nuking my lua folder, removing terrortown and letting it redownload, etc. Nothing fixed it. My next try is to disable some games and try joining with the bare minimum (HL2, CS:S).[/QUOTE] Still looking for a solution to this.
[QUOTE=WitheredPyre;46851499]Still looking for a solution to this.[/QUOTE] Caused by ragdolls. [url]https://github.com/Kefta/Ragdoll-Remover[/url] Throw that in your addons and it should reduce the amount of crashes greatly, at least it did for me. :)
Something rotates 30 degrees... out of my control. The normalized angle yaw was 160, now it's -170. How could I fetch 30 from that?
-snip- misread the question.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/math/AngleDifference]math.AngleDifference[/url]
Is EntityFireBullets a shared function or server only and the wiki is incorrect? I cannot seem to get any output from it on my client script.
[QUOTE=Ylsid;46852719]Is EntityFireBullets a shared function or server only and the wiki is incorrect? I cannot seem to get any output from it on my client script.[/QUOTE] It's shared. Don't code in singleplayer.
[QUOTE=serfma;46851532]Caused by ragdolls. [url]https://github.com/Kefta/Ragdoll-Remover[/url] Throw that in your addons and it should reduce the amount of crashes greatly, at least it did for me. :)[/QUOTE] This crash only occurs clientside to me and no one else on the server crashes. It's not even my server.
How do I get Absolute Position of the Panel?
[QUOTE=Acecool;46848073]So the error happens on SWEPs? HL2 weapons are normal without errors ( which is to be expected except some functions don't exist in their space )? Show us this sh_anim.lua file and shared if you can, or at least a few lines before, the line causing the issue and a few lines after. self.Owner may be getting overwritten, or something else may be happening.[/QUOTE] Don't have the file, it's M9K.
[QUOTE=rebel1324;46854169]How do I get Absolute Position of the Panel?[/QUOTE] panel:GetBounds( ) returns x, y, w and h IIRC
When creating a clientside c++ module, how would I go about receiving data about the client like steamid for example? The module is loaded using require.
I am using slightly modified code that I use to move my player's arm to manage bullet direction but it doesn't seem to work. My bullets fly off in incorrect directions and my attempts at tweaking the code by inversing variables and using the arm rotation have not been successful. 2d games are quite an adventure... [code] local bullet = createBullet( x + objects.Player:GetWide(), y ) local mX, mY = gPhone.phoneScreen:ScreenToLocal( gui.MouseX(), gui.MouseY() ) local shootAngle = math.atan2((mY - y), (mX - x)) shootAngle = math.deg( math.Clamp(shootAngle, -90, 90) ) --shootAngle = objects.PlayerArm.Rotation -- The bullet needs proper velocity for its trajectory bullet.VelocityX = math.cos(shootAngle) * 5 bullet.VelocityY = math.sin(shootAngle) * 5 --bullet.Rotation = shootAngle print("Angle", shootAngle, "Velocity X and Y", bullet.VelocityX, bullet.VelocityY) [/code] [quote] Angle 47.920721521 Velocity X and Y -3.4948799788437 -3.5757256513158 Angle 40.643024994154 Velocity X and Y -4.9026247521248 0.98197277958863 Angle 34.215702132437 Velocity X and Y -4.7107357222273 1.6759978983674 Angle 24.928474135461 Velocity X and Y 4.8960495864893 -1.0142477244922 Angle 16.837472625676 Velocity X and Y -2.1355174970471 -4.5210137159497 Angle 10.684912400003 Velocity X and Y -1.5284445365972 -4.7606572338855 Angle -1.029154804306 Velocity X and Y 2.5777162320797 -4.2843178018061 Angle -5.7781190691267 Velocity X and Y 4.3757121302174 2.4193270455787 Angle -11.63363399894 Velocity X and Y 2.978190104641 4.0162648942293 Angle -17.525568373723 Velocity X and Y 1.2215534552425 4.8484850372034 Angle -22.671343621981 Velocity X and Y -3.8872502993046 3.1447233758403 Angle -29.019082851605 Velocity X and Y -3.6762903547925 3.3889362973151 Angle -37.030389605679 Velocity X and Y 3.9230724923559 3.0999197118185 Angle -46.287328941525 Velocity X and Y -3.3500990187161 -3.7117161212568 Angle -55.175510843043 Velocity X and Y 0.98177619682405 4.9026641226327 [/quote]
What are x and y? The position of the gun barrel? Also, I think you have your points backwards, since the "aim the way the mouse is facing" code I've used is like this: [code]x, y = gui.MousePos( ) v, w = ScrW( ) * .5, ScrH( ) * .5 ang.y = math.deg( math.atan2( v - x, w - y ) )[/code]
[QUOTE=Exho;46855598][/QUOTE] [LUA] local angle = math.atan2( mouse.y - start.y, mouse.x - start.x ) local speed = 200 bullet.direction = { x = math.cos( angle ) * speed, y = math.sin( angle ) * speed } -- then somewhere else local dt = FrameTime() bullet.pos.x = bullet.pos.x + (bullet.direction.x * dt) bullet.pos.y = bullet.pos.y + (bullet.direction.y * dt) [/LUA] eg [t]http://i.imgur.com/2QUmogs.png[/t]
I needed to use radians instead of converting it to degrees like I did with the arm rotation...
How can I randomize a value in the table but get the index of the value. here's the table [code] local Crops = {} Crops["Cabbage"] = "models/weapons/w_bugbait.mdl" Crops["Red Cabbage"] = "other model here" [/code] for instance I use [code] local randName = table.Random(Crops) [/code] and the output is "models/weapons/w_bugbait.mdl" but now i want to get the index of that random value
[lua]local randName, randKey = table.Random(Crops) print(randKey, randName) Output: Cabbage models/weapons/w_bugbait.mdl[/lua]
[del]Is it possible to check if the player is dancing client sided? I tried checking player sequence and DoAnimationEvent hook, but neither return info about it. EDIT: I'm talking about "act dance" in console. ACT_GMOD_TAUNT_DANCE[/del] Nevermind, turns out DoAnimationEvent works enough that I can do what I need to.
[QUOTE=_Entity;46856695]How can I randomize a value in the table but get the index of the value. here's the table [code] local Crops = {} Crops["Cabbage"] = "models/weapons/w_bugbait.mdl" Crops["Red Cabbage"] = "other model here" [/code] for instance I use [code] local randName = table.Random(Crops) [/code] and the output is "models/weapons/w_bugbait.mdl" but now i want to get the index of that random value[/QUOTE] index your table numerically , use math.Random() as your randValue and setup some enums I.E. _CABBAGE = 1 etc etc oh wow, I'm late. [sp]I didn't know table.Random returned the key as well[/sp] :suicide:
How can I listen for key presses while a player is in a vehicle? Near as I can tell only ShowSpare and similar have any effect when pressed. If I manually type "impulse 100" in console, the flashlight impulse is sent, but pressing F (which is bound to "impulse 100") does nothing. Can I only use those few F# keys in vehicles?
[QUOTE=Willox;46852366][IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/math/AngleDifference"]math.AngleDifference[/URL][/QUOTE] According to the examples on that one, it looks like to me it just subtracts one from the other... so 160 and -170 would give me 330. Because of that, I didn't think it would work, so I came here to ask... [editline]4th January 2015[/editline] Angle difference between 159 and 240 is -81 Angle difference between 240 and 159 is 81 Angle difference between 58 and 145 is -87 159 - 240 = -81 240 - 159 = 81 58 - 145 = -87 None of those display wrapping around? In that case, what will 355 and 5 return? I would assume 350. <snip> wouldn't work [editline]4th January 2015[/editline] Maybe someone would want to get 340 from 350 -> 10, rather than 20. That's what I think Angle Difference would do
[QUOTE=WalkingZombie;46857872]According to the examples on that one, it looks like to me it just subtracts one from the other... so 160 and -170 would give me 330. Because of that, I didn't think it would work, so I came here to ask... [editline]4th January 2015[/editline] Angle difference between 159 and 240 is -81 Angle difference between 240 and 159 is 81 Angle difference between 58 and 145 is -87 159 - 240 = -81 240 - 159 = 81 58 - 145 = -87 None of those display wrapping around? In that case, what will 355 and 5 return? I would assume 350. <snip> wouldn't work[/QUOTE] [url]https://github.com/garrynewman/garrysmod/blob/2197a37d2170a36844eeffb475e846521ba2da71/garrysmod/lua/includes/extensions/math.lua#L231-L241[/url]
[QUOTE=Willox;46857947][URL]https://github.com/garrynewman/garrysmod/blob/2197a37d2170a36844eeffb475e846521ba2da71/garrysmod/lua/includes/extensions/math.lua#L231-L241[/URL][/QUOTE] Ok, thank you, that answers it!
How does syntax highlighting in a derma text box work? ( for example, in Luapad )
There was a Lua writing DElement, but it was removed from the game. Unfortunately the code isn't really that helpful [url]http://bluekirbygmod.googlecode.com/svn/trunk/gmod-dl/lua/vgui/dluaeditor.lua[/url]
Anyone know how to change an NPC's class? I have two versions of an NPC with different weaponry, but one always overlaps the other. Not much of a coder so I don't know how to change it without it saying "cannon find (npc_example)" I've been searching for days and can't figure this out. :/
A class is just a file name
So just reanme the file in "lua" from npc_example to npc_example2 ? And change the class names in the code to match the new filename?
Sorry, you need to Log In to post a reply to this thread.