My question(s) is about Assert,
Is it wise to assert a other script in the NewUserConnected event or other very often triggerd event?
What exactly happens when u use assert.
does assert uses alot of CPU ?
It is wise to always use assert in major functions while a script is in development.
The lua manual describes assert as:
function assert (v, m)
if not v then
m = m or ""
error("assertion failed! " .. m)
end
end
As you can see, it's nothing more than an if statement, requiring very little resources.
It is good practice to add asserts to any useful code snippets that you make.
On a side note, do not use string concatation with assert such as:
assert( num1 == num2, num1 .. " does not equal " num2);
String concatation occurs _BEFORE_ the assert statement is evaluated, so this operation will happen even if the assertion is succeeds.
You should use instead:
function fast_assert(condition, ...)
if not condition then
if getn(arg) > 0 then
assert(condition, call(format, arg))
else
assert(condition)
end
end
end
Read more about fast_assert and other code optimization at: http://lua-users.org/wiki/OptimisationCodingTips
-NotRabidWombat
tx , for info
wasn't totally sure about assert before you posted,
Currently i'm trying to put every function in sepperate lua file, and trying to use tables as classes.
To get more of a programming language idea then a scripting language ;)