Jump to content




Config API


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

#1 Noobular

  • Members
  • 86 posts

Posted 30 March 2015 - 07:57 PM

Is there anyway i can have a simple config that will worked across multiple programs?

i tried to make one extremely simple
function SetConfig()
r = peripheral.wrap("BigReactors-Reactor_0")   -- Reactor Position
m = peripheral.wrap("left")   -- Management Monitor
m2 = peripheral.wrap("monitor_0")  -- Controller Monitor
end

just setting these across all 4 programs connected, since its a pain in the arse to go across all of them and set them constantly.

after setconfig is used on the other programs it doesn't actually wrap anything it just gives me an error since it doesn't exist.

Edit: r and m2 do actually work fine on the other programs but for what ever reason theres a problem with m ill test somethings.

#2 Noobular

  • Members
  • 86 posts

Posted 30 March 2015 - 08:03 PM

Edit2: nevermind i'm stupid and never restarted the other programs they don't work either.

#3 Blueberrys

  • Members
  • 10 posts

Posted 30 March 2015 - 08:05 PM

API code:
local r = peripheral.wrap("BigReactors-Reactor_0")
function GetR()
	return r
end

To use it:
os.loadAPI("api_name")
print(api_name.GetR())

OR

API code:
r = peripheral.wrap("BigReactors-Reactor_0")

To use it:
os.loadAPI("api_name")
print(api_name.r)


Reference: Making an API

Edited by Blueberrys, 30 March 2015 - 08:08 PM.


#4 Noobular

  • Members
  • 86 posts

Posted 30 March 2015 - 08:16 PM

Actually it was as easy as

API:
ManageMon = "monitor_1"
Reactor = "right"
Controller = "monitor_0"

USAGE OF API:
program 1
local m = peripheral.wrap(config.ManageMon) -- Monitor for Management (5 long 3 wide)
local r = peripheral.wrap(config.Reactor) -- Big Reactors, Reactor
program 2
local m = peripheral.wrap(config.Controller) -- Monitor for Controls
local r = peripheral.wrap(config.Reactor)    -- Reactor
program 3
local r = peripheral.wrap(config.Reactor) -- Reactor






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users