Jump to content




Functions


5 replies to this topic

#1 macss_

  • Members
  • 30 posts
  • LocationBrazil

Posted 18 May 2014 - 08:04 PM

Is it possible to stabilish "global" functions that I can call in in any program?

like

function rednetSend(msg)
msg = tostring(msg)
redenet.broadcast(msg)
end

So i can call it in any program i have.

#2 CometWolf

  • Members
  • 1,283 posts

Posted 18 May 2014 - 08:06 PM

You just did, any non local variable is acessible from all programs after it has been defined until the computer reboots.

#3 Lignum

  • Members
  • 558 posts

Posted 18 May 2014 - 08:07 PM

No, not really. But you can make an API.
EDIT: Never mind, just tried it, CometWolf is right. Lua never ceases to amaze me with its magic.

Edited by Lignum, 18 May 2014 - 08:08 PM.


#4 macss_

  • Members
  • 30 posts
  • LocationBrazil

Posted 18 May 2014 - 08:07 PM

So if I run a program called "function" then terminate it an imediatly after i execute rednetSend("Hello") the message will be sent?

#5 Lignum

  • Members
  • 558 posts

Posted 18 May 2014 - 08:09 PM

View Postmacss_, on 18 May 2014 - 08:07 PM, said:

So if I run a program called "function" then terminate it an imediatly after i execute rednetSend("Hello") the message will be sent?
Yes.

#6 macss_

  • Members
  • 30 posts
  • LocationBrazil

Posted 18 May 2014 - 08:14 PM

Well, thank you so! :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users