• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=ROFLBURGER;46402306]Any way to grab a [URL="http://wiki.garrysmod.com/page/Enums/MAT"]Material type[/URL] without using trace result?[/QUOTE] Grab from what? You could do some trickery if you know the surfaceprop. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/scripts/surfaceproperties.txt[/url]
[QUOTE=ROFLBURGER;46402306]Any way to grab a [URL="http://wiki.garrysmod.com/page/Enums/MAT"]Material type[/URL] without using trace result?[/QUOTE] I'm pretty sure I asked that around GM13 release when Garry still worked on Gmod, and it wasn't really possible and I don't think a function has been added since
How would I go about getting the info associated with a variable from a different lua file? For example, lets say I have a lua file somewhere that states that (variable) PWVersionFormat = "1.0.1". Now lets say I have a custom console command that's meant to print the version number. Would I just do within the command- [code]function GM:PrintFCGamVers( ply ) print(PWVersionFormat) end[/code] Or would I specifically have to go get the variable's data and "bring" it to the function's file? This would all be within a gamemode. Sorry if the question is confusing. edit: Incase I didn't mention it- The variable and function are in different lua files.
[code] GM.MyAddon = {} GM.MyAddon.AddonVersion = "1.01" [/code] Then just do GAMEMODE.MyAddon.AddonVersion in any lua file.
[QUOTE=Robotboy655;46402413]Grab from what? You could do some trickery if you know the surfaceprop. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/scripts/surfaceproperties.txt[/url][/QUOTE] Basically I was trying to get the surface material from a prop so I could calculate how strong the prop is for a prop damage system
[QUOTE=ROFLBURGER;46402856]Basically I was trying to get the surface material from a prop so I could calculate how strong the prop is for a prop damage system[/QUOTE] Isn't there a mass thing for ents? If mass isn't automatically defined then you may have to do some hard coding. (Probably table with index as model and val as mass then for loop ents in postentity and set their mass equal to tbl[model], same for entity created)
[QUOTE=AnonTakesOver;46402915]Isn't there a mass thing for ents? If mass isn't automatically defined then you may have to do some hard coding. (Probably table with index as model and val as mass then for loop ents in postentity and set their mass equal to tbl[model], same for entity created)[/QUOTE] I'm including mass in the equation too Mass, Volume, Material type.
[QUOTE=ROFLBURGER;46403523]I'm including mass in the equation too Mass, Volume, Material type.[/QUOTE] The material type isn't important for what you're trying to do, look at the density. Divide the mass by the bounding volume and scale the damage based off that. ex1: cinder block -> low obb, high mass -> big / small -> overall big ex2: big picture -> big obb, low mass -> low / big -> overall small
[QUOTE=zzaacckk;46404290]The material type isn't important for what you're trying to do, look at the density. Divide the mass by the bounding volume and scale the damage based off that. ex1: cinder block -> low obb, high mass -> big / small -> overall big ex2: big picture -> big obb, low mass -> low / big -> overall small[/QUOTE] Speaking of this, are there any functions to get the volume or even the surface area of a model/VPhysics object? EDIT: NVM, I am retarded. [url]http://wiki.garrysmod.com/page/PhysObj/GetVolume[/url] [url]http://wiki.garrysmod.com/page/PhysObj/GetSurfaceArea[/url]
[QUOTE=zzaacckk;46404290]The material type isn't important for what you're trying to do, look at the density. Divide the mass by the bounding volume and scale the damage based off that. ex1: cinder block -> low obb, high mass -> big / small -> overall big ex2: big picture -> big obb, low mass -> low / big -> overall small[/QUOTE] Can't really divide do mass/volume because for example different sizes of a phx plastic prop return the same health when it should be different. So I used local maxhealth = (mass*volume) / 500 [editline]3rd November 2014[/editline] I am thinking of changing it to local maxhealth = (mass/volume) * surfacearea * 10
How do I go about properly offsetting in 3D2D. The code I've got at the moment works fine until the entity is rotated: [t]http://puu.sh/cCU3o/d3945bfae6.jpg[/t] [code] cam.Start3D2D( self:GetPos() + Vector( 15.5, 0, 22 ), self:GetAngles() + Angle( 0, 90, 90 ), 0.5 ) draw.RoundedBox( 0, -38, 4, 80, 20, Color( 0, 0, 0, 255) ) draw.DrawText("Bus Tickets", "ticketMachine", 0, 5, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER ) draw.RoundedBox( 0, -38, -143, 80, 20, Color( 0, 0, 0, 255) ) draw.DrawText("$150 All Day", "ticketMachine", 0, -142, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER ) cam.End3D2D() [/code] I feel rather than hardcoded values I should be using relative position or something?
Use Entity:LocalToWorld(Vector( 15.5, 0, 22 )) instead of self:GetPos() + Vector( 15.5, 0, 22 )
Just bought a new game server for a little reunion of my old community. In TTT, I edited the knife's damage so it would be insta-kill, the changes are saved and the knife is insta-kill, however on map change or server reset the knife is back to being 50 damage, even though the lua file has the damage at 200.. Any help is appreciated :)
My mapvote prevents the round from starting on TTT. It stops any round from starting... This round start code is by Tyrantelf [code] if cfg.CurrentGamemode == "TTT" then function CheckForMapSwitch() -- Check for mapswitch local rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6) - 1) SetGlobalInt("ttt_rounds_left", rounds_left) local time_left = math.max(0, (GetConVar("ttt_time_limit_minutes"):GetInt() * 60) - CurTime()) local switchmap = false local nextmap = string.upper(game.GetMapNext()) if rounds_left <= 0 then LANG.Msg("limit_round", {mapname = nextmap}) switchmap = true elseif time_left <= 0 then LANG.Msg("limit_time", {mapname = nextmap}) switchmap = true end if switchmap then timer.Stop("end2prep") MapVote.StartVote() end end end [/code]
So I guess I broke math? [code]TEST [lua/includes/modules/json.lua][lua/includes/modules/hook.lua] [ERROR] lua/includes/extensions/math.lua:56: attempt to perform arithmetic on local 'high' (a nil value) 1. Rand - lua/includes/extensions/math.lua:56 2. v - addons/fin2/lua/autorun/server/sv_fin.lua:25 3. unknown - lua/includes/modules/hook.lua:84 [/code] Note: This just started randomly when ever I launch I gamemode that I've been working on. Not even sure why seeing as it wasn't doing this the last time I shut down GMOD and I haven't touched anything else since. Also, I didn't put this in regular gmod issues b/c it only happens when I launch my gamemode. Edit: Just took a glance. Looks like fin is being stupid or something...?
in sv_fin.lua line 25 is passing a nil parameter to a math function
Is there a way to achieve what is usually achieved with * as in, npc_* is equivalent to any entity that starts with npc_ such as npc_combine_s or npc_headcrab etc? I believe that's called a wild card symbol?
[QUOTE=WalkingZombie;46410968]Is there a way to achieve what is usually achieved with * as in, npc_* is equivalent to any entity that starts with npc_ such as npc_combine_s or npc_headcrab etc? I believe that's called a wild card symbol?[/QUOTE] [CODE]ents.FindByClass("npc_*")[/CODE]
[QUOTE=WalkingZombie;46410968]Is there a way to achieve what is usually achieved with * as in, npc_* is equivalent to any entity that starts with npc_ such as npc_combine_s or npc_headcrab etc? I believe that's called a wild card symbol?[/QUOTE] [QUOTE=_FR_Starfox64;46411042][CODE]ents.FindByClass("npc_*")[/CODE][/QUOTE] If you want to do it manually (string matching) then the character to use is [B].[/B] . means any characters, and * means appearing 0 or more times. So you replace * with .* Example: [URL="http://ideone.com/f1mclE"]http://ideone.com/f1mclE[/URL] Shortened version: [lua]local function MatchStrings(SearchTerm,MatchAgainst) SearchTerm = SearchTerm:gsub("*",".*") SearchTerm = "^"..SearchTerm.."$" local Result = MatchAgainst:match(SearchTerm) return Result and Result==MatchAgainst end print( MatchStrings("npc_*","npc_zombie" ) ) --true[/lua]
[del]Not what I wanted to do?[/del] Ok, so instead of doing "npc_*" == "npc_zombie" I would use string.match then? [editline]4th November 2014[/editline] instead of doing "bollocks_*" == "bollocks_grande" I would use string.match?
string.StartWith also works
awesome. thanks, but I recently ran into another problem trying to fix some laggy code... My halos, with this code, they draw perfectly when they're drawn in the Think function. When I run them like this, they don't render at all: [lua]function DrawHalo() local Fluxor = math.tan(CurTime()*8) if Fluxor > 2 then Fluxor = 0 end local Flux = .5*Fluxor Flux = math.max(0.1, math.Clamp((Flux*.9)+.1, 0, 1)) halo.Add( {self}, Color( 0, 0, 0, 255 ), 10, 10, 1, false, false ) halo.Add( {self}, Color( 255, 128, 0, 255 ), 10*Flux, 10*Flux, 1, true, false ) end hook.Add( "PreDrawHalos", "AddHalos", DrawHalo )[/lua]
[QUOTE=WalkingZombie;46411678]awesome. thanks, but I recently ran into another problem trying to fix some laggy code... My halos, with this code, they draw perfectly when they're drawn in the Think function. When I run them like this, they don't render at all: [lua]function DrawHalo() local Fluxor = math.tan(CurTime()*8) if Fluxor > 2 then Fluxor = 0 end local Flux = .5*Fluxor Flux = math.max(0.1, math.Clamp((Flux*.9)+.1, 0, 1)) halo.Add( {self}, Color( 0, 0, 0, 255 ), 10, 10, 1, false, false ) halo.Add( {self}, Color( 255, 128, 0, 255 ), 10*Flux, 10*Flux, 1, true, false ) end hook.Add( "PreDrawHalos", "AddHalos", DrawHalo )[/lua][/QUOTE] self is not defined.
Ok, so I can't use self. How do I get 'self' then?
LocalPlayer() But you should cache LocalPlayer() into a variable outside the hook.
but it's not the player??? [editline]4th November 2014[/editline] it's a SENT [editline]4th November 2014[/editline] Ha... nevermind I just got it working, thanks
I'm having issues setting up global classes. I have classes as individual files in a folder. (Gamemodes/gamemodename/gamemode/classes/001_PistolWhipper.lua) And I am going about it all like so: [IMG]http://puu.sh/cE3ft/bfb2d1d443.png[/IMG] It works on the server fine - [img]http://puu.sh/cE3kP/ad4f5e8e91.png[/img] But clientside it does not, I've done this sort of stuff before but I don't remember how I went about it.. [IMG]http://puu.sh/cE3nS/f49c2eb430.png[/IMG]
[QUOTE=Minteh Fresh;46414234]I'm having issues setting up global classes. I have classes as individual files in a folder. (Gamemodes/gamemodename/gamemode/classes/001_PistolWhipper.lua) And I am going about it all like so: [IMG]http://puu.sh/cE3ft/bfb2d1d443.png[/IMG] It works on the server fine - [img]http://puu.sh/cE3kP/ad4f5e8e91.png[/img] But clientside it does not, I've done this sort of stuff before but I don't remember how I went about it.. [IMG]http://puu.sh/cE3nS/f49c2eb430.png[/IMG][/QUOTE] I would guess it is where in your shared.lua you are searching for the files to include. You are searching the 'gamemode' directory but I think after you send the files to the client they aren't in that directory anymore, they are in the regular lua directory. I could be wrong but add print statements to make sure it is finding/including the file.
-snip, fixed-
Is GetPhysicsObject truely shared? I'm trying to call it on client and it's not working. [lua] local prop = LocalPlayer():GetEyeTrace().Entity local DeltaMass = -1 if prop:IsValid() then print("prop is valid") if prop:GetPhysicsObject():IsValid() then print("physicsobject is valid") DeltaMass = prop:GetPhysicsObject():GetMass() end end [/lua] [editline]5th November 2014[/editline] w/e I'll just use SetNW and GetNW
Sorry, you need to Log In to post a reply to this thread.