PtokaX forum

Development Section => Your Developing Problems => Topic started by: Madman on 01 December, 2004, 21:43:27

Title: dofile rightclick
Post by: Madman on 01 December, 2004, 21:43:27
Got A problem with my FunScript...
I want to add a RightClicker to it, so i thought i had the code in a sepperate file... so i use this in the main file...
assert(dofile("FunScript/zFunRightClick.lua"),"Error!")

And this in the rightclcik....
--curUser:SendData("$UserCommand 1 2 FunScript\\Do To A User\\Command$<%[mynick]> !command %[nick]||")
curUser:SendData("$UserCommand 1 2 FunScript\\Do To A User\\Slap User$<%[mynick]> !slap %[nick]||")
curUser:SendData("$UserCommand 1 2 FunScript\\Do To A User\\Love User$<%[mynick]> !love %[nick]||")

But I Get this error....

Syntax error: attempt to index global `curUser' (a nil value)
stack traceback:
   1:  main of file `FunScript/zFunRightClick.lua' at line 2
   2:  function `dofile' [C]
   3:  main of file `...ram\Hub\PtokaX-0.330 madhouse\scripts\Funv5.lua' at line 142

Syntax error: assertion failed!  Error!
stack traceback:
   1:  function `assert' [C]
   2:  main of file `...ram\Hub\PtokaX-0.330 madhouse\scripts\Funv5.lua' at line 142

And, yes i use curUser in the main file...
What do i have to do to get it to work?
Title:
Post by: bastya_elvtars on 01 December, 2004, 22:07:19
put this into the file you wanna call the dofile on:

function sendusercommands(curUser)
  curUser:SendData(blahblah) -- sending usercmds here
end

this is because curUser is local to the NewUserConnected, not global.
Title:
Post by: Madman on 01 December, 2004, 22:28:11
Thanks =)