Please login or register.

Xuras

Author Topic: Chaotic cow's "I need help with Lua" thread  (Read 2005 times)

Offline Pollyzoid

  • Regular
  • *
  • Posts: 479
  • Cookies: 8
  • Hallo thar ^.^
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #15 on: 28 December, 2008, 14:06:00 pm »
Nope, it's

draw.RoundedBox( Number Bordersize, Number X, Number Y, Number Width, Number Height, Table Colour )

Offline Donkie

  • Not l33t anymore
  • Almost lives here
  • ***
  • Posts: 1,710
  • Cookies: 10
  • Victory is near! Make the last push!
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #16 on: 28 December, 2008, 15:20:51 pm »
oh :D

I got alot to brag about ^
Code: [Select]
22:25 - Donkie: go it
22:25 - Donkie: got tit
22:25 - Donkie: aergaergaer
22:25 - Donkie: got it*

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #17 on: 28 December, 2008, 16:51:11 pm »
Actually it's "Roundness of the corners" and not "Border Size"

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #18 on: 28 December, 2008, 21:12:34 pm »
New Problem...


Trying to get Target name,health,team, and anything else to pop up in the center of the screen.



function targethud
local client = LocalPlayer
if client:Alive() then

 local pos = self.Owner:GetShootPos()
 local ang = self.Owner:GetAimVector()
 local tracedata = {}
 tracedata.start = pos
 tracedata.endpos = pos+(ang*100)
 tracedata.filter = self.Owner
 local trace = util.TraceLine(tracedata)
 if trace.HitNonWorld then
    target = trace.Entity
   
   local TarHealth = Entity.Health()
   
   draw.SimpleText(TarHealth,"ScoreboardText", 950, 7, Color(255,255,255,255))
   
 end 

Offline thingshappen

  • Founder
  • Global Administrator
  • Lives here
  • *****
  • Posts: 3,030
  • Cookies: 1337
  • GENTLE MANNE of LEISURE
    • STEAM_0:1:15987148
    • View Profile
    • You're on it!
Re: Chaotic cow's "I need help with Lua" thread
« Reply #19 on: 28 December, 2008, 21:19:44 pm »
Looks like you forgot an end

You have 2 ifs and only 1 end.


Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #20 on: 28 December, 2008, 21:40:23 pm »
Looks like you forgot an end

You have 2 ifs and only 1 end.

can you explain that?

Still doesn't work.

Offline Pollyzoid

  • Regular
  • *
  • Posts: 479
  • Cookies: 8
  • Hallo thar ^.^
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #21 on: 28 December, 2008, 21:49:27 pm »
You are using couple variable names that do not exist
Also, use code tags in future :P

Fixed:
Code: [Select]
function targethud() --Don't forget the brackets
  local client = LocalPlayer()  --LocalPlayer() is a function
  if client:Alive() then
    local pos = client:GetShootPos() --self.Owner does not exist, self is only used in meta functions
    local ang = client:GetAimVector()
    local tracedata = {}
    tracedata.start = pos
    tracedata.endpos = pos+(ang*500) --Short distance so I increased it a bit
    tracedata.filter = client 
    local trace = util.TraceLine(tracedata)
    if trace.HitNonWorld and trace.Entity and trace.Entity:IsValid() and trace.Entity:IsPlayer() then --Pile of checks, just to be sure
      target = trace.Entity

      local TarHealth = target:Health() --"Entity" was not defined anywhere

      draw.SimpleText(TarHealth,"ScoreboardText", 950, 7, Color(255,255,255,255)) --I suggest you use font "TargetID" instead of this one
    end
  end
end

Also, for the coordinates...
To make it more compatible for more resolutions, use multipliers and dividers with ScrW() and ScrH(), which both return game window's width and height, respectively...
ScrW()/2 would be half of the screen

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #22 on: 28 December, 2008, 22:13:10 pm »
You are using couple variable names that do not exist
Also, use code tags in future :P

Fixed:
Code: [Select]
function targethud() --Don't forget the brackets
  local client = LocalPlayer()  --LocalPlayer() is a function
  if client:Alive() then
    local pos = client:GetShootPos() --self.Owner does not exist, self is only used in meta functions
    local ang = client:GetAimVector()
    local tracedata = {}
    tracedata.start = pos
    tracedata.endpos = pos+(ang*500) --Short distance so I increased it a bit
    tracedata.filter = client 
    local trace = util.TraceLine(tracedata)
    if trace.HitNonWorld and trace.Entity and trace.Entity:IsValid() and trace.Entity:IsPlayer() then --Pile of checks, just to be sure
      target = trace.Entity

      local TarHealth = target:Health() --"Entity" was not defined anywhere

      draw.SimpleText(TarHealth,"ScoreboardText", 950, 7, Color(255,255,255,255)) --I suggest you use font "TargetID" instead of this one
    end
  end
end

Also, for the coordinates...
To make it more compatible for more resolutions, use multipliers and dividers with ScrW() and ScrH(), which both return game window's width and height, respectively...
ScrW()/2 would be half of the screen


Weird...still doesn't work.

Also would the ScrH -ScrW fix all my other stuff like health and time to fit? On Bigger resolutions/etc

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #23 on: 12 January, 2009, 16:30:04 pm »
How do I make  Health Bars? =[

Offline Dotmister

  • Co-Founder
  • Global Administrator
  • Almost lives here
  • *****
  • Posts: 1,002
  • Cookies: 35
    • STEAM_0:0:12123040
    • View Profile
    • Adamncasey.co.uk
Re: Chaotic cow's "I need help with Lua" thread
« Reply #24 on: 13 January, 2009, 18:27:09 pm »
using rounded boxes, or boxes. One for the actual bar, and one for where the bar would be if it was 100% (usually much darker)

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #25 on: 22 January, 2009, 21:17:26 pm »
I'm back! Trying out some Derma.




autorun/client/cowADMIN.lua:8: function arguments expected near 'then'


function cowADMIN()
local client = LocalPlayer()
if client:Alive then

 local PropertySheet = vgui.Create( "DPropertySheet" )
 PropertySheet:SetParent( DermaPanel )
 PropertySheet:SetPos( 5, 30 )
 PropertySheet:SetSize( 340, 315 )
   
 local PlayerMenu = vgui.Create("DCollapsibleCategory", DermaPanel)
 PlayerMenu:SetPos( 25,50 )
 PlayerMenu:SetSize( 200, 50 ) // Keep the second number at 50
 PlayerMenu:SetExpanded( 0 ) // Expanded when popped up
 PlayerMenu:SetLabel( "Our Collapsible Category" )
   
 CategoryList = vgui.Create( "DPanelList" )
 CategoryList:SetAutoSize( true )
 CategoryList:SetSpacing( 5 )
 CategoryList:EnableHorizontal( false )
 CategoryList:EnableVerticalScrollbar( true )
     
   
 PropertySheet:AddSheet( "Some Menu", PlayerMenu, "gui/silkicons/user", false, false, "Player Menu" )


end
end

hook.Add("HUDPaint", "cowADMIN", cowADMIN)

Offline thingshappen

  • Founder
  • Global Administrator
  • Lives here
  • *****
  • Posts: 3,030
  • Cookies: 1337
  • GENTLE MANNE of LEISURE
    • STEAM_0:1:15987148
    • View Profile
    • You're on it!
Re: Chaotic cow's "I need help with Lua" thread
« Reply #26 on: 22 January, 2009, 21:42:11 pm »
from
Code: [Select]
if client:Alive
to
Code: [Select]
if client:Alive()


Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #27 on: 22 January, 2009, 22:38:04 pm »
EDIT:  For some reason it just started working. =\

I think it was because It was "DlistView" and not "DListView"




autorun/client/cowADMIN.lua:28: attempt to index local 'SheetItemOne' (a nil value)




function cowADMIN()
local client = LocalPlayer()
if client:Alive() then

//--Frame
         local frame1 = vgui.Create("DFrame")
   
         frame1:SetPos(300,200)
         frame1:SetSize(500,500)
         frame1:SetTitle("cowADMIN")
         frame1:MakePopup()
       frame1:ShowCloseButton( true ) // Show the close button?
      
       //--Tab Frame
        local PropertySheet = vgui.Create( "DPropertySheet" )
 PropertySheet:SetParent( frame1 )
 PropertySheet:SetPos( 10, 30 )
 PropertySheet:SetSize( 485, 460 )
   
   //--Admin Tab
 local SheetItemOne = vgui.Create( "DlistView" )
 
 SheetItemOne:SetParent(frame1)
 SheetItemOne:SetPos(300, 200)
 SheetItemOne:SetSize(450, 450)
 SheetItemOne:SetMultiSelect(false)
 SheetItemOne:AddColumn("Name") // Add column
 SheetItemOne:AddColumn("Amount of kills")
   
   //--Tab 2
 local SheetItemTwo = vgui.Create( "DCheckBoxLabel" , CategoryContentTwo )
 SheetItemTwo:SetText( "Use SENTs?" )
 SheetItemTwo:SetConVar( "some_convar" )
 SheetItemTwo:SetValue( 1 )
 SheetItemTwo:SizeToContents()
   
   
   //--Tab Name,etc
 PropertySheet:AddSheet( "Admin Menu", SheetItemOne, "gui/silkicons/user", false, false, "Admin Commands" )
 PropertySheet:AddSheet( "Super Menu", SheetItemTwo, "gui/silkicons/group", false, false, "Can I haz meh cheezburger now?" ) 
      
      
      
      
 end
end
 concommand.Add("cowADMIN", cowADMIN)
« Last Edit: 22 January, 2009, 22:41:36 pm by Chaotic Cow »

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #28 on: 22 January, 2009, 22:59:42 pm »
for k,v in pairs(player.GetAll()) do
     SheetItemOne:AddLine(v:Nick(),v:Frags()) // Add lines
 end


How would I make that display "Team/Rank" instead of "Frags"?

Offline thingshappen

  • Founder
  • Global Administrator
  • Lives here
  • *****
  • Posts: 3,030
  • Cookies: 1337
  • GENTLE MANNE of LEISURE
    • STEAM_0:1:15987148
    • View Profile
    • You're on it!
Re: Chaotic cow's "I need help with Lua" thread
« Reply #29 on: 22 January, 2009, 23:55:48 pm »
I'm prolly missing something really vital here, but I looked it up.

Code: [Select]
for k,v in pairs(player.GetAll()) do
   SheetItemOne:AddLine(v:Nick(),v:Team()) // Add lines
 end

GetAll returns this table

And according to this it should return the team.


 


SimplePortal 2.3.2 © 2008-2010, SimplePortal