ComputerCraft Routing

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
@Arkandon: There's actually a Modem API as well as a Modem Peripheral.

@casilleroatr: That was the problem. Actually needed a couple more ends, but now I can switch the track by remote. Thanks for the help. Now to get the resources to build the next part and try out the code for multiple routings.
Oh I see the problem with the end keywords, I didn't notice that before. Are you used to java where you put else and if separately, instead of the elseif found in Lua?
 

Imnafoy

New Member
Jul 29, 2019
29
0
0
Then what is the diffrence between the API and the peripheral? Never heard about a Modem api, would very much like to learn about it if it exists.
Difference between api and peripheral is pretty simple. Api is program interface, it is bunch of functions or methods. Peripheral is physical device for example disk drive, monitor and such or in this case actual modem. However each peripheral needs some interface because you need communicate with it from your program. This interface is in most cases some kind of api. In minecraft terms: peripheral is actual block next to your computer and api is set of methods you are calling to control/use it.
 

KingTriaxx

Forum Addict
Jul 27, 2013
4,266
1,333
184
Michigan
The last programming language I was proficient in was BASIC. This particular piece of programming is the first time I've ever had an else if of any kind work at all. For that matter, it took more than a year to figure out how to get a number out of the title arguments. :p So thank you very, very much for your help.
 

Arkandos

New Member
Jul 29, 2019
349
0
0
Difference between api and peripheral is pretty simple. Api is program interface, it is bunch of functions or methods. Peripheral is physical device for example disk drive, monitor and such or in this case actual modem. However each peripheral needs some interface because you need communicate with it from your program. This interface is in most cases some kind of api. In minecraft terms: peripheral is actual block next to your computer and api is set of methods you are calling to control/use it.

Uhm. No. And I do know the diffrence between an API and a peripheral. An API in computercraft is one of two things. It's either a file being loaded automatically on startup because it exists in rom, or using "os.loadAPI( name )".
The modem is used by wrapping the peripheral directly, which means any name can be used. "modem.transmit()" and "iceCreamIsGreat.transmit()" both work, as modem is not an API, it's a peripheral.
I agree that peripherals have functions and methods, but they are very diffrent from APIs
 

Imnafoy

New Member
Jul 29, 2019
29
0
0
Uhm. No. And I do know the diffrence between an API and a peripheral. An API in computercraft is one of two things. It's either a file being loaded automatically on startup because it exists in rom, or using "os.loadAPI( name )".
The modem is used by wrapping the peripheral directly, which means any name can be used. "modem.transmit()" and "iceCreamIsGreat.transmit()" both work, as modem is not an API, it's a peripheral.
I agree that peripherals have functions and methods, but they are very diffrent from APIs
I used real-life definitions for peripheral and API and in minecraft it is same. Well... modem in minecraft is actually abstraction of real-life sice it is only in game, but still... modem as peripheral is just that block... and calling peripheral.wrap() is what you need to get to its API. But still it is API (you can see this). So each peripheral must have their own API so you can use them. So modem peripheral(block on side of computer) has its own modem API. Main difference between peripheral's API and API which you mean is that peripheral.wrap() creates object which symbolizes actual peripheral and its methods are its API. On the other hand, os.loadAPI() (and APIs automatically loaded from rom are same) just loads file and executes it and created functions or variables become members of object which has same name like file from which it was loaded and can be in program only once.
Only problem is that in Computer Craft has really unfortunate terminology in which API stands for both preripheral API and modules.

So to end this argument. In CC there is no modem API which can be loaded by os.loadAPI("modem"), but there is modem API which is API of modem peripheral.
 
  • Like
Reactions: immibis