Jump to content




RedNetLog

networking

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

#1 MisterMeister32

  • Members
  • 6 posts
  • LocationGermany

Posted 24 March 2018 - 02:20 PM

RedNetLog


RedNetLog is a very basic and easy-to-use RedNet Logger.

It is a useful tool for developng and debugging networking applications.

Download:
pastebin get wCBNGPiy rnlog

Output format: ID(Protocol):Massage

Coming Features:
  • Saving logs to a File
  • Fanzy GUI


#2 CLNinja

  • Members
  • 191 posts

Posted 24 March 2018 - 02:36 PM

This sort of thing has been done time and time again. I really don't think we need another one.

#3 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 24 March 2018 - 03:01 PM

View PostCLNinja, on 24 March 2018 - 02:36 PM, said:

This sort of thing has been done time and time again. I really don't think we need another one.
You could say that about many CC programs though. Looks at the Operating Systems section.

MisterMeister32: this is actually pretty decent code for a first program, good job! One thing I'd recommend is prefixing all your variable definitions with "local". It's a rather trivial change, but means values are specific to a given function, rather than leaked across programs. So you'd change your code to look something like:
local function open() --# Note the "local function" instead
  local p = peripheral.getNames() --# Again, note the use of local when declaring the variable.
  local modem = nil
  for i = 1, #p do --seaching for modems
    if peripheral.getType(p[i]) == "modem" then
      modem = p[i] --# As we're setting an existing variable, we don't need it here.
    end
  end

There's also a neat little trick you can do with peripheral.find in order to open all modems. Instead of looping through each modem and opening it, you can do:
peripheral.find("modem", rednet.open)


#4 MisterMeister32

  • Members
  • 6 posts
  • LocationGermany

Posted 24 March 2018 - 03:50 PM

Now I put "local" before every function and variable.
I didn't knew about peripheral.find, but leave my own routine In there, because its easier to work with.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users