Jump to content




[Solved] peripheral.getNames?


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

#1 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 11 May 2013 - 01:42 PM

Does peripheral.getNames just use rs.getSides, then if it's a wired modem lists it's remote peripherals? I'm trying to sandbox it, so I need help.

#2 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 11 May 2013 - 01:48 PM

From the API section in your copy of CC/lua:
local native = peripheral

function getNames()
	local tResults = {}
	for n,sSide in ipairs( rs.getSides() ) do
		if native.isPresent( sSide ) then
			table.insert( tResults, sSide )
			if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
				local tRemote = native.call( sSide, "getNamesRemote" )
				for n,sName in ipairs( tRemote ) do
					table.insert( tResults, sName )
				end
			end
		end
	end
	return tResults
end
Things you should know with figuring out this code:
- native.someFunc is a built-in function

I know for a matter of fact you can program so you can figure out the code :P
If not, just ask :)

#3 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 11 May 2013 - 01:52 PM

That is the exact same thing I expected it to be, thanks for confirming.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users