[QUOTE=Fishbrain;34588973]Ermm yes because I would like to know a way to fix this seen as though I'm sure it's not hard.[/QUOTE]
No, it's really not that hard, it's just addition, keep track of your Y values and your Heights, Let's assume "Pistols" is the first thing, so anything below it will be the "Pistols" Y pos + the height of the box showing the guns + any padding you want = Y value for next category.
and the one after that would be the last categories Y + that box's height + any padding = next Y
hope that helps
Would you be able to give an example? It would help alot.
[QUOTE=Fishbrain;34588765]Anyone help me on this?[/QUOTE]
Are you using [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf605.html?title=DCollapsibleCategory"]DCollapsibleCategory[/URL]?
Yes I am
[QUOTE=JustSoFaded;34580701]Was that to me or to Panto? Also, if it was to Panto, how would you suggest doing a gradient outlined rect (I ask you because you seem to be pretty knowledgeable in the rendering section)?[/QUOTE]
Panto.
And I can't find anything on gradients I'm afraid.
I'm new to Lua and sorry if this is dumb, but why doesn't this work? It prints this to console: "attempt to index global 'input' (a nil value)".
[lua]if (input.IsMouseDown(MOUSE_WHEEL_DOWN) ) then
Msg("test")
end[/lua]
[QUOTE=Fishbrain;34588765]Anyone help me on this?[/QUOTE]
Put your DCollapsibleCategorys into a [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcc5c.html?title=DPanelList"]DPanelList[/URL]. Tested it and it works fine.
[QUOTE=Hill0;34591281]I'm new to Lua and sorry if this is dumb, but why doesn't this work? It prints this to console: "attempt to index global 'input' (a nil value)".
[lua]if (input.IsMouseDown(MOUSE_WHEEL_DOWN) ) then
Msg("test")
end[/lua][/QUOTE]
You have to run it client-side.
I'm wanting to make a TAG sort of system and have the basic's of it. However just now I'm not doing it the best way possible. The way I would like it is that it reads from a TXT file as such. This is what I'm currently doing:
[lua]
local ADMINS = {"STEAM_0:1:16970247"}
local VIPS = {"STEAM_0:0:22688997"}
if table.HasValue(ADMINS, pl:SteamID()) then
self.m_RankLabel:SetText("ADMIN")
self.m_RankLabel:SetTextColor(COLOR_RED)
elseif table.HasValue(VIPS, pl:SteamID()) then
self.m_RankLabel:SetText("VIP")
self.m_RankLabel:SetTextColor(COLOR_YELOW)
else
self.m_RankLabel:SetText("Guest")
self.m_RankLabel:SetTextColor(COLOR_WHITE)
end
[/lua]
I'm not to fond of reading/writing to files, had a quick look on the wiki but no luck. I also couldn't get my head around using SetPData for multiple SteamID's.
[QUOTE=Mrkrabz;34591638]...[/QUOTE]
This should work..
[lua]
local function getAdmins()
if !file.Exists("tagthinger/admins.txt") then return {} end
return string.Explode(";;", file.Read("tagthinger/admins.txt"))
end
local function getVIPS()
if !file.Exists("tagthinger/vips.txt") then return {} end
return string.Explode(";;", file.Read("tagthinger/vips.txt"))
end
function yourtable:yourfunc()
if table.HasValue(getAdmins(), pl:SteamID()) then
self.m_RankLabel:SetText("ADMIN")
self.m_RankLabel:SetTextColor(COLOR_RED)
elseif table.HasValue(getVIPS(), pl:SteamID()) then
self.m_RankLabel:SetText("VIP")
self.m_RankLabel:SetTextColor(COLOR_YELOW)
else
self.m_RankLabel:SetText("Guest")
self.m_RankLabel:SetTextColor(COLOR_WHITE)
end
end
[/lua]
data/tagthinger/admins.txt
[lua]
STEAM_0:1:16970247;;[steamidhere]
[/lua]
I'm having a problem with '}' expected (to close '{' at line 73) near text_spacing
[lua]good_hud = { };
local function clr( color ) return color.r, color.g, color.b, color.a; end
function good_hud:PaintBar (x, y, w, h, colors, value )
self:PaintPanel(x, y, w, h, colors )
x = x + 1; y = y + 1;
w = w - 2; h = h - 2;
surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );
local width = w * math.Clamp( value, 0, 1 );
local shade = 4;
surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );
surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect ( x, y + shade, width, h - shade );
end
local Colors =
{
border = Color( 255, 255, 255, 255),
background = Color( 255, 255, 255, 200 ),
shade = Color( 255, 255, 255, 255 ),
fill = Color( 0, 0, 0, 255 ),
};
good_hud:PaintBar( 50, 50, 250, 16, colors, 0.75 );
function good_hud:paintPanel (x, y, w, h, colors )
surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );
end
function good_hud:PaintText( x, y, text, font, colors )
surface.SetFont( font );
surface.SetTextPos( x + 1, y + 1);
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );
surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );
end
local colors =
{
shdow = Color( 0, 0, 0, 155 ),
text = Color(255, 255, 255, 255 )
};
good_hud:PaintText( 50,50, "Health", "Armor", colors );
function good_hud:TextSize( text, font )
surface.SetFont( font );
return surface.GetTextSize( text );
end
local vars =
{
font = "TargetID",
padding = 10,
margin = 35
text_spacing = 2,
bar_spacing = 5,
bar_height = 16,
width = 0.25
};
local colors =
{
background =
{
border = Color( 190, 255,128, 255 ),
background = Color( 120, 240, 0, 75 )
},
text =
{
shadow = Color(0, 0, 0, 200 ),
text = Color( 255, 255, 255, 255 )
},
health_bar =
{
border = Color( 255, 0, 0, 255 ),
background = Color( 255, 0, 0, 75 ),
shade = Color( 255, 104, 104, 255 ),
fill = Color( 232, 0, 0, 255 )
},
suit_bar =
{
border = Color( 0, 0, 255, 255 ),
background = Color( 0, 0, 255, 75 ),
shade = Color( 136, 136, 255, 255 ),
fill = Color( 0, 0, 219, 255 )
}
};
local function HUDPaint( )
client = client or LocalPlayer( );
if( !client:Alive( ) ) then return; end
local _, th = good_hud:TextSize( "TEXT", vars.font );
local i = 2;
local width = vars.width * ScrW( );
local bar_width = width - ( vars.padding * i );
local height = ( vars.padding * i ) + ( th * i ) + ( vars.text_spacing * i ) + ( vars.bar_height * i ) + vars.bar_spacing;
local x = vars.margin;
local y = ScrH( ) - vars.margin - height;
local cx = x + vars.padding;
local cy = y + vars.padding;
good_hud:PaintPanel( x, y, width, height, colors.background );
local by = th + vars.text_spacing; -- calc text position
local text = string.format( "Health: %iHP", client:Health( ) ); -- get health text
good_hud:PaintText( cx, cy, text, vars.font, colors.text ); -- paint health text and health bar
good_hud:PaintBar( cx, cy + by, bar_width, vars.bar_height, colors.health_bar, client:Health( ) / 100 );
by = by + vars.bar_height + vars.bar_spacing; -- increment text position
local text = string.format( "Suit: %iSP", client:Armor( ) ); -- get suit text
good_hud:PaintText( cx, cy + by, text, vars.font, colors.text ); -- paint suit text and suit bar
good_hud:PaintBar( cx, cy + by + th + vars.text_spacing, bar_width, vars.bar_height, colors.suit_bar, client:Armor( ) / 100 );
end
hook.Add("HUDPaint", "PaintOurHud", Hudpaint );
[/lua]
[editline]7th February 2012[/editline]
located near the "local vars =" part
[QUOTE=confinedUser;34592253]I'm having a problem with '}' expected (to close '{' at line 73) near text_spacing
located near the "local vars =" part[/QUOTE]
You forgot a "," after margin = 35
[QUOTE=confinedUser;34592253]I'm having a problem with '}' expected (to close '{' at line 73) near text_spacing
-code-[/QUOTE]
Can you please use [noparse][Lua][/Lua][/noparse] tags?
[QUOTE=marvincmarvin;34592198]This should work..
[lua]
local function getAdmins()
if !file.Exists("tagthinger/admins.txt") then return {} end
return string.Explode(";;", file.Read("tagthinger/admins.txt"))
end
local function getVIPS()
if !file.Exists("tagthinger/vips.txt") then return {} end
return string.Explode(";;", file.Read("tagthinger/vips.txt"))
end
function yourtable:yourfunc()
if table.HasValue(getAdmins(), pl:SteamID()) then
self.m_RankLabel:SetText("ADMIN")
self.m_RankLabel:SetTextColor(COLOR_RED)
elseif table.HasValue(getVIPS(), pl:SteamID()) then
self.m_RankLabel:SetText("VIP")
self.m_RankLabel:SetTextColor(COLOR_YELOW)
else
self.m_RankLabel:SetText("Guest")
self.m_RankLabel:SetTextColor(COLOR_WHITE)
end
end
[/lua]
data/tagthinger/admins.txt
[lua]
STEAM_0:1:16970247;;[steamidhere]
[/lua][/QUOTE]
Whats [lua]function yourtable:yourfunc()[/lua]?
Edit: Fixed it anyway, just removed that.
So i'm trying to find a way to stop my player marble from bouncing, I'm doing custom gravity and I basically need to ball to stick close to the surface it's on, i'm doing gravity in the PhysicsUpdate Hook, and the gravTrace is done in the think hook and stored( PhysicsUpdate runs way too fast for traces imo).
While my code works and gravity goes where it is supposed to, I bounce up and down a lot, not jumpy, but like a ball bouncy.
[lua]
local physDeltaTime = CurTime()
function ENT:PhysicsUpdate( phys )
-- No grav trace then no gravity yet
if !self.lastGravTrace then return end
local physDelta = CurTime() - physDeltaTime
physDeltaTime = CurTime()
-- Set the goal point for the player marble to the gravity hit pos - 1/2 the radius of the marble
-- and compute movement normal
local gravDiff = (self.lastGravTrace.HitPos - (self.lastGravTrace.HitNormal * (self:BoundingRadius() * 0.5))) - self:GetPos()
-- calculate velocity based on 9.8 ft per sec ( 16 units = 1 foot) (16 * 9.8) * 60 = 9408
local gravVel = (gravDiff:GetNormal() * (9408 * physDelta))
-- apply gravity
phys:AddVelocity(gravVel * physDelta)
end
[/lua]
any help is always appreciated.
[QUOTE=Fantym420;34592699]So i'm trying to find a way to stop my player marble from bouncing, I'm doing custom gravity and I basically need to ball to stick close to the surface it's on, i'm doing gravity in the PhysicsUpdate Hook, and the gravTrace is done in the think hook and stored( PhysicsUpdate runs way too fast for traces imo).
While my code works and gravity goes where it is supposed to, I bounce up and down a lot, not jumpy, but like a ball bouncy.
[lua]
local physDeltaTime = CurTime()
function ENT:PhysicsUpdate( phys )
-- No grav trace then no gravity yet
if !self.lastGravTrace then return end
local physDelta = CurTime() - physDeltaTime
physDeltaTime = CurTime()
-- Set the goal point for the player marble to the gravity hit pos - 1/2 the radius of the marble
-- and compute movement normal
local gravDiff = (self.lastGravTrace.HitPos - (self.lastGravTrace.HitNormal * (self:BoundingRadius() * 0.5))) - self:GetPos()
-- calculate velocity based on 9.8 ft per sec ( 16 units = 1 foot) (16 * 9.8) * 60 = 9408
local gravVel = (gravDiff:GetNormal() * (9408 * physDelta))
-- apply gravity
phys:AddVelocity(gravVel * physDelta)
end
[/lua]
any help is always appreciated.[/QUOTE]
Is 600 (the usual gravity number) a representation of gravitational acceleration or velocity in Gmod units?
This is a bit tough. I'm trying to think of how you're going about this which is weird because I would've done it a different way (that probably would have failed).
If you know the displacement, the gravitational acceleration (which I'm assuming is 600 gmodunits/s^2), and the time you can use this equation to find the initial velocity which you can treat as a constant I think (unless you want to get all jiggy with the kinematics equations and make it ultra-realistic):
d = v0 * t + 0.5*a*t^2
d = +/- gravDiff depending on orientation
t = physDelta
a = +/- 600 depending on orientation
and then just solve for v0.
Honestly just throwing things out there because what you're doing looks really cool and I want you to be able to fix this.
[QUOTE=Mrkrabz;34592454]Whats [lua]function yourtable:yourfunc()[/lua]?
Edit: Fixed it anyway, just removed that.[/QUOTE]
Okay well it seems to not work, I've tried printing the table and it comes back blank. the files do exist, and have my steamID in, however it's not working. It's always returning to guest.
How do i fix the attempt to call "PaintPanel" (a nil value) thing. I tried removing two extra lines of code i forgot to remove since it wasn't needed because of the paint panel, i tried adding this ";" at the end of it and nothing works
[QUOTE=confinedUser;34593806]How do i fix the attempt to call "PaintPanel" (a nil value) thing. I tried removing two extra lines of code i forgot to remove since it wasn't needed because of the paint panel, i tried adding this ";" at the end of it and nothing works[/QUOTE]
Line 77:
margin = 35[B],[/B]
[QUOTE=Mrkrabz;34593660]Okay well it seems to not work, I've tried printing the table and it comes back blank. the files do exist, and have my steamID in, however it's not working. It's always returning to guest.[/QUOTE]
Do you have those functions defined outside of the function your calling it from?
Do you have the text files parsed as I had it?
Are the text files in the right directory?
[QUOTE=pennerlord;34593957]Line 77:
margin = 35[B],[/B][/QUOTE]
i added that it fixed my previous issue but created this one.
[QUOTE=marvincmarvin;34594017]Do you have those functions defined outside of the function your calling it from?
Do you have the text files parsed as I had it?
Are the text files in the right directory?[/QUOTE]
No,
Yes,
Yes.
[QUOTE=pennerlord;34591322]Put your DCollapsibleCategorys into a [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcc5c.html?title=DPanelList"]DPanelList[/URL]. Tested it and it works fine.[/QUOTE]
Cheers
[QUOTE=confinedUser;34593806]How do i fix the attempt to call "PaintPanel" (a nil value) thing. I tried removing two extra lines of code i forgot to remove since it wasn't needed because of the paint panel, i tried adding this ";" at the end of it and nothing works[/QUOTE]
[lua]function good_hud:paintPanel (x, y, w, h, colors )[/lua]
Your paintPanel has a lower case P. You're trying to call PaintPanel with capital P.
Does anyone know how to code for OpenAura? Like items, factions, and weapons to put in? I find this system one of the most hardest to cooperate with but it is really worth it once you got some Passive RPers in there.
[QUOTE=wizardsbane;34593635]Is 600 (the usual gravity number) a representation of gravitational acceleration or velocity in Gmod units?
This is a bit tough. I'm trying to think of how you're going about this which is weird because I would've done it a different way (that probably would have failed).
If you know the displacement, the gravitational acceleration (which I'm assuming is 600 gmodunits/s^2), and the time you can use this equation to find the initial velocity which you can treat as a constant I think (unless you want to get all jiggy with the kinematics equations and make it ultra-realistic):
d = v0 * t + 0.5*a*t^2
d = +/- gravDiff depending on orientation
t = physDelta
a = +/- 600 depending on orientation
and then just solve for v0.
Honestly just throwing things out there because what you're doing looks really cool and I want you to be able to fix this.[/QUOTE]
Well thanks for trying, but either i don't understand the equation or it's just not working for me. I'll keep trying, a class in physics wouldn't hurt either i suppose.
[QUOTE=Fantym420;34595510]Well thanks for trying, but either i don't understand the equation or it's just not working for me. I'll keep trying, a class in physics wouldn't hurt either i suppose.[/QUOTE]
You're probably doing something right but I'm just not seeing it due to my limited knowledge of physics and so that concept may very well be unnecessary or incompatible with how you implemented gravity. Like I said, just throwing stuff out there that might work or be useful.
[QUOTE=raBBish;34594963][lua]function good_hud:paintPanel (x, y, w, h, colors )[/lua]
Your paintPanel has a lower case P. You're trying to call PaintPanel with capital P.[/QUOTE]
oops haha silly me thanks
[editline]7th February 2012[/editline]
ok fixed it still giving me this bullshit. I'm going to take a closer look at it when im not tired. I might be missing something that needs to be fixed. If not I'll come back
ok I can't seem to find the problem this is the last time I use the gmod lua wiki for tutorials as it's very horrible.
How would I make an if(LocalPlayer() is driving a vehicle) please?
Sorry, you need to Log In to post a reply to this thread.