Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Suterusu

Members
  • Content Count

    13
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Suterusu

  1. So far I have ~450 lines... I am trying to write a "cell network" program to be able to send messages between nodes on a "tree" structure".  I have all the logic for "routing" messages, etc. the part I am trying to deal with is the psudo concurrency of trying to send/recieve.

     

    Using event.listen() as a "background" listener has worked, sort of.  I've been able to send and echo back messages from computers connected to different cell towers over my network using hop-by-hop of nodes with modem.send().

     

    What I am trying to do with event.listen() is this (calling a function directly instead of an event handler):

    event.listen("modem_message", listen)
    
    function listen(msg, localAddress, remoteAddress, port, distance, data)
    	local payload = serialization.unserialize(data)
        --more code here
    end
    

    That works fine, I can do other "stuff" in code, and when an event type "modem_message" is received, it calls listen() and passes it all the parameters.

     

    What I am stuck on however, is if another function wants to send, "modem.send()" to another host, the listen() function will recieve the reply.  I don't want to call event.pull() within the function that used modem.send() in order to "wait" for a reply back because it will block and prevent further code execution.

    function nameLookup(name)
    	local querry = {["type"] = "querry", ["name"] = name}
    	sendData(querry, nameServer)
       --more code
    end
    
    function sendData(data, destination)
    	local data = serialization.serialize(data) 
    	local payload = {["dstAddress"] = destination, ["srcAddress"] = myAddress, ["data"] = data}
    	m.send(rootPathList[1], 16, serialization.serialize({["msgType"] = "data", ["payload"] = payload}))
    end
    

    So, from within nameLookup() we should be getting the reply data there, the stuff listen() gets when called by event.listen(), so we can parse it and return the function to the calling function.

     

     

  2. I noticed on the wiki this part here:

     

    Important: If you use event handling in driver mode, then event functions will be called from the environment of the OS event handler and variables local to your program will not be visible!

     

    Do you have any code examples that use event.listen?

  3. For anyone using GT 5 and wants a decent display for EU....

     

    Dynamically will update total power based on batteries inside a battery buffer + batter buffer stored power.  Green text = charging (overall gain in EU), Red = discharging (losing power greater than charge).

     

    If you use the code, you need to manually adjust the screen resolution and the variable for the Battery Buffer based on the type you are using.  I used a tier2 case with a tier2 graphics card and a tier2 display.

     

    http://pastebin.com/TgpMa93Q

     

    Wb8Zw53.png

  4. I want to be able to "listen for" and "transmit" modem messages concurently.

     

    Basically, I want to activley be listening for incoming messages, but during that time I may want to send messages as well.  Additionally, once a message is received, I want to do something about it, whilst going back to "listening" for messages again.

     

    Listener()

      -> Add incoming message to queue

    Processor()

     -> Process message queue

    Sender()

      -> Send messages as needed

     

    I have the general idea, I am just unsure how to execute this (if even possible) with LUA and OC.

     

    Any psudo code or hints/help would be greatly appreciated!

  5. Is there any way to get the amount of power stored in a GT battery buffer (NOT IC2 Batbox)?

     

    Here are the exposed methods from using it (small battery buffer) with an Adapter:

     

    3kCNbJg.png

     

    None seem to yield any relevent data.

     

    Furthermore, I found GT has its own tool for getting block data, but it's a player item, not a block:

     

    fLNe02V.png

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.