Content deleted Content added
Removed superlative things Tags: Mobile edit Mobile web edit |
More context about rbx.lua, i added i so people know that rbx.lua is a nickname for Luau |
||
(9 intermediate revisions by 5 users not shown) | |||
Line 1:
[[File:ComputerDiagram.png|alt=|thumb|300x300px|Diagram for how to construct a basic computer including a MicroController.]]
The main parts of programming are:▼
Documentation for all the parts can be found here [https://github.com/iimurpyh/pilot-lua/wiki].
*[[Microcontroller]] - An object that stores and runs code when triggered by polysilicon and powered. This is the core component of coding, as its the only way to run code in this game.▼
*[[Port]] - Allows the microcontroller to interact with other objects, trigger and configure, etc. This is also a very important part, because it is the ONLY way to allow microcontrollers to interact with the outside world.▼
▲*[[Microcontroller]] -
*[[Disk]] - Stores values in a [https://create.roblox.com/docs/education/coding-5/intro-to-dictionaries dictionary] format. It is very useful to store large amounts of info like code and [[Model Builder|model codes]]. It is also very useful, as microcontrollers don't carry information across turning on and off, while disks do. ▼
▲*[[Port]] - Allows the
*[[Screen]] - Displays user interface objects on its surface using Gui elements (such as TextLabel, Button, ..). It is one of the most common ways to provide the user with feedback as it is able to display it in a clear, visual way. It can be to a certain extent supplemented with the much easier to program [[Sign|signs]].
▲*[[Disk]] - Stores values in a [https://create.roblox.com/docs/education/coding-5/intro-to-dictionaries dictionary] format.
*[[EthernetCable]] (optional) - Allows Ports to reach further when placed touching the hole of the port, similar to how a wire allows power to reach further.
*(UNSTABLE) [[Router]] (optional) - The router is the [[Antenna]] of [[EthernetCable|ethernet cables]]. It does the same thing as [[EthernetCable|ethernet cables]], only wireless. This is incredibly useful, as it allows for wireless connections, and allows for parts to be connected from across the region. Note that this is ONLY in [https://www.roblox.com/games/4569607361/Waste-Of-Space-UNSTABLE unstable].
Other less-important items in coding include:
*[[Modem]] - Allows for cross-region message passing and communication with arbitrary www domains (Sends GET and or POST requests to either the WOS internet, or the real (www) one). Allows for the creation of an internet of sorts. See the article for more details.
*[[LifeSensor]] -
*[[Gyro]] -
*[[Keyboard]] -
*[[Microphone]] -
*[[Instrument]] -
*[[TouchScreen]] - A improved version of the [[Screen]], as it allows you to get the X and Y (in offset) of the cursor on the screen. Note that you can use buttons on Screens for User input.
local Gyro = GetPartFromPort(1, "Gyro") -- Gets gyro attached to port 1
local Microphone = GetPartFromPort(2, "Microphone") -- Gets microphone attached to port 2
Line 35 ⟶ 38:
end)
</syntaxhighlight>
There are many functions in Pilot.lua that allow you to interact with other objects
*GetPort(ID) - Returns a port instance that can be used in other functions. It is only really recommended if your going to do something like port:Connect("Triggered")▼
*GetPartFromPort(ID or Port Instance, ClassName) Returns a part if found directly attached to a port. An example would be GetPartFromPort(2, "Screen")▼
*TriggerPort(ID or Port Instance) - pretty self explanatory, sends a [[Button|trigger signal]] from the given port or port instance ▼
*GetPartsFromPort(ID or Port Instance, ClassName) Returns an [https://create.roblox.com/docs/luau/tables array] of different parts attached to the [[Port]]. In order to use, it is recommended to use [https://create.roblox.com/docs/education/coding-5/pairs-and-ipairs ipairs], however, a "'''for i = number, number do'''" along with a "'''Parts[i]'''" will work too.▼
▲*<code>GetPort(ID)</code> - Returns a port instance that can be used in other functions. It is only really recommended if your going to do something like <code>port:Connect("Triggered")</code>
▲*<code>GetPartFromPort(ID or Port Instance, ClassName)</code> Returns a part if found directly attached to a port. An example would be GetPartFromPort(2, "Screen")
▲*<code>TriggerPort(ID or Port Instance)</code> - pretty self explanatory, sends a [[Button|trigger signal]] from the given port or port instance
▲*<code>GetPartsFromPort(ID or Port Instance, ClassName)</code> Returns an [https://create.roblox.com/docs/luau/tables array] of different parts attached to the [[Port]]. In order to use, it is recommended to use [https://create.roblox.com/docs/education/coding-5/pairs-and-ipairs ipairs], however, a
All objects will contain certain programmable properties and functions. However, all instances will contain the following properties and methods:
*Properties
**Configurable properties, for example an
**<code>ClassName</code>, which is simply the name of the object
*Methods
**Object:Trigger(), which simply triggers the object
**Object:Configure({Property=NewValue}), which configures the part to the given dictionary/table
**Object:Connect,
*Events
**part:Connect("Triggered", function
Certain parts however will have their own special properties.
*Screen
Line 150 ⟶ 152:
</syntaxhighlight>
There you go! You have just made a simple messaging system. You can expand on this by using [[Keyboard|Keyboards]] to send messages, or use screens to make a nice looking UI.
Another method is the RealPostRequest, it enables you to send post requests to real websites such as google. Here's an example:
<syntaxhighlight lang="lua" start="1">
local Modem = GetPartFromPort(1,"Modem")
local Sign = GetPartFromPort(1,"Sign")
local Payload = JSONEncode({"Data",1,2,3})
local Data, Success = Modem:RealPostRequest("http://CustomLinkHere.com",Payload,false,nil,{["Content-Type"]="application/json"})
if Success then
Sign:Configure({SignText=Payload})
end
</syntaxhighlight>Sadly, the RealGetRequest does not work. So you have to use the post requests.
If you want to use the RealPostRequest for sending data to your computer then you will have to use third party resources. (i.e. website hosting) how ever, learn Luau first, you will need some LUAU experience or lua 5.1 experience, learn Lua 5.1 then Luau then pliot.lua.
== Resources ==
Line 155 ⟶ 173:
* There is currently one player-made wiki, [https://github.com/iimurpyh/pilot-lua/wiki murpyh's]
* Some information on parts can be found at [https://wos.mawesome4ever.com mawesome's part list site], though some information is inaccurate or not displayed there
*[https://create.roblox.com/docs/ Roblox creator documentation] contains a load of info on rbx.lua. If you are unfamiliar with lua, or coding in general, it is highly recommended to learn rbx.lua first. if you do NOT know what rbx.lua IS, it is a nickname for Luau.
==Programming Examples ==
|