[QUOTE=ROFLBURGER;49503203]Amazing, thank you. You saved me a headache.[/QUOTE]
Here's some example code I was just trying in case you want it:
[CODE]
hook.Add( 'HUDPaint', 'Testpaint', function()
local vec = Vector( 0, 0, 0 )
local toscreen = vec:ToScreen()
toscreen.x = math.Clamp( toscreen.x, 25, ScrW() - 25 )
toscreen.y = math.Clamp( toscreen.y, 25, ScrH() - 25 )
draw.NoTexture()
surface.SetDrawColor( 255, 0, 255, 255 )
surface.DrawRect( toscreen.x - 10, toscreen.y - 10, 20, 20 )
end )
[/CODE]
You probably won't need that though :P
I've built a regex pattern to match Color(255,255,255) (whatever values inside) inside of arguments that would go into varargs. So, example,
[code]"Hi there, this is a test string, Color(255, 255, 255), This should get matched!"[/code]
Should find the color structure inside that string, but it doesn't.
Here is the pattern I made
[code],?%s*([Colr])+%(%s*([0-9],?%s*)+%)?%s*,?[/code]
Here is the original regex
[code],?\s*([Ccolr])+\(\s*([0-9],?\s*)+\)?\s*,?[/code]
[QUOTE=Z0mb1n3;49505542]I've built a regex pattern to match Color(255,255,255) (whatever values inside) inside of arguments that would go into varargs. So, example,
[code]"Hi there, this is a test string, Color(255, 255, 255), This should get matched!"[/code]
Should find the color structure inside that string, but it doesn't.
Here is the pattern I made
[code],?%s*([Colr])+%(%s*([0-9],?%s*)+%)?%s*,?[/code]
Here is the original regex
[code],?\s*([Ccolr])+\(\s*([0-9],?\s*)+\)?\s*,?[/code][/QUOTE]
[code]local s = "Hi there, this is a test string, Color(255, 200, 150), This should get matched!"
for r, g, b in s:gmatch("Color%s*%(%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*%)") do
print(r, g, b)
end[/code]
Is it possible to move/rotate a prop parented to something? I'm trying to make a hat preview on a player model in DModelPanel and I've got the entity showing up but it won't respond to any SetPos or SetAngle commands
[code]
local item = ents.CreateClientProp( data.Model )
local bone_id = ent:LookupAttachment( data.Parent )
local tbl = ent:GetAttachment( bone_id )
item:SetParent( ent, bone_id )
item:SetModelScale( data.Scale )
item:SetPos( tbl.Pos + data.Pos )
item:SetAngles( tbl.Ang + data.Angle )
item:Spawn()
[/code]
[QUOTE=solid_jake;49505835]Is it possible to move/rotate a prop parented to something? I'm trying to make a hat preview on a player model in DModelPanel and I've got the entity showing up but it won't respond to any SetPos or SetAngle commands
[code]
local item = ents.CreateClientProp( data.Model )
local bone_id = ent:LookupAttachment( data.Parent )
local tbl = ent:GetAttachment( bone_id )
item:SetParent( ent, bone_id )
item:SetModelScale( data.Scale )
item:SetPos( tbl.Pos + data.Pos )
item:SetAngles( tbl.Ang + data.Angle )
item:Spawn()
[/code][/QUOTE]
You'd need to use SetRenderOrigin and SetRenderAngles on it from the client's end.
[editline]11th January 2016[/editline]
[QUOTE=man with hat;49505791][code]local s = "Hi there, this is a test string, Color(255, 200, 150), This should get matched!"
for r, g, b in s:gmatch("Color%s*%(%s*(%d+)%s*,%s*(%d+)%s*,%s*(%d+)%s*%)") do
print(r, g, b)
end[/code][/QUOTE]
Not quite what I was looking for. I don't need the actual values inside so much as I do the entire color structure.
What I want to do is to be able to input an entire string like this:
[code]local str = "This is the first part of the message, and it is colored white (which is the default color), Color(255,0,0), but this part is colored red!"[/code]
and wrap the sentences in doublequotes. The string is being inputted by a Derma_StringRequest, and I want to save users the trouble of having to manually wrap sentences in doublequotes, so I figured I could gsub sentences that don't match the color structure to have quotes around them.
[QUOTE=Z0mb1n3;49505869]You'd need to use SetRenderOrigin and SetRenderAngles on it from the client's end.[/QUOTE]
I've tried that but in conjunction with the parent. I'll give it another go without parenting this time
[editline]11th January 2016[/editline]
Ran into a problem using that method. The player model becomes semi transparent. If I look at the model from behind I can only see the prop even though it's clearly sticking forward a little bit:
[IMG]http://i.imgur.com/FsGdFsN.png[/IMG]
[IMG]http://i.imgur.com/6OxjgTP.png[/IMG]
[code] local bone_id = ent:LookupAttachment( data.Parent )
local tbl = ent:GetAttachment( bone_id )
item:SetRenderOrigin( tbl.Pos + data.Pos )
item:SetRenderAngles( tbl.Ang + data.Angle )[/code]
How can I setup a custom hitbox without affecting the collision mesh?
For example, physics mesh for players is a 32x32x70 box, yet the hitboxes are more dynamic...
When I shoot the entity in a specific position, it should be a different hitbox (Bullet Trace).
The only available LUA Classes are either broken or useless to me...
[url=http://wiki.garrysmod.com/page/Entity/SetHitboxSet]SetHitboxSet[/url] (Crashes usually)
Which seems to be the only class I can use to setup a hitbox.
[QUOTE=Z0mb1n3;49505869]Not quite what I was looking for. I don't need the actual values inside so much as I do the entire color structure.
What I want to do is to be able to input an entire string like this:
[code]local str = "This is the first part of the message, and it is colored white (which is the default color), Color(255,0,0), but this part is colored red!"[/code]
and wrap the sentences in doublequotes. The string is being inputted by a Derma_StringRequest, and I want to save users the trouble of having to manually wrap sentences in doublequotes, so I figured I could gsub sentences that don't match the color structure to have quotes around them.[/QUOTE]
[quote]I've built a regex pattern to match Color(255,255,255) (whatever values inside)[/quote]
[quote]Not quite what I was looking for. I don't need the actual values inside[/quote]
I don't understand. You ask for the values inside, and then say you don't want them, and want quotes around sentences instead.
[quote]I don't need the actual values inside so much as I do the entire color structure.[/quote]
You can create the color from the values.
[QUOTE=Z0mb1n3;49505542]I've built a regex pattern to match Color(255,255,255) (whatever values inside) inside of arguments that would go into varargs. So, example,
[code]"Hi there, this is a test string, Color(255, 255, 255), This should get matched!"[/code]
Should find the color structure inside that string, but it doesn't.
Here is the pattern I made
[code],?%s*([Colr])+%(%s*([0-9],?%s*)+%)?%s*,?[/code]
Here is the original regex
[code],?\s*([Ccolr])+\(\s*([0-9],?\s*)+\)?\s*,?[/code][/QUOTE]
I find [URL="http://regex101.com"]regex101[/URL] pretty useful for regex, because it explains what each part of the regex does. However in your regex you have percentage signs all over though, which leads me to believe that it isn't actually regex because that isn't something in regex. Is this Lua's Pattern Matching?
I have to leave for classes now, but when I get the time in a few hours I'll try to make a regex pattern for this, but I'm not sure if that's what you want.
[QUOTE=roastchicken;49506835]:snip:[/QUOTE]
Unfortunately (:suicide:) Lua doesn't use Regex and uses its own [URL="http://www.lua.org/pil/20.2.html"]pattern matching[/URL].
Most things should be somewhat the same, but you'll have to replace \s (for example) with %s. Many of the features Regex has, Lua does not :L
[QUOTE=man with hat;49506589]I don't understand. You ask for the values inside, and then say you don't want them, and want quotes around sentences instead.
You can create the color from the values.[/QUOTE]
I apologize for not wording it better, but what my original regex pattern was intended for was that it would check if a string was a color structure. It wouldn't care what the numbers were inside and it wouldn't return the values inside. It would simply say "yes this matches a color structure" if it had the word color in front, parentheses, and three values. I would then use string.Explode to explode the string using that pattern as a separator, and from there would be able to do the quote wrapping.
How can i allow a specific weapon to be pick up from the ground and placed in your inventory?
Hi,
I'm trying to send a private message to the player saying "[Millionaire] You've been assigned the {TEAM} team!"
Everything's working fine, except for the team color.
How can I get the ply's team color to be added here? Thanks
[CODE]
ply:SendLua([[chat.AddText( Color( 255, 255, 255 ), "[", Color( 20, 20, 150 ), "Millionaire", Color( 255, 255, 255), "] ", Color( 200, 200, 200 ), "You've been assigned the ", ]]..team.GetColor( ply:Team() )..[[, "]]..team.GetName( ply:Team() )..[[", Color( 200, 200, 200), " team!")]])
[/CODE]
EDIT: Error code:
[CODE]
[ERROR] gamemodes/millionaire/gamemode/init.lua:39: attempt to concatenate a table value
[/CODE]
:snip: misread
[QUOTE=MPan1;49510523][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/team/GetColor]team.GetColor[/url]?[/QUOTE]
Shit, sorry, completely forgot to add the error code in it.
Anyways, I am using team.GetColor (right after the You've been assigned the)
Error I'm getting is
[CODE]
[ERROR] gamemodes/millionaire/gamemode/init.lua:39: attempt to concatenate a table value
[/CODE]
[QUOTE=Silhouhat;49510534]Shit, sorry, completely forgot to add the error code in it.
Anyways, I am using team.GetColor (right after the You've been assigned the)
Error I'm getting is
[CODE]
[ERROR] gamemodes/millionaire/gamemode/init.lua:39: attempt to concatenate a table value
[/CODE][/QUOTE]
You're assuming the team color is a string.
This is what you want to do
[code]ply:SendLua([[chat.AddText( Color( 255, 255, 255 ), "[", Color( 20, 20, 150 ), "Millionaire", Color( 255, 255, 255), "] ", Color( 200, 200, 200 ), "You've been assigned the ", ]], team.GetColor( ply:Team() ), [[, "]]..team.GetName( ply:Team() )..[[", Color( 200, 200, 200), " team!")]])[/code]
:snip: ninja'd
Is there a clientside equivalent of the EntityTakeDamage hook?
Also, if not, what kind of net function should I be using to send the CTakeDamageInfo thing?
Actually, nevermind
[QUOTE=Z0mb1n3;49510582]You're assuming the team color is a string.
This is what you want to do
[code]ply:SendLua([[chat.AddText( Color( 255, 255, 255 ), "[", Color( 20, 20, 150 ), "Millionaire", Color( 255, 255, 255), "] ", Color( 200, 200, 200 ), "You've been assigned the ", ]], team.GetColor( ply:Team() ), [[, "]]..team.GetName( ply:Team() )..[[", Color( 200, 200, 200), " team!")]])[/code][/QUOTE]
I'm getting the following error with your code:
[CODE]
[ERROR] LuaCmd:1: unexpected symbol near '<eof>'
1. unknown - LuaCmd:0
[/CODE]
[QUOTE=Silhouhat;49510749]I'm getting the following error with your code:
[CODE]
[ERROR] LuaCmd:1: unexpected symbol near '<eof>'
1. unknown - LuaCmd:0
[/CODE][/QUOTE]
Thats an autorefresh error. Ignore it.
Youre code should be runing fine now
[QUOTE=geferon;49512753]Thats an autorefresh error. Ignore it.
Youre code should be runing fine now[/QUOTE]
Strange. It still doesn't work. Returns in the same error as before.
Does anyone have any example code that smoothy transitions between two vectors in a set time? I know this seems really basic but I'm used to derma stuff not involving vectors and it'd really help me learn
[QUOTE=MPan1;49518463]Does anyone have any example code that smoothy transitions between two vectors in a set time? I know this seems really basic but I'm used to derma stuff not involving vectors and it'd really help me learn[/QUOTE]
For derma, you can just use [url=http://wiki.garrysmod.com/page/Panel/LerpPositions]Panel.LerpPositions[/url] to get the panel to smoothly transition when you call SetPos on it.
Sorry, forgot to mention, I'm not using derma, just actual vectors
Do you know how to smoothly transition between two vectors?
[QUOTE=MPan1;49518530]Sorry, forgot to mention, I'm not using derma, just actual vectors
Do you know how to smoothly transition between two vectors?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LerpVector]Global.LerpVector[/url]
I looked at that function, but I don't know what to use for the fraction since I need it to take the same time span to transition between the vectors for all clients, which probably involves something to do with FrameTime but I'm not sure what to do with it. I know this must seem really basic and dumb but it'd really be nice if someone could help me
[QUOTE=MPan1;49518568]I looked at that function, but I don't know what to use for the fraction since I need it to take the same time span to transition between the vectors for all clients, which probably involves something to do with FrameTime but I'm not sure what to do with it. I know this must seem really basic and dumb but it'd really be nice if someone could help me[/QUOTE]
lerp by a value that is multiplied by frametime, e.g. LerpVector(frac*FrameTime(),from_vec,to_vec)
[QUOTE=MPan1;49518568]I looked at that function, but I don't know what to use for the fraction since I need it to take the same time span to transition between the vectors for all clients, which probably involves something to do with FrameTime but I'm not sure what to do with it. I know this must seem really basic and dumb but it'd really be nice if someone could help me[/QUOTE]
Look through Customizable Weaponry 2.0's code. CSPSpy did a [i]ton[/i] of work with Lerp there.
-snip-
got it
[QUOTE=MaximLaHaxim;49518730]Look through Customizable Weaponry 2.0's code. CSPSpy did a [i]ton[/i] of work with Lerp there.[/QUOTE]
I just ended up creating a 2 second timer and using timer.TimeLeft :P
Anyway, I have a question, whenever I try to use
[CODE]
dmginfo:GetInflictor()
[/CODE]
In an EntityTakeDamage hook and the attacker is me, it always returns my name for the inflictor as well as the attacker. Is this a bug? I thought GetAttacker was meant to get the shooter and GetInflictor was meant to get the weapon...
-moved to thread-
Sorry, you need to Log In to post a reply to this thread.