Author Topic: os.clock()  (Read 2715 times)

0 Members and 1 Guest are viewing this topic.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
os.clock()
« on: 05 March, 2005, 01:52:26 »
Code: [Select]
if cmd then
local x=os.clock()
if parsecmds(user,data,string.lower(cmd),"MAIN") then
if LagTest==1 then
[color=#993399]user:SendData(parseenv(user,env,Bot).."Executing this command took "..os.clock() - x.." seconds.")[/color]
end
return 1
else
user:SendPM(Bot,"It would be so nice to talk to you, but I have many things to do. So either enter a valid command or stop bugging me! ;)")
end
end

Any ideas why this gives the following error?

Quote
Syntax O:\ptokax1604\scripts\lawmaker.lua:4262: attempt to concatenate a nil value
« Last Edit: 05 March, 2005, 02:45:21 by bastya_elvtars »
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

os.clock()
« on: 05 March, 2005, 01:52:26 »

Offline Pothead

  • Lord
  • ***
  • Posts: 455
  • Karma: +25/-4
(No subject)
« Reply #1 on: 05 March, 2005, 02:15:03 »
Which line is 4262 ? :)

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #2 on: 05 March, 2005, 02:46:03 »
Quote
Originally posted by Pothead
Which line is 4262 ? :)

The one containing concatenation. :D

OK, I made it purle.
Everything could have been anything else and it would have just as much meaning.

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #3 on: 05 March, 2005, 04:19:15 »
probably not what ur lookin for...

Code: [Select]
current = os.date("%d:%m:%y - %H:%M")
iMin = 1000*60
tTime = {
--["timestring"] = "show this string"
["06:00"] = "Guten Morgen Hub - Ein neuer Tag ist angebrochen!!",
["09:30"] = "Morgens halb zehn in Deutschland - KNOPPERS Das Fr?hst?ckchen!! Mahlzeit *fg*",
["12:00"] = "Guten hunger, all denen die nun was essen!!",
["22:00"] = "Gut nacht, all denen die schon oder gleich ins Bett gehen!"
}
function Main()
current = os.date("%d:%m:%y - %H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
SetTimer(iMin)
StartTimer()
end
function OnTimer()
frmHub:UnregBot("---" ..current .."---")
current = os.date("%d:%m:%y - %H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
end
function OnExit()
frmHub:UnregBot("---" ..current .."---")
end

but maybe something inside could help u
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Herodes

  • Guest
(No subject)
« Reply #4 on: 05 March, 2005, 09:43:43 »
Code: [Select]
user:SendData(parseenv(user,env,Bot).."Executing this command took "..os.clock() - x.." seconds.")Make sure that parseenv(user,env,Bot) is actually returning smth with the parameters ... and also it'll be poss cleaner to parenthesize (os.clock()-x) while concating it ...
Hope its solved by the time you r reading this .. ;)

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #5 on: 05 March, 2005, 10:24:41 »
when handling 2 values inside a string do it like this:

Code: [Select]
user:SendData(parseenv(user,env,Bot).."Executing this command took "..(os.clock() - x).." seconds.")

My coin to this... cheers
//NL

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #6 on: 05 March, 2005, 12:35:34 »
The fun is that it works here:

Code: [Select]
function Main()
local x=os.clock()
if not string.find(frmHub:GetHubDescr(), "LawMaker") then
local tempdescstore = frmHub:GetHubDescr()
local NewDescription = tempdescstore.." - powered by "..botver
frmHub:SetHubDescr(NewDescription)
end
ipranges=loadipranges()
local f=io.open("lawmaker/getlogs.bat","w+")
f:write("dir \""..ptokaxpath.."/scripts/lawmaker/logs\" %1 /-p /o:gn > \""..ptokaxpath.."/scripts/lawmaker/lists/logs.lst\"")
f:close()
-- Cleaning()
loadwatchkicks()
immunelist=maketable("lawmaker/lists/immune.lst")
bannedranges=maketable("lawmaker/lists/banned_ranges.lst")
CleanDay = os.date("%Y. %m. %d.")
if loadfile("lawmaker/inifiles/offline.ini") then
require("lawmaker/inifiles/offline.ini")
end
if loadfile("lawmaker/inifiles/announce.ini") then
require("lawmaker/inifiles/announce.ini")
end
if loadfile("lawmaker/inifiles/leave.ini") then
require("lawmaker/inifiles/leave.ini")
end
GetOpVipChat()
LoadFile(opchat,"lawmaker/inifiles/opchat.ini")
LoadFile(vipchat,"lawmaker/inifiles/vipchat.ini")
-- botversion(nil,"MAIN",nil)
-- frmHub:EnableFullData(1)
frmHub:RegBot(Bot)
frmHub:RegBot(opchatbot)
--frmHub:UnRegBot(vipchatbot)
if enablevipchat==1 then frmHub:RegBot(vipchatbot) end
fakeshares=maketable("lawmaker/inifiles/fakesharesize.ini")
NoClean=maketable("lawmaker/lists/noclean.lst")
NoMotd=maketable("lawmaker/lists/nomotd.lst")
LoadWarn()
SetTimer(1000)
StartTimer()
ReloadRel()
loadaway()
kicks=loadkicks()
NoMotd=maketable("lawmaker/lists/nomotd.lst")
userinfo=nil
Clear()
userinfo={}
LoadUserInfo()
SaveUserinfo()
SendToOps(Bot,"Booting... done in "..os.clock()-x.." seconds.")
end

@Herodes: parseenv is about 100 times called in my script. IMHO it's the command parsing that flushes it. Gonna try with GLOBAL variable. :S
« Last Edit: 05 March, 2005, 12:38:19 by bastya_elvtars »
Everything could have been anything else and it would have just as much meaning.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #7 on: 07 March, 2005, 04:33:22 »
Code: [Select]
Gonna try with GLOBAL variable.
Does not work either. Need workaround,
Everything could have been anything else and it would have just as much meaning.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #8 on: 07 March, 2005, 06:03:02 »
*was an idiot*

Thx to RabidWombat for directing my attention to parseenv, that was erroneous - altho I still do not 100% understand why.
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

(No subject)
« Reply #8 on: 07 March, 2005, 06:03:02 »