Jump to content




Scope headaches.


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

#1 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 02 May 2012 - 04:24 AM

I've got some slight modifications to make to read() that I'd like to apply to all calls to it on a per-computer basis. I'm trying to do this such that it would be possible to use on SMP when one doesn't have access to the ROM (which is where it's implemented right now). The best way I could think of was a straight function-replacement in startup, but I have the nasty feeling that that change is going out of scope as soon as startup is finished executing, since I'm seeing the behavior of the usual read() there instead of the modified behavior. Everything works fine if the modified read() is implemented in bios.lua instead. Any pointers on what the issue is? Is it really just a scope issue?

[These changes implement event-driven multitasking (for rednet daemons), and are already tested and proven to work. I'm just trying to make the system portable at this point.]

#2 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 29 June 2012 - 06:37 PM

As long as the computer is not shut down, it should work. Atleast it works like that in Lua, I don't know about CC.

#3 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 29 June 2012 - 07:01 PM

Try

rawset(_G, "read", yourNewRead)


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 June 2012 - 12:22 AM

Holy crap, topic necromancy. I got this working weeks ago using a rawset() call. Thanks for the (somewhat too late) help, Cloudy.

#5 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 30 June 2012 - 07:23 AM

I didn't realise that the topic had been bumped from May. Sorry!

mad: You really shouldn't bump topics this old!

#6 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 30 June 2012 - 09:52 AM

Cloudy: You should neither!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users