Jump to content




Extending Existing API's


  • You cannot reply to this topic
5 replies to this topic

#1 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 10 February 2013 - 07:37 AM

So, I'm gonna extend some already existing API's, and add neat features such as rednet.openAll() I can't do:
function rednet.openAll()
  ...
end

and I can't do:

rednet = {}
rednet.openAll()
  ...
end

The first one attempts to write to a global API, which is not allowed, and the second one, of course, would wipe out rednet. Does anyone know if it is possible to extend APIs? Thanks.

#2 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 10 February 2013 - 07:39 AM

This should work:
rednet.openAll = function()
  -- body
end


#3 Eric

  • Members
  • 92 posts
  • LocationUK

Posted 10 February 2013 - 07:53 AM

Your first method should work just fine.

#4 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 10 February 2013 - 08:09 AM

bios:267: Attempt to write to global

Btw I'm doing this on tekkit.

#5 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 10 February 2013 - 08:12 AM

ok then

rawset(rednet,"openAll",function()
--
end)


#6 ChunLing

  • Members
  • 2,027 posts

Posted 12 February 2013 - 11:33 AM

Orwell's method should work fine.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users