Requesting a little bit of help

(I am NOT asking somebody to fix this for me, more to point me in the right direction as I REALLY want to learn and not be spoon fed)

I’m trying to learn lua for gmod so I can make some small addons that I need for my server that don’t seem to exist. I have previously coded before so I am not starting from scratch.

Instead of learning the basics and working up, I personally find it easier to modify previous code to my liking then learn from that.
My current “project” is trying to fix Umaps for ulx but I have hit a brick wall.

The error is this:

 lua/ulib/modules/umaps/cl_init.lua:17: attempt to perform arithmetic on local 's' (a nil value)

This is:

function UMaps.formatTime( s )
if s == false then end
	local m = math.floor( s / 60 ) // This is line 17 thats causing problems.

(Ignore the if s ==, that was a previous attempt of mine that failed, but doesnt cause any errors so I left it there for now)

What I get from the error is S is not getting an integer assigned to it, so trying to divide nill by 60 obviously cant be done.

Now I looked into something else that used *.formatTime( * ) and they seem to use the exact same format with no errors. What exactly is this doing? Is it creating a timer called S OR is it getting S from another predefined function / variable called S?

Any help would be greatly appreciated as I really need to learn this, its been way too long.


if s == false then end


if !s then return end

The return cuts the function off short, that way the code underneath cannot run without ‘s’ being valid and not null.

Thanks, but im pretty sure this is just going to create another problem :frowning:

if it cant run the code underneath, the timer or clock or w/e it is wont run.

What would be really really handy is if someone can explain to me what this does

function UMaps.formatTime( s )

I have researched untill im pulling my hair out but I just cant find any info. the closest I came was,

*.formatTime( string , format ) but I still dont understand what or where S is comming from. it must be comming from somewhere otherwise it cant do s / 60.

Any help on that would be fantastic :smiley:

Il also try !s in a sec, just to double check.


Just as I feared.
draw.SimpleText( UMaps.formatTime( UMaps.timeleft ), “UMapsAlert”, ( ScrW() / 2 ), ( ScrH() / 4 ) + ( ScrH() / 12 ), Color( 255, 255, 255, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )

Now its not getting a string because we canceled that part of the script.