[QUOTE=KingCentKing;48614438]Ok but how can I use it that it fades from the first Angle to the second angle.
The function itself just returns a percentage. (?)[/QUOTE]
Set it to a variable and add it or rotate around axis to your previous angle.
[code]
local lerpto = LocalPlayer():EyeAngle()
lerpto = LerpAngle(10,lerpto,newangle)
LocalPlayer():EyeAngle():SetAngle(lerpto)
[/code]
Dunno if this is how it works but I'm assuming since I've used regular Lerp for GUI stuff.
[sp]Also, try not to type in the quote cause it took me forever to find what you typed[/sp]
[QUOTE=LUModder;48615465]Set it to a variable and add it or rotate around axis to your previous angle.
[code]
local lerpto = LocalPlayer():EyeAngle()
lerpto = LerpAngle(10,lerpto,newangle)
LocalPlayer():EyeAngle():SetAngle(lerpto)
[/code]
Dunno if this is how it works but I'm assuming since I've used regular Lerp for GUI stuff.
[sp]Also, try not to type in the quote cause it took me forever to find what you typed[/sp][/QUOTE]
That is not how you use the Lerp functions correctly.
[lua]
LerpAngle((currentTime - animationStartTime) / animationDuration, startAngle, endAngle)
[/lua]
Would anyone happen to know how I can make models in DModelPanel less jagged?
[img]https://i.gyazo.com/fddef4818e98586962b644fc28817aeb.png[/img]
[code]
local mp = vgui.Create( "DModelPanel", panel )
mp:SetSize( panel:GetWide() + 100, panel:GetTall() )
mp:SetPos( -12, -10 )
mp:SetModel( model )
mp:SetAnimSpeed( 0.1 )
mp:SetAnimated( true )
mp:SetAmbientLight( Color( 255, 255, 255 ) )
mp:SetDirectionalLight( BOX_TOP, Color( 255, 255, 255 ) )
mp:SetCamPos( Vector( vec1, vec2, vec3 ) )
mp:SetLookAt( Vector( look1, look2, look3 ) )
mp:SetFOV( 40 )
[/code]
[QUOTE=Shenesis;48619307]Override [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dmodelpanel.lua#L91"]the DrawModel function[/URL] and try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/PushFilterMin]render.PushFilterMin[/url]
[/QUOTE]
-snip fixed all my stupid overflow mistakes -
I've added the:
[code]
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
render.PopFilterMin()
[/code]
to the DrawModel function inside lua/vgui/dmodelpanel.lua but it didn't seem to do much if anything at all:
[IMG]https://i.gyazo.com/16089fbb288c434454b007e81f7be25a.png[/IMG]
[QUOTE=kpjVideo;48619811]-snip fixed all my stupid overflow mistakes -
I've added the:
[code]
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
render.PopFilterMin()
[/code]
to the DrawModel function inside lua/vgui/dmodelpanel.lua but it didn't seem to do much if anything at all:
[IMG]https://i.gyazo.com/16089fbb288c434454b007e81f7be25a.png[/IMG][/QUOTE]
It's supposed to wrap the Entity:Draw() call.
[lua]
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
EntityReference:Draw( )
render.PopFilterMin()
[/lua]
[QUOTE=James xX;48620343]It's supposed to wrap the Entity:Draw() call.
[lua]
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
EntityReference:Draw( )
render.PopFilterMin()
[/lua][/QUOTE]
Correct me if I'm wrong/dumb but there isn't any Entity, Are you talking about the DrawModel func within DModelPanel?
like so?:
[code]
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
self:DrawModel()
render.PopFilterMin()
[/code]
Either way, thanks for the help <3
[QUOTE=kpjVideo;48620495]Correct me if I'm wrong/dumb but there isn't any Entity, Are you talking about the DrawModel func within DModelPanel?
like so?:
[code]
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
self:DrawModel()
render.PopFilterMin()
[/code]
Either way, thanks for the help <3[/QUOTE]
There is an entity (ClientSideModel, self.Entity if you're interested), but yeah that code should work.
[QUOTE=James xX;48620603]There is an entity (ClientSideModel, self.Entity if you're interested), but yeah that code should work.[/QUOTE]
Oddly enough, using that didn't seem to do anything :(
[QUOTE=kpjVideo;48620655]Oddly enough, using that didn't seem to do anything :([/QUOTE]
The antialiasing on DModelPanel also depends on your mat_antialias setting. I don't think there is a way to forcefully antialias it, besides actually doing it on your own. (scaling down a render target of a big version of the model, never done it so I don't know if that makes any sense but it should)
[QUOTE=Jeezy;48579422]Maybe this is worth a try.
[url]https://github.com/MeltedBu11et/GM-A-Pathfinder[/url][/QUOTE]
Can I get an example of how to properly use it? There are no examples and after spending the last 25 minutes chasing down Lua errors in it I still am unable to get a walkable position vector on Gm_construct, I only get nil values
[code]
local path = Pathfinder:new( findExho():GetPos(), Vector(832, 292, -79) )
print(path)
path:setGridSize( 16 )
path:start()
print(path:findWalkablePosition( findExho():GetPos()) )
[/code]
Is there a way to change the slot a weapon goes into on pickup using PlayerCanPickupWeapon or WeaponEquip? I know I need to do something with weapon.slot but how can I set that before it's already been assigned?
Is there any way to store data with file.Write() when server turns off?
I found an GM:Initialize() functions to load all things but couldn't find any function when server turns off.
Should I use GM:Tick() functions to write data to server each 5min or something like that?
Also, is there any way to draw a clientside model on entity without having clientside entity created?
Any way a trace can hit a SOLID_NONE entity?
Tried MASK_ALL, MASK_SHOT_HULL but actually I got no clue lol.
It's used for seats inside a vehicle, so I guess SOLID_NONE is the correct choice.
So I found the issue of my invisible players, It's to-do with util.SpriteTrail (trails). If I spawn a bunch of bots on a server and give them a trail, after around 5-10 minutes of them falling off the map into a teleport and getting put back at spawn things randomly go invisible.
Without trails this doesn't happen. The trails aren't getting duplicated as they are only created on spawn if they don't already exist, so I'm not sure what's going on but it's something to-do with trails while being teleported.
Hi. I got small but hardly(as for me) problem. I would like create many layer material(material, that have 4-5 materials inside) and use them in SetSubMaterial. But material don't work. Can someone help with?
[CODE] [ERROR] gamemodes/capturetheflag/entities/entities/ent_flag/init.lua:61: attempt to call method 'PrintMessage' (a nil value)
1. unknown - gamemodes/capturetheflag/entities/entities/ent_flag/init.lua:61
[/CODE]
what is the problem with it? running it serverside.
My code:
[CODE]
function ENT:Touch(ent)
if (ent:IsPlayer() and not self:GetColor() == team.GetColor(ent:Team()) ) then
local weapon = ent:Give("weapon_flag")
self:Remove()
else if (ent:IsPlayer())
ent:PrintMessage(HUD_PRINTCENTER, "This is your FLAG. defend it.")
end end
end
[/CODE]
Im working on a command for TTT to hide players pointshop trails, to fix the spectator floaty trails bug.
Here is what I have so far:
[code]
hook.Add("PlayerSay", "Server_PointshopTriggers", function( player, text )
if ( string.sub( text, 1, 10 ) == "/fixtrails" ) then
for _,ply in pairs(player.GetAll()) do
if ply:IsSpec() then
print("Attempting to remove PS items.")
self:HidePSItems(ply)
end
end
end
end);
[/code]
But when I run it, I get this error:
[code]
[ERROR] addons/miscaddons/lua/autorun/pointshopfix:155: attempt to c
all field 'GetAll' (a nil value)
1. fn - addons/miscaddons/lua/autorun/pointshopfix.lua:155
2. Run - addons/ulib svn/lua/ulib/shared/hook.lua:110
3. func - addons/atlaschat/lua/atlaschat/init.lua:647
4. unknown - lua/includes/extensions/net.lua:32
[/code]
Im out of ideas, Anyone know why this isn't working?
Thank you =)
hook.Add("PlayerSay", "Server_PointshopTriggers", function( player, text )
if ( string.sub( text, 1, 10 ) == "/fixtrails" ) then
for _,ply in pairs(player.GetAll()) do
if ply:IsSpec() then
print("Attempting to remove PS items.")
self:HidePSItems(ply)
end
end
end
end);
This is where FPTje's linter comes in handy, your hook argument called "player" overshadows the player library, so what you are trying to do is Player.GetAll, since Player object doesn't have such method, and you are not called a method properly, it obviously errors.
Change the variable name for your first argument.
-snip-
Ninja'd.
fix it
[QUOTE=gamerpaddy;48603098]You can use
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetMaterials]Entity:GetMaterials()[/url]
you also could try [url]http://www.wunderboy.org/apps/jhlmv.php[/url] which also show raw textures (before compile, same name, but different file extension)[/QUOTE]
Whenever I print the Entity:GetMaterials() it returns "table 0x" and a bunch of random numbers and letters after.
For the Wunderboy, whenever I try to load the models the software ends up crashing.
This is for finding a model's textures so I can accurately find what files to add to FastDL
[QUOTE=PigeonTroll;48636249]Whenever I print the Entity:GetMaterials() it returns "table 0x" and a bunch of random numbers and letters after.[/QUOTE]
To print tables you have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintTable]PrintTable[/url]( tbl ).
In my code, I was basically storing SteamID and Username into one string, but split via a /. I wrote a simple function to get each side:
[code]
function string.NiandraSplit(value,get_right)
local direction = ""
local remove = ""
if get_right then
direction = string.Right(value, "21")
remove = string.Replace(value,direction,"")
else
direction = string.Left(value, string.find(value,"/"))
remove = string.Replace(value,direction,"")
end
return remove
end
[/code]
This works fine:
[img]http://i.imgur.com/xTOnB4V.png[/img]
However I want to make it for general purposes, so I thought to myself I would take the code above and change "21" to the string.Find like in the left direction, but if I do that and then try "Salad/Pie", I get this:
[img]http://i.imgur.com/tobpJla.png[/img]
Does anyone know why string.Left works fine and gets the appropriate amount of characters but string.Right does not?
You could approach this with pattern matching. I almost never used string.Left/Right, just use string.match for this purpose.
Untested, but you will need something like this:
[code]
local left, right = string.match(str, "([^//]+)/(.+)$")
[/code]
Try create texture by rendering
[code]
function GenTestTex()
local w, h = ScrW(), ScrH()
local size = 512
local rendtex = GetRenderTarget( "testtexture", size, size, false )
local OldRT = render.GetRenderTarget()
render.SetRenderTarget( rendtex )
render.SuppressEngineLighting( true )
cam.IgnoreZ( true )
render.SetBlend( 1 )
render.SetViewPort( 0, 0, size, size )
render.Clear( 0, 0, 0, 255, true )
cam.Start2D()
render.SetColorModulation(1,1,1)
for k,v in pairs(materials) do
render.SetMaterial(Material(v))
render.DrawQuadEasy(Vector(256,256,0),Vector(0,0,-1),512,512,Color(math.random(1,255),math.random(1,255),math.random(1,255),255 ), -90)
end
cam.End2D()
render.SetRenderTarget( OldRT )
render.SetViewPort( 0, 0, w, h )
render.SetColorModulation(1,1,1)
render.SetBlend( 1 )
render.SuppressEngineLighting( false )
return rendtex
end
[/code]
materials table contain paths to materials.
After try use this material in SetSubMaterial(clientside)
[code]
local mat = GenTestTex()
Entity(1):SetSubMaterial(2,mat)
[/code]
And nothing. GetSubMaterial get "" string.
Can somebody help me?
-snip-
I really don't know how RTs work, sorry.
Someone got the FontAwsome icon pack working in Gmod?
Basically put the .ttf into resource/fonts/ and added this to the code:
[CODE]
--Server
resource.AddFile("resource/fonts/fontawesome-webfont.ttf") -- Font awsome
--Client
surface.CreateFont("fontawesome.100", {font = "FontAwesome", size = 100, weight = 100})
--I also tried this
surface.CreateFont("fontawesome.100", {font = "FontAwesome", size = 100, weight = 100, symbol = true})
--somehere HUDPaint
draw.SimpleText("", "fontawesome.100", ScrW() - 390, ScrH() - 100, Color(255, 255, 255, 242), TEXT_ALIGN_LEFT)
[/CODE]
Sadly, no approach worked. symbol=true just made it a webdings font.
[QUOTE=UnkN;48639935]
After try use this material in SetSubMaterial(clientside)
[code]
local mat = GenTestTex()
Entity(1):SetSubMaterial(2,mat)
[/code]
And nothing. GetSubMaterial get "" string.
Can somebody help me?[/QUOTE]
Render targets are textures, not materials. You need to create a material to go with it, like this:
[code]
local iconRT = GetRenderTarget( "icon_rt", iconW, iconH )
local iconMat = CreateMaterial( "icon_rt", "UnlitGeneric", {
[ "$basetexture" ] = iconRT:GetName(),
[ "$vertexalpha" ] = 1,
} )
[/code]
Also read the wiki page about [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetSubMaterial]Entity:SetSubMaterial[/url],
it claims you need to pass the name of the material you created.
[QUOTE=MDave;48641950]Render targets are textures, not materials. You need to create a material to go with it, like this:
[code]
local iconRT = GetRenderTarget( "icon_rt", iconW, iconH )
local iconMat = CreateMaterial( "icon_rt", "UnlitGeneric", {
[ "$basetexture" ] = iconRT:GetName(),
[ "$vertexalpha" ] = 1,
} )
[/code]
Also read the wiki page about [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetSubMaterial]Entity:SetSubMaterial[/url],
it claims you need to pass the name of the material you created.[/QUOTE]
[code]
local newmat = GetRenderTarget("body"..ent:EntIndex())
local mat = CreateMaterial( "!body"..ent:EntIndex(), "VertexLitGeneric", {
[ "$basetexture" ] = newmat:GetName(),
[ "$vertexcolor" ] = 1,
[ "$vertexalpha" ] = 1,
} )
ent:SetSubMaterial(2,mat)
[/code]
Don't work :C
*EDIT*
When I use this material in surface.DrawTexturedRect all works fine.
1) In a shared autorun file, do I still need the server to AddCSLuaFile?
2) Is there a reason why GetNWInt returns a string?
Sorry, you need to Log In to post a reply to this thread.