Author Topic: Calling fuctions in other scripts  (Read 1617 times)

0 Members and 1 Guest are viewing this topic.

Offline TecMaster

  • Fulll Member
  • ****
  • Posts: 74
  • Karma: +1/-0
Calling fuctions in other scripts
« on: 04 August, 2004, 12:09:21 »
How do I call a function, Test1(), in script file Test1.lua from a function, say Test2 in script file Test2.lua???

PtokaX forum

Calling fuctions in other scripts
« on: 04 August, 2004, 12:09:21 »

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #1 on: 04 August, 2004, 13:15:34 »
you put the two script togheter at the top of Test1.lua like this:



assert(dofile("Test2.lua"), "Test2.lua is not found")


hope this helps some...

/NL
//NL

Offline TecMaster

  • Fulll Member
  • ****
  • Posts: 74
  • Karma: +1/-0
(No subject)
« Reply #2 on: 04 August, 2004, 16:18:12 »
But this would meen that the variables in the included Test2.lua would not be the same as the "stand alone" Test2.lua?

Herodes

  • Guest
(No subject)
« Reply #3 on: 04 August, 2004, 18:10:45 »
u can still use any variables and any lua chunks if u assert a .lua file to another...

It is like attaching the lua code to the host-script...

Offline TecMaster

  • Fulll Member
  • ****
  • Posts: 74
  • Karma: +1/-0
(No subject)
« Reply #4 on: 05 August, 2004, 14:09:55 »
Thanks, works fine  :)

PtokaX forum

(No subject)
« Reply #4 on: 05 August, 2004, 14:09:55 »