[QUOTE=Mista Tea;45627390]The 'other guy' is using surface.SetTextColor and surface.SetTextPos already.
[CODE]
surface.SetTextColor( MyColor )
surface.SetTextPos( 0, 0 )
surface.SetFont( "My font" )
surface.DrawText( "My text" )[/CODE]
I'm not literally doing that ^ but you get the point. I am calling the appropriate functions within cam.Start3D2D/cam.End3D2D.
But I'm totes down for any other suggestions though.[/QUOTE]
I just made an entity to test:
[lua]ENT.Base = "base_anim"
AddCSLuaFile()
function ENT:Initialize()
self:SetModel("models/hunter/blocks/cube025x1x025.mdl")
end
function ENT:Draw()
self:DrawModel()
cam.Start3D2D(self:GetPos() + self:GetAngles():Up() * 11.5, self:GetAngles(), 1)
surface.SetFont("default")
surface.SetTextColor(Color(128, 255, 255))
surface.SetTextPos(0, 0)
surface.DrawText("Dildos")
cam.End3D2D()
end[/lua]
Went into sandbox and it works perfectly.
[QUOTE=OzymandiasJ;45627562]Went into sandbox and it works perfectly.[/QUOTE]
Unfortunately my issue is not simply occurring outright.
I'd be working on the script and after a while it just stops drawing the text entirely, yet all of my draw.RoundedBox's and other draw/surface elements still show up just fine, even though I hadn't even touched the cam drawing part for a good while. I don't have a way to replicate it. I just know it's occurred on at least 2 separate occassions for no apparent reason.
The text will literally fade in/out to black/transparent over a second when I open any other sort of menu, even though nothing I am doing even remotely simulates any of that. By that I mean it doesn't simply have 255 alpha as soon as you open console (for example) and 0 alpha when you close it. It literally fades in and out.
I know none of this really helps much but at the same time I didn't really post this here looking for a specific fix.
[QUOTE=Mista Tea;45627574]
I know none of this really helps much but at the same time I didn't really post this here looking for a specific fix.[/QUOTE]
That literally just sounds like you're not setting the surface.SetColor value and other things are setting it and it's screwing up your text (try not setting the color and then causing an error, and watch the flashing co-respond to the error.)
[QUOTE=OzymandiasJ;45627627]That literally just sounds like you're not setting the surface.SetColor value and other things are setting it and it's screwing up your text (try not setting the color and then causing an error, and watch the flashing co-respond to the error.)[/QUOTE]
This is literally what I was doing:
[CODE]cam.Start3D2D( visualizer.Pos, visualizer.Ang, 1 )
draw.RoundedBox( 0, x, ( levelH - h*3 ) / 2, levelW, h*3, HSVToColor( hue + i, s, v ) )
if ( visualizer.DrawBorders:GetBool() ) then
surface.SetDrawColor( visualizer.BorderColor )
surface.DrawOutlinedRect( x, ( levelH - h*3 ) / 2, levelW, h*3 )
end
surface.SetDrawColor( WHITE )
surface.SetTextPos( x + ( levelW / 2 ), levelH )
surface.DrawText( i )
cam.End3D2D()[/CODE]
I realize without the context this doesn't mean much but I was just making a dumb FFT visualizer with sound.PlayURL for fun. The text just corresponded to the current FFT channel (this cam is surrounded in a for loop for the 128 FFT channels).
And I have WHITE predefined elsewhere, that isn't the issue. I am definitely setting the text color.
I'll see if I can get the issue to occur again and post a screenshot of it.
I'm trying to find out how to set the material behaviour of an entity. Like how humans always have the MAT_FLESH and world weapon models seem to have MAT_METAL. Is there a way to override this and, for example, set a weapon to use MAT_SLOSH? I just can't seem to find out how to do it, or, which is more likely, I'm looking in all the wrong places :(
[QUOTE=OzymandiasJ;45627627]That literally just sounds like you're not setting the surface.SetColor value and other things are setting it and it's screwing up your text (try not setting the color and then causing an error, and watch the flashing co-respond to the error.)[/QUOTE]
Wow, I'm sorry. I didn't even notice it without a friend catching it, but I was using surface.SetDrawColor in the specific spot where I was drawing the numbers, but correctly using surface.SetTextColor for my other stuff, so I never noticed it.
My bad.
-snip-
[editline]8th August 2014[/editline]
Is it possible to reverse a weapon animation? If so, how would I do it?
I'm not sure, but have you tried playing with SetPlaybackRate() at -1?
[QUOTE=TripsLetash;45627699]I'm trying to find out how to set the material behaviour of an entity. Like how humans always have the MAT_FLESH and world weapon models seem to have MAT_METAL. Is there a way to override this and, for example, set a weapon to use MAT_SLOSH? I just can't seem to find out how to do it, or, which is more likely, I'm looking in all the wrong places :([/QUOTE]
[url]http://wiki.garrysmod.com/page/PhysObj/SetMaterial[/url] ?
Well, I guess no one knows how to make the hardcode 'sniperbullet' entity work? If you do know how, please inform me! Meanwhile, I'll be off trying to make my own version. I have no idea how to imitate the tracer effect used on the sniper bullet. (It's not a simple tracer like the ones for hit-scan bullets)
[editline]8th August 2014[/editline]
[QUOTE=Ott;45633337][QUOTE=TripsLetash;45627699]I'm trying to find out how to set the material behaviour of an entity. Like how humans always have the MAT_FLESH and world weapon models seem to have MAT_METAL. Is there a way to override this and, for example, set a weapon to use MAT_SLOSH? I just can't seem to find out how to do it, or, which is more likely, I'm looking in all the wrong places :([/QUOTE]
[url]http://wiki.garrysmod.com/page/PhysObj/SetMaterial[/url] ?[/QUOTE]
I believe he wants to change the physical properties, not just the appearance.
[QUOTE=TripsLetash;45627699]I'm trying to find out how to set the material behaviour of an entity. Like how humans always have the MAT_FLESH and world weapon models seem to have MAT_METAL. Is there a way to override this and, for example, set a weapon to use MAT_SLOSH? I just can't seem to find out how to do it, or, which is more likely, I'm looking in all the wrong places :([/QUOTE]
This may be what you're looking for?
[url]http://wiki.garrysmod.com/page/Global/CreateMaterial[/url]
I'm trying to rewrite a perk system so that saving the clients data doesn't require a text file per class, but when I use util.KeyValuesToTable to get the client's current level, I'm met with
[lua]table: 0x26824768[/lua]
as opposed to an actual table, and then everything returns nil
code I'm using:
[lua]if self:GetPlayerClass() == CLASS_COMMANDO then
local plySavedData = util.KeyValuesToTable(file.Read("toxsinx/userdata/" .. self:SteamID64() .. "_perkdata.txt", "DATA"))
self:SetExperience(tonumber(plySavedData["CommandoExperience"]))
self:SetLevel(tonumber(plySavedData["CommandoLevel"]))
self:SetReqExperience(tonumber(plySavedData["CommandoReqExperience"]))
end [/lua]
any ideas?
[editline]9th August 2014[/editline]
good job lua tags for disappearing after I edit it :(
[QUOTE=solid_jake;45636520]I'm trying to rewrite a perk system so that saving the clients data doesn't require a text file per class, but when I use util.KeyValuesToTable to get the client's current level, I'm met with
[lua]table: 0x26824768[/lua]
as opposed to an actual table, and then everything returns nil
code I'm using:
[lua]if self:GetPlayerClass() == CLASS_COMMANDO then
local plySavedData = util.KeyValuesToTable(file.Read("toxsinx/userdata/" .. self:SteamID64() .. "_perkdata.txt", "DATA"))
self:SetExperience(tonumber(plySavedData["CommandoExperience"]))
self:SetLevel(tonumber(plySavedData["CommandoLevel"]))
self:SetReqExperience(tonumber(plySavedData["CommandoReqExperience"]))
end [/lua]
any ideas?
[editline]9th August 2014[/editline]
good job lua tags for disappearing after I edit it :([/QUOTE]
Although I might sound dicky and I'm not going to help you, just quickly I noticed that you're doing a if self:GetPlayerClass() == CLASS_COMMANDO then CommandoExperience etc.
Have you considered setting up tables within tables? For example:
[lua]self:SetExperience( plySavedData[ self:GetPlayerClass( ) ].Experience)
self:SetLevel( plySavedData[ self:GetPlayerClass( ) ].Level)
self:SetReqExperience( plySavedData[ self:GetPlayerClass( ) ].ReqExperience)[/lua]
etc, so then you won't have to go through 50 if class checks and manually write it all.
[QUOTE=solid_jake;45636520]I'm trying to rewrite a perk system so that saving the clients data doesn't require a text file per class, but when I use util.KeyValuesToTable to get the client's current level, I'm met with
[lua]table: 0x26824768[/lua]
[/QUOTE]
You're either:
1. Trying to use the wrong key names.
2. Trying to parse a malformed keyvalues string (Console should say "KeyValues Error: x" in read ). This function still returns a table even if it failed to parse and explains why you're getting nil and not an error if thats the case.
Try PrintTable( plySavedData ) and see what it gives you. It seems like you were just trying print()
When I overwrite the Paint function of a panel and I set the DrawColor to a particular color; that color isn't the color which is being used to draw the panel. (As I can tell by print-screening and using Photoshop's color eye-dropper). However, the color remains very similar.
Does anybody know why this is?
How do I make my own ulx category.
Thanks guy, it worked now. Turned out I left the names in capitals instead of lower case.. woops.
Though I rewrote the code as you suggested Minteh, and it is WONDERFUL
Why custom viewmodel sway is lagging in multiplayer?
I don't see anything wrong in code (though I never coded sways)
[code]local SwayAng = nil
local SwayOldAng = Angle()
local SwayDelta = Angle()
function SWEP:CalcViewModelView(ViewModel, oldPos, oldAng, pos, ang)
SwayAng = oldAng - SwayOldAng
if math.abs(oldAng.y - SwayOldAng.y) > 180 then
SwayAng.y = (360 - math.abs(oldAng.y - SwayOldAng.y)) * math.abs(oldAng.y - SwayOldAng.y) / (SwayOldAng.y - oldAng.y)
else
SwayAng.y = oldAng.y - SwayOldAng.y
end
SwayOldAng.p = oldAng.p
SwayOldAng.y = oldAng.y
SwayAng.p = math.Clamp(SwayAng.p, -self.SwayBounds, self.SwayBounds)
SwayAng.y = math.Clamp(SwayAng.y, -self.SwayBounds, self.SwayBounds)
SwayDelta = LerpAngle(math.Clamp(FrameTime() * 8, 0, 1), SwayDelta, SwayAng)
oldAng.p = oldAng.p - SwayDelta.p *8
oldAng:RotateAroundAxis(oldAng:Up(), SwayDelta.y *-8)
return oldPos, oldAng
end[/code]
[video=youtube;faawBdxD3q0]http://www.youtube.com/watch?v=faawBdxD3q0[/video]
Is there a way to set a player's view angles from serverside? (without relying on the client)
[QUOTE=Hyper Iguana;45644467]Is there a way to set a player's view angles from serverside? (without relying on the client)[/QUOTE]
[code]
ply:SetEyeAngles(Angles(1,1,1))
[/code]
[QUOTE=Leystryku;45645338][code]
ply:SetEyeAngles(Angles(1,1,1)
[/code][/QUOTE]
[CODE]
)
[/CODE]
I think you dropped this
[QUOTE=CallMePyro;45646991][CODE]
)
[/CODE]
I think you dropped this[/QUOTE]
Oops, sorry
When you shoot a swep, it leaves a bullet hole/decal on the wall. How can I stop it from doing this?
[QUOTE=NiandraLades;45649026]When you shoot a swep, it leaves a bullet hole/decal on the wall. How can I stop it from doing this?[/QUOTE]
I'm guessing it has something to do with either [url=http://wiki.garrysmod.com/page/ENTITY/ImpactTrace]this[/url] or [url=http://wiki.garrysmod.com/page/WEAPON/DoImpactEffect]this[/url] (I think you should return true on SWEP:DoImpactEffect()).
Why won't my DLight light the world? The idea was to have the muzzle flash of my gun illuminate the world around me. I would fuss around with the variables to adjust how it looked, but since it's not working I haven't had the chance to fuss!
[lua]function SWEP:Think()
/* more unrelated code above */
if CLIENT then
if self:GetNWBool( "DoFlash" ) == true then
local dlight = DynamicLight( self:EntIndex() )
-- print( "yah" )
if ( dlight ) then
local r, g, b = Color( 255, math.random( 236, 240 ), math.random( 184, 199 ) )
dlight.Pos = self:GetAttachment( 1 ).Pos
dlight.r = r
dlight.g = g
dlight.b = b
dlight.Brightness = 255
dlight.Size = 256
dlight.Decay = 10
dlight.DieTime = CurTime() + 10
dlight.Style = 0
dlight.NoWorld = false
end
end
end
end[/lua]
The light will show on the gun itself, but that's it! The only thing that doesn't work is lighting the world around it.
[editline]10th August 2014[/editline]
and of course, the location where I set the variable?
[lua]...
if self.Sil then
bullet.Damage = math.random( 15, 21 )
else
bullet.Damage = math.random( 21, 27 )
self:SetNWBool( "DoFlash", true )
end
...[/lua]
A decent explanation for the Function "UpdateBehave" for nextbots? Like How to use it?
wiki has zero useful information about it.
Can someone point me in the right direction? I'm currently trying to learn to code in LUA and have read all the resources in code_gs' thread. I've followed the beginner tutorials on the official gmod WIKI and have no clue where to go next. Tutorial: [URL="http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro"]http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro[/URL] Most of the other resources are how to code a gamemode and such are those specific or a good place to start? Are there any recommendations on what to learn very first?
[QUOTE=Hollistupid;45654457]Can someone point me in the right direction? I'm currently trying to learn to code in LUA and have read all the resources in code_gs' thread. I've followed the beginner tutorials on the official gmod WIKI and have no clue where to go next. Tutorial: [URL="http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro"]http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro[/URL] Most of the other resources are how to code a gamemode and such are those specific or a good place to start? Are there any recommendations on what to learn very first?[/QUOTE]Take an entity and try to modify it. This goes for any script just take it and modify till you understand what it does. And if you still have problems with understanding a function just go to [URL="http://wiki.garrysmod.com"]http://wiki.garrysmod.com[/URL]
-snip fixed-
[QUOTE=gonzalolog;45625431]Well, i need help...
[LUA]
surface.CreateFont( "FancyTitle", {
font = "Lobster 1.4",
size = 32,
weight = 500
} )
[/lua]
I'm trying to use the Lobster font...But...When i try to use custom files fonts, i can't...This just use the default until i open the font and press "Install"
Before install:
[t]http://i.imgur.com/hD9Ee0s.jpg[/t]
After install:
[T]http://i.imgur.com/RL5a0JZ.jpg[/t]
I don't think that people will download the font for install this one if they want to see the font[/QUOTE]
Are you using TTF ?
Sorry, you need to Log In to post a reply to this thread.