Sign in to follow this  
  • entries
    557
  • comments
    1237
  • views
    421073

Untitled

Sign in to follow this  
Evil Steve

42 views

I've been moving my code more and more into Lua. Instead of having the main user loop in C++ and call Lua functions to check usernames, and so on, I now call a script "Tick" function once for each user. More scriptability = good.

I also found out that I'm using a 4 year old version of Lua (v5.0), which is missing some rather useful functions - like the ability to convert a string to a number. The following code gives me an error:

function HandleNewUser(user)
ip = GetConnectionIP(user);
expires = GetDBValue("ipbans", ip)
if expires ~= "" then
if expires <= GetTime() then
SetDBValue("ipbans", ip, "");
else
-- Snip


Saying that it can't compare a string to a number (GetTime() returns a number, expires is a string). Apparently the tonumber() function doesn't exist in v5.0 unless it's a debug build (wtf?). strlen() doesn't exist either.

So I'll be getting and compiling Lua 5.1 this lunch time...
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now