Author Topic: dofile rightclick  (Read 1409 times)

0 Members and 1 Guest are viewing this topic.

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
dofile rightclick
« 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...
Code: [Select]
assert(dofile("FunScript/zFunRightClick.lua"),"Error!")

And this in the rightclcik....
Code: [Select]
--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?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

PtokaX forum

dofile rightclick
« on: 01 December, 2004, 21:43:27 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 744
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #1 on: 01 December, 2004, 22:07:19 »
put this into the file you wanna call the dofile on:

Code: [Select]
function sendusercommands(curUser)
  curUser:SendData(blahblah) -- sending usercmds here
end

this is because curUser is local to the NewUserConnected, not global.
« Last Edit: 01 December, 2004, 22:08:13 by bastya_elvtars »
Everything could have been anything else and it would have just as much meaning.

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
(No subject)
« Reply #2 on: 01 December, 2004, 22:28:11 »
Thanks =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

PtokaX forum

(No subject)
« Reply #2 on: 01 December, 2004, 22:28:11 »