Cider HUD date

Okay i’m trying to make this clock/date shower for cider but before i destroy whole my dev server with this i just wanted to check if it was okay.

If anything is wrong please help me.
cl_init.lua
[LUA]
local ply = LocalPlayer()
local time = os.date ()
function hud()
draw.RoundedBox(0, 5, ScrH() - 15 - 20, date, 15, Color(255,0,0,255))
draw.SimpleText(date, “default”, 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

it’s not going to be a part of where the health bar and such stuff is but i’ll edit the position later and the design.

Look at your draw.SimpleText call. You’re drawing the variable “date”, and I think you want to use “os.date()”.

Now i have done it like this i’m going to test it.

[LUA]
local ply = LocalPlayer()
local time = os.date ()
function hud()
draw.RoundedBox(0, 5, ScrH() - 15 - 20, date, 15, Color(255,0,0,255))
draw.SimpleText(os.date, “default”, 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

EDIT: it did not work.
[LUA]
Couldn’t include file ‘cider\gamemode\cl_init.lua’ (File not found)
[cpp]
There was a problem opening the gamemode file ‘cider/gamemode/cl_init.lua’
[/LUA]

all user messages are un-handled too.

os.date is a function, so you need the parentheses. os.date()

Take these lines out of the code:
[lua]local ply = LocalPlayer()
local time = os.date ()[/lua]

Because ply is most likely set somewhere where the LocalPlayer hasn’t been created yet, and you’re not using them anyways.

Now using
[LUA]
function hud()
draw.RoundedBox(0, 5, ScrH() - 15 - 20, os.date(), 15, Color(255,0,0,255))
draw.SimpleText(os.date(), “default”, 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

oh wait that end is not supposed to be there.

I’ll see if it works.

EDIT: did not work.

I don’t think it’s the end it’s the parentheses.

[gamemodes\cider\gamemode\cl_init.lua:507] unexpected symbol near ‘,’
[cpp]
There was a problem opening the gamemode file ‘cider/gamemode/cl_init.lua’

Now using
[LUA]
function hud()
draw.RoundedBox(0, 5, ScrH() - 15 - 20, (os.date), 15, Color(255,0,0,255))
draw.SimpleText((os.date), “default”, 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

EDIT: did not work.

[gamemodes\cider\gamemode\cl_init.lua:501] attempt to concatenate global ‘date’ (a nil value)(Hook: HUDPaint)

Now using
[LUA]
function hud()
draw.RoundedBox(0, 5, ScrH() - 15 - 20, (os.date), 15, Color(255,0,0,255))
draw.SimpleText((os.date), “default”, 10, ScrH() - 15 - 40, Color(255,255,255,255))
hud:FadeIn()
hud:DrawGenericContentbox(
/*Text */ os.date("%D:%H:%M:%S")
/*Subtxt */ ,""
/*Txtcol */ ,nil
/Stxtcol/ ,nil
/*FontN */ ,1
)
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

EDIT: Did not work

Now using this again.
[LUA]
function hud()
draw.RoundedBox(0, 5, ScrH() - 15 - 20, os.date(), 15, Color(255,0,0,255))
draw.SimpleText(os.date(), “default”, 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

[gamemodes\cider\gamemode\cl_init.lua:501] attempt to concatenate global ‘date’ (a nil value)(Hook: HUDPaint)
Same error.

Thats because you have the draw.RoundedBox syntax incorrect

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

However instead of drawing a box and drawing text, I would just draw a word box which will create a rounded box with the text inside of it and perfectly sized

[lua]function hud()
draw.WordBox( 8, ScrW() / 2, ScrH() / 2, os.date(), “Default”, Color(255,0,0,255), Color(255,255,255,255) )
end
hook.Add(“HUDPaint”, “HUDTime”, hud)[/lua]

I’d recommend checking out the syntax for wordboxes on the gmod wiki and then editing the numbers that I put to your liking

Thanks, i’ll try that.

Same errors as before and i was using:
[LUA]
function hud()
draw.WordBox( 8, ScrW() / 2, ScrH() / 2, os.date(), “Default”, Color(255,0,0,255), Color(255,255,255,255) )
end
hook.Add(“HUDPaint”, “HUDTime”, hud)
[/LUA]

Show the line that errors…

[gamemodes\cider\gamemode\cl_init.lua:507] attempt to index global ‘endhook’ (a nil value)
[cpp]
There was a problem opening the gamemode file ‘cider/gamemode/cl_init.lua’
[LUA]
endhook.Add(“HUDPaint”, “HUDTime”, hud);
[/LUA]

I have no idea, but I always end up getting hideous errors when I set LocalPlayer to a variable.

Fixed

It did not work now it can’t include the file or open it, it says.
Do you even know if i can use it here?

Using this code:

Cl_init.lua
[LUA]
function hud() draw.WordBox( 8, ScrW() / 2, ScrH() / 2, os.date(), “Default”, Color(255,0,0,255), Color(255,255,255,255) );
end;
hook.Add(“HUDPaint”, “HUDTime”, hud);
[/LUA]

Edited it to this:

[cider\gamemode\cl_init.lua:501] attempt to concatenate global ‘date’ (a nil value)(Hook: HUDPaint)

[LUA]
function hud()
draw.WordBox( 8, 5, ScrH() / 2, "Date: "…os.date, “ScoreboardText”, Color(255,100,100,200), Color(255,255,255,255))
end
hook.Add( “HUDDatePaint”, “HUDTime”, hud )
[/LUA]

Christian, you are either a very good troll or not at all willing to put time into learning Lua and understanding where you’re going wrong. You actually keep changing other stuff that you don’t understand whenever someone helps you. Like you changed “HUDPaint” to “HUDDatePaint”.

[lua]
hook.Add(“HUDPaint”, “HUDTime”, function()
draw.WordBox( 8, 5, ScrH() / 2, "Date: "…os.date(), “ScoreboardText”, Color(255, 100, 100, 200), Color(255, 255, 255, 255) );
end);
[/lua]

Just use this code, and then if you’re genuinly interested in learning Lua or making modifications like this go to http://lua.org/pil/ and read thouroughly.

Okay i got it :frowning:
and i’m not a troll and i’m sorry if i have done something inappropriate.
I just think i’m gonna rate you all lua helpers if you don’t mind.

EDIT: I have read some of it.
I’m at chapter 3.6 and by the way i have also tried to read it before i just gave up, but i’m going to bed now i’ll read some more after school tomorrow, for more updates keep checking this thread! IF THIS IS AGAINST FORUM RULES PLEASE NOTIFY ME.

EDIT: Reached 5.1 continuing later.

http://lua.org/pil/ isn’t specifically for GMod Lua, it covers the entire language.
I myself never found e-books to be useful, since they use terms that I often don’t quite understand, and since I never seem to grasp much from it. The best way to learn something is through experience, in my opinion.