Please login or register.

Xuras

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

Chaotic Cow

  • Guest
Chaotic cow's "I need help with Lua" thread
« on: 26 December, 2008, 21:16:09 pm »
So this is my official thread for posting my problems and questions. This is so I don't go posting 50 threads on each problem I have.

1. My HUD displays server name, but if the server name is ~37 characters long(Including spaces) it just cuts off. Anyway to legnthen it?

2. Is it possible to get Total In-game time on servers. Like Utime.

3. how in the world do I get my HUD to do a drop down effect to display stuff in that? (Think Utime drop down when you target someone.

and more questions and problems when they come.

Offline Pollyzoid

  • Regular
  • *
  • Posts: 479
  • Cookies: 8
  • Hallo thar ^.^
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #1 on: 26 December, 2008, 22:13:58 pm »
So this is my official thread for posting my problems and questions. This is so I don't go posting 50 threads on each problem I have.

1. My HUD displays server name, but if the server name is ~37 characters long(Including spaces) it just cuts off. Anyway to legnthen it?

2. Is it possible to get Total In-game time on servers. Like Utime.

3. how in the world do I get my HUD to do a drop down effect to display stuff in that? (Think Utime drop down when you target someone.

and more questions and problems when they come.

Kay, here it goes...

1. AFAIK, the server's name is limited to about that anyways, I'll check and update later

2. Not without writing an addonthingie

3. UTime: It has two rounded boxes ( draw.RoundedBox( blarguments ) ), one smaller which is the box inside which doesn't change it's size.
Bigger box changes size to taller if a trace from player's eyes hit a player in a certain range.

There, answers :hurrrr:

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #2 on: 26 December, 2008, 22:47:08 pm »
1. well I counted on my HUD is around that i think. lol

2. i wouldn't mind doing that. i don't know how to start though.

3. Explain that one a little more...

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #3 on: 27 December, 2008, 04:39:12 am »
Sorry for Double Post.

Error Time!

I am trying to create a ping meter.

but I get the Error  "Expected Symbo "=" near "<"

I tried =< and <=

I don't know what it wants.


   Cping < 100 then
   draw.RoundedBox(2, 500, 5, 10, 5, Color(0,255,0,255))
   draw.RoundedBox(2, 500, 12, 10, 5, Color(0,255,0,255))
   draw.RoundedBox(2, 500, 20, 10, 5, Color(0,255,0,255))
   
   Cping >= 130 then
      draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
   draw.RoundedBox(2, 500, 12, 10, 5, Color(255,255,0,255))
   draw.RoundedBox(2, 500, 20, 10, 5, Color(255,255,0,255))
   
   Cping >= 180 then
      draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
   draw.RoundedBox(2, 500, 12, 10, 5, Color(0,0,0,255))
   draw.RoundedBox(2, 500, 20, 10, 5, Color(255,0,0,255))

Paper-Burn

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #4 on: 27 December, 2008, 09:11:58 am »
Well, I must admit, I don't know a shit about lua, but doesn't it wants you to delete it?
"UNexpected symbol"

Christoffer395

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #5 on: 27 December, 2008, 09:28:38 am »
Cping (< 100) then
   draw.RoundedBox(2, 500, 5, 10, 5, Color(0,255,0,255))
   draw.RoundedBox(2, 500, 12, 10, 5, Color(0,255,0,255))
   draw.RoundedBox(2, 500, 20, 10, 5, Color(0,255,0,255))
   
   Cping (>= 130) then
      draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
   draw.RoundedBox(2, 500, 12, 10, 5, Color(255,255,0,255))
   draw.RoundedBox(2, 500, 20, 10, 5, Color(255,255,0,255))
   
   Cping (>= 180) then
      draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
   draw.RoundedBox(2, 500, 12, 10, 5, Color(0,0,0,255))
   draw.RoundedBox(2, 500, 20, 10, 5, Color(255,0,0,255))

I guess so far, just recently starting to learn about the lua language

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 #6 on: 27 December, 2008, 12:04:54 pm »
If you've got brackets around it you need to include the Variable too, so it'll be

(Cping < 100) then
blah


Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #7 on: 27 December, 2008, 18:18:22 pm »
If you've got brackets around it you need to include the Variable too, so it'll be

(Cping < 100) then
blah
Those arn't brackets! =P

But I will not try with Parentheses!

I think it works....my HUD


I decieded to get rid of the Ping.
« Last Edit: 27 December, 2008, 20:48:57 pm by Chaotic Cow »

Offline Pollyzoid

  • Regular
  • *
  • Posts: 479
  • Cookies: 8
  • Hallo thar ^.^
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #8 on: 27 December, 2008, 23:35:38 pm »
Well, correct way is this:
Code: [Select]
if Cping < 100 then
  draw.RoundedBox(2, 500, 5, 10, 5, Color(0,255,0,255))
  draw.RoundedBox(2, 500, 12, 10, 5, Color(0,255,0,255))
  draw.RoundedBox(2, 500, 20, 10, 5, Color(0,255,0,255))
end
if Cping >= 130 then
  draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
  draw.RoundedBox(2, 500, 12, 10, 5, Color(255,255,0,255))
  draw.RoundedBox(2, 500, 20, 10, 5, Color(255,255,0,255))
end
if Cping >= 180 then
  draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
  draw.RoundedBox(2, 500, 12, 10, 5, Color(0,0,0,255))
  draw.RoundedBox(2, 500, 20, 10, 5, Color(255,0,0,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 #9 on: 28 December, 2008, 01:24:05 am »
Yarr, end it...

I was thinking of { and }, but obviously LUA doesn't use that.


Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #10 on: 28 December, 2008, 02:38:42 am »
Yeah I actually got it working..except the part where the ping bars disappear after above 101ping but I found out Lua Ping is different and isn't the Full Ping that net_graph shows.

So...eh.

Offline Pollyzoid

  • Regular
  • *
  • Posts: 479
  • Cookies: 8
  • Hallo thar ^.^
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #11 on: 28 December, 2008, 04:11:08 am »
Umm... the bar dissappearing is because of the script

if Cping < 100 then blah
Draws boxes if the ping is less than 100

Next is if Cping >= 130 then
That draws boxes if ping is over or equal to 130

You have nothing between those two, making it draw nothing

Chaotic Cow

  • Guest
Re: Chaotic cow's "I need help with Lua" thread
« Reply #12 on: 28 December, 2008, 04:53:23 am »
Umm... the bar dissappearing is because of the script

if Cping < 100 then blah
Draws boxes if the ping is less than 100

Next is if Cping >= 130 then
That draws boxes if ping is over or equal to 130

You have nothing between those two, making it draw nothing


Of course I saw that and made it "101" and it didn't work still.

Offline Pollyzoid

  • Regular
  • *
  • Posts: 479
  • Cookies: 8
  • Hallo thar ^.^
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #13 on: 28 December, 2008, 12:19:29 pm »
Try switching

if Cping < 100 then

to

if Cping < 130 then

Should do the trick

Online Donkie

  • Not l33t anymore
  • Almost lives here
  • ***
  • Posts: 1,708
  • Cookies: 10
  • Victory is near! Make the last push!
    • View Profile
Re: Chaotic cow's "I need help with Lua" thread
« Reply #14 on: 28 December, 2008, 12:41:39 pm »
I dont know a crap about lua but i think i know what the code cow showed means:
Code: [Select]
if Cping < 100 then
  draw.RoundedBox(2, 500, 5, 10, 5, Color(0,255,0,255))
  draw.RoundedBox(2, 500, 12, 10, 5, Color(0,255,0,255))
  draw.RoundedBox(2, 500, 20, 10, 5, Color(0,255,0,255))
end
if Cping >= 130 then
  draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
  draw.RoundedBox(2, 500, 12, 10, 5, Color(255,255,0,255))
  draw.RoundedBox(2, 500, 20, 10, 5, Color(255,255,0,255))
end
if Cping >= 180 then
  draw.RoundedBox(2, 500, 5, 10, 5, Color(0,0,0,255))
  draw.RoundedBox(2, 500, 12, 10, 5, Color(0,0,0,255))
  draw.RoundedBox(2, 500, 20, 10, 5, Color(255,0,0,255))
end
These numbers: 2, 500, 20, 10, 5 is coordinates?
These numbers are coulors im pretty sure (R G B A) (255,0,0,255)
So if Ping is greather than or equals to 180 then it will draw a roundedbox at (2, 500, 5, 10, 5, Color(0,0,0,255)),
(2, 500, 12, 10, 5, Color(0,0,0,255)), (2, 500, 20, 10, 5, Color(255,0,0,255)) with the following colours?

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*

 


SimplePortal 2.3.2 © 2008-2010, SimplePortal