How I can integrate math.Round into the RunConsoleCommand to get the value (3) in a round number ?
[IMG]http://img204.imageshack.us/img204/5462/mathroundwse.png[/IMG]
[lua]local DermaLView = vgui.Create("DListView")
DermaLView:SetParent(DermaTest)
DermaLView:SetPos( 20, 55 )
DermaLView:SetSize( 270, 100 )
DermaLView:SetMultiSelect(false)
DermaLView:AddColumn(" Name ") -- Add Column
DermaLView:AddColumn(" # Kills ")
DermaLView:AddColumn(" # 1st Clip ")
DermaLView:AddColumn(" # Alt. Clip ")
DermaLView.OnRowSelected = function(panel , line)
RunConsoleCommand("Say" , DermaLView:GetLine(line):GetValue(3))
end
for k,v in pairs(player.GetAll()) do
DermaLView:AddLine(v:Nick(),v:Frags(),v:GetActiveWeapon():Clip1(),v:GetAmmoCount(v:GetActiveWeapon():GetSecondaryAmmoType())) -- Add Lines
end[/lua]
math.Round(DermaLView:GetLine(line):GetValue(3))
Not working I tried like that
[lua] RunConsoleCommand("Say" , math.Round(DermaLView:GetLine(line):GetValue(3)) [/lua]
[code]Unknown Command: 'DermaTesting'[/code]
You forgot a ")".
[code]
autorun/client/test.lua:72: 'end' expected (to close 'function' at line 1) near '<eof>'
Registering gamemode 'sandbox' derived from 'base'
Sending 267 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
Redownloading all lightmaps
Unknown Command: 'DermaTesting'[/code]
[lua]function DermaTest()
local DermaTest = vgui.Create( "DFrame" )
DermaTest:SetPos( 200, 200 )
DermaTest:SetSize( 350, 300 )
DermaTest:SetTitle( "Weapons Suite" )
DermaTest:SetVisible( true )
DermaTest:MakePopup()
local DPress = vgui.Create( "DButton", DermaTest )
DPress:SetSize( 146, 20 );
DPress:SetPos( 19, 30 );
DPress:SetText( "Spawn Weapon" );
DPress.Paint = function() -- The Paint Function
surface.SetDrawColor( 255, 255, 255, 40 )
surface.DrawRect( 2, 2, DPress:GetWide(), DPress:GetTall() )
DPress.OnMousePressed = function()
DPress.Paint = function() -- The Paint Function
surface.SetDrawColor( 0, 102, 153, 180 )
surface.DrawRect( 2, 2, DPress:GetWide(), DPress:GetTall() )
end
DPress.OnMouseReleased = function()
DPress.Paint = function() -- The Paint Function
surface.SetDrawColor( 255, 255, 255, 40 )
surface.DrawRect( 2, 2, DPress:GetWide(), DPress:GetTall() )
end
end
end
local DermaLView = vgui.Create("DListView")
DermaLView:SetParent(DermaTest)
DermaLView:SetPos( 20, 55 )
DermaLView:SetSize( 270, 100 )
DermaLView:SetMultiSelect(false)
DermaLView:AddColumn(" Name ") -- Add Column
DermaLView:AddColumn(" # Kills ")
DermaLView:AddColumn(" # 1st Clip ")
DermaLView:AddColumn(" # Alt. Clip ")
DermaLView.OnRowSelected = function(panel , line)
RunConsoleCommand("Say" , math.Round(DermaLView:GetLine(line):GetValue(3)))
for k,v in pairs(player.GetAll()) do
DermaLView:AddLine(v:Nick(),v:Frags(),v:GetActiveWeapon():Clip1(),v:GetAmmoCount(v:GetActiveWeapon():GetSecondaryAmmoType())) -- Add Lines
end
function DermaTest:Paint() -- Paint The DermaFrame ..
surface.SetDrawColor( 0, 0, 0, 150 )
surface.DrawRect( 1, 1, DermaTest:GetWide(), DermaTest:GetTall() )
surface.SetDrawColor( 0, 0, 0, 200 ) -- The Foreground Square
surface.DrawRect( 1, 22, DermaTest:GetWide(), DermaTest:GetTall() - 26)
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 1, 1, DermaTest:GetWide(), 3 )
surface.DrawRect( 1, 20, DermaTest:GetWide(), 1 )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 1, 297, DermaTest:GetWide(), 3 )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawRect( 1, 1, 3, DermaTest:GetTall() )
surface.SetDrawColor( 255, 255, 255, 255 ) -- The Right Line
surface.DrawRect( 347, 1, 3, DermaTest:GetTall() )
end
end
end
concommand.Add("DermaTesting", DermaTest)[/lua]
Although I respect anyone's personal programming style, I just wanted to say I got lost in your code due to unusual indentation. You also probably are missing "end"s and ")"s.
Thanks ok I'm trying to find the "end" or ")" missing.
But have you a suggestion how I can code it properly because I'm starting learning Lua but I'm not sure about this.
It's just that your indentation is unusual. I would assume you didn't learn a markup language before learning Lua (usually helps, unless your a quick learner).
[lua]local function HelloWorld()
--indentation of four spaces, one tab is much more widely used
end
local function HelloWorld2()
local function a()
--defining a function within a function
end
local function b()
--defining a second function within a function
end
end
[/lua]
thanks for the tips, when I have a more of time to spent I just try to read the basic lua, maybe tonight a the work :)
Ok math.Round is ok but it's done no result.
I have always (in example) -1.00 and I want it in -1
[lua]local DermaLView = vgui.Create("DListView")
DermaLView:SetParent(DermaTest)
DermaLView:SetPos( 20, 55 )
DermaLView:SetSize( 270, 100 )
DermaLView:SetMultiSelect(false)
DermaLView:AddColumn(" Name ") -- Add Column
DermaLView:AddColumn(" # Kills ")
DermaLView:AddColumn(" # 1st Clip ")
DermaLView:AddColumn(" # Alt. Clip ")
DermaLView.OnRowSelected = function(panel , line)
RunConsoleCommand("Say" , math.Round(DermaLView:GetLine(line):GetValue(3)))
end[/lua]
Sorry, you need to Log In to post a reply to this thread.