http://www.computercraft.info/wiki/api.php?action=feedcontributions&user=TheVarmari&feedformat=atomComputerCraft Wiki - User contributions [en]2024-03-28T09:46:42ZUser contributionsMediaWiki 1.24.1http://www.computercraft.info/wiki/index.php?title=Rednet_(API)&diff=5656Rednet (API)2013-05-12T03:02:50Z<p>TheVarmari: Minor type edits</p>
<hr />
<div>{{msgbox<br />
|title=Please Note<br />
|text=As of ComputerCraft 1.5, the Rednet API is just a wrapper for [[Modem_(API)|modems and channels]], and no longer supports<br>transmitting data through Bundled Cables. However interacting with Bundled Cables is still available via the [[Redstone_(API)|Redstone API]]<br />
}}<br />
<br />
The Rednet API allows computers to communicate between themselves without using redstone wires. In order to send and receive data, a [[modem]] is required. The data is received immediately after sending it, but only by computers within a certain range. That range depends on the altitude of the sending computer increasing with higher altitudes to a max of 384.<br />
'''NOTE:''' The distance variable that is sent/received through the Rednet API is based off of the computer location, not the modem location. <br />
<br />
<br />
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"><br />
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;"><br />
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;<br />
Rednet (API)<br />
</td></tr><br />
<br />
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr><br />
<br />
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.open]]({{type|string}} side)</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tells the computer that the side can be used for networking.</td></tr><br />
<br />
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.close]]({{type|string}} side)</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tells the computer that the side can no longer be used for networking.</td></tr><br />
<br />
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.announce]]()</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Broadcasts an empty rednet message.</td></tr><br />
<br />
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.send]]({{type|number}} receiverID, {{type|string}} message)</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sends a message to the computer using the opened sides. The receiver ID is the ID (number, not string) of the computer you're sending the message to. ID as nil will do the same as a broadcast. The message must be a string to send across rednet, if you are wanting to send a table see [[textutils.serialize]]</td></tr><br />
<br />
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.broadcast]]({{type|string}} message)</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sends the message to ALL connected and open computers.</td></tr><br />
<br />
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.receive]]({{type|number}} timeout)</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Waits until it received a rednet message or <var>timeout</var> has passed. Leave args empty to wait for a message forever.</td></tr><br />
<br />
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.isOpen]]({{type|string}} side)</td><br />
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns true if the wireless modem is open.</td></tr><br />
</table><br />
<br />
==Events==<br />
{| class="wikitable" width="100%"<br />
! colspan="1" | Event Name<br />
! colspan="1" | Description<br />
! colspan="1" | Parameters<br />
|-<br />
! scope="row" | rednet_message<br />
|Fired when a rednet message is received (can be used as alternative for rednet.receive())<br />
|{{type|number}} senderId, {{type|string}} message, {{type|number}} distance<br />
|}<br />
<br />
==History==<br />
Before the creation of the in-game wireless networking API, the term "Rednet" referred to a system created by one of the ComputerCraft users based on bundled cables from a popular Minecraft mod - RedPower. It also allowed communication between computers, but the data was transferred slowly - every bit was converted to redstone signal, that lasted about 0,1 seconds. On the release of ComputerCraft 1.3, the system became useless, as the wireless networking was officially implemented to the mod.<br />
<br />
[[Category:APIs]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Computer.getID&diff=5655Computer.getID2013-05-12T02:55:11Z<p>TheVarmari: Changed int to number</p>
<hr />
<div>{{Function<br />
|name=computer.getID<br />
|api=peripheral<br />
|returns=[[number (type)|number]] ID<br />
|addon=ComputerCraft<br />
|desc=Returns the ID of a computer or turtle wrapped to the "computer" variable<br />
|examples={{Example<br />
|desc=Prints the ID of a computer or turtle on the right side of the calling machine.<br />
|code=<br />
local handle = peripheral.wrap("right") <br />
print(handle.getID())<br />
|output=The ID of any computer or turtle to the right of the calling machine.<br />
}}<br />
}}<br />
<br />
[[Category:Lua_Core_Functions]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Os.getComputerID&diff=5654Os.getComputerID2013-05-12T02:54:17Z<p>TheVarmari: Changed int to number</p>
<hr />
<div>{{lowercase}}<br />
{{Function<br />
|name=os.getComputerID<br />
|returns=[[number (type)|number]] ID<br />
|api=OS<br />
|addon=ComputerCraft<br />
|desc=Returns a number which uniquely identifies the computer and which is the name of the directory in the world’s <code>computer</code> directory containing the computer’s data. This function is also available as [[os.computerID]].<br />
|examples=<br />
{{Example<br />
|desc=Prints the computer ID.<br />
|code=print(os.getComputerID())<br />
|output=1<br />
}}<br />
}}<br />
<br />
[[Category:Lua_Core_Functions]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Computer.getID&diff=5653Computer.getID2013-05-12T02:52:41Z<p>TheVarmari: Added function page</p>
<hr />
<div>{{Function<br />
|name=computer.getID<br />
|api=peripheral<br />
|returns=[[int]] ID<br />
|addon=ComputerCraft<br />
|desc=Returns the ID of a computer or turtle wrapped to the "computer" variable<br />
|examples={{Example<br />
|desc=Prints the ID of a computer or turtle on the right side of the calling machine.<br />
|code=<br />
local handle = peripheral.wrap("right") <br />
print(handle.getID())<br />
|output=The ID of any computer or turtle to the right of the calling machine.<br />
}}<br />
}}<br />
<br />
[[Category:Lua_Core_Functions]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Computer.reboot&diff=5652Computer.reboot2013-05-12T02:47:47Z<p>TheVarmari: Tidied up source, made code multi-line</p>
<hr />
<div>{{Function<br />
|name=computer.reboot<br />
|api=peripheral<br />
|addon=ComputerCraft<br />
|desc=Reboots a computer or turtle wrapped to the "computer" variable<br />
|examples={{Example<br />
|desc=Reboots the computer or turtle on the right side of the calling machine.<br />
|code=<br />
local handle = peripheral.wrap("right") <br />
handle.reboot()<br />
|output=Reboots any computer or turtle to the right of the calling machine.<br />
}}<br />
}}<br />
<br />
[[Category:Lua_Core_Functions]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Computer.shutdown&diff=5651Computer.shutdown2013-05-12T02:44:52Z<p>TheVarmari: Tidied up source, made code multi-line</p>
<hr />
<div>{{Function<br />
|name=computer.shutdown<br />
|api=peripheral<br />
|addon=ComputerCraft<br />
|desc=Shuts down a computer or turtle wrapped to the "computer" variable<br />
|examples={{Example<br />
|desc=Shuts down the computer or turtle on the right side of the calling machine.<br />
|code=<br />
local handle = peripheral.wrap("right") <br />
handle.shutdown()<br />
|output=Shuts down any computer to the right of the computer/turtle.<br />
}}<br />
}}<br />
<br />
[[Category:Lua_Core_Functions]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Computer.turnOn&diff=5650Computer.turnOn2013-05-12T02:43:00Z<p>TheVarmari: Added function page</p>
<hr />
<div>{{Function<br />
|name=computer.turnOn<br />
|api=peripheral<br />
|addon=ComputerCraft<br />
|desc=Turns on a computer or turtle wrapped to the "computer" variable<br />
|examples={{Example<br />
|desc=Turns on the computer or turtle on the right side of the calling machine.<br />
|code=<br />
local handle = peripheral.wrap("right") <br />
handle.turnOn()<br />
|output=Turns on any computer to the right of the computer/turtle.<br />
}}<br />
}}<br />
<br />
[[Category:Lua_Core_Functions]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Advanced_Computer&diff=5649Advanced Computer2013-05-12T02:29:16Z<p>TheVarmari: Linked functions</p>
<hr />
<div>{{Block<br />
|name=Advanced Computer<br />
|image=Iso_Advanced_Computer.png<br />
|id=4095<br />
|damage-value=The ID of the Computer.<br />
|is-peripheral=Yes<br />
}}<br />
The Advanced Computer is a [[computer]] that has mouse and colour API support. More exclusive features may be added in another update. They resemble the traditional computer console, but are golden coloured to match their crafting [[recipes|recipe]].<br />
==Recipe==<br />
{{Crafting grid<br />
|A1=Gold_Ingot |B1=Gold_Ingot |C1=Gold_Ingot<br />
|A2=Gold_Ingot |B2=Redstone |C2=Gold_Ingot<br />
|A3=Gold_Ingot |B3=glass_pane |C3=Gold_Ingot<br />
|Output=Advanced_Computer<br />
}}<br />
<br />
==Exclusive Functions==<br />
[[File:AdvancedComputerPaint.png|frame|right|An advanced computer running Paint, an exclusive program]]<br />
[[Advanced Computer|Advanced Computers]] and [[Advanced Monitor|Advanced Monitors]] both have access to color-setting functions in the [[Term (API)]]. In contrast, the standard [[Computer|Computers]] and [[Monitor|Monitors]] do not have access to color-setting functions. Also, advanced computers are able to detect mouse clicks, drags, and scrolls, while the standard [[Computer|Computers]] and [[Monitor|Monitors]] can not. Note that [[Advanced Monitor|Advanced Monitors]] can only detect touch.<br />
<br />
==Exclusive Programs & APIs==<br />
*[[Paint]]<br />
*[[paintutils (API)]]<br />
<br />
== Peripheral Functions ==<br />
'''''computer'' stands for the variable you wrapped the computer to.'''<br />
''Example:'' computer = peripheral.wrap( "top" )<br />
<br />
{| class="wikitable"<br />
!style="background:#EEE" width="210px"|Method name<br />
!style="background:#EEE" width="*"|Description<br />
|-<br />
|[[computer.turnOn()]]<br />
|Turns on the Computer or Turtle.<br />
|-<br />
|[[computer.shutdown()]]<br />
|Shuts off the Computer or Turtle.<br />
|-<br />
|[[computer.reboot()]]<br />
|Reboots the Computer or Turtle.<br />
|-<br />
|[[computer.getID()]]<br />
|Gets the ID of the Computer or Turtle.<br />
|}<br />
<br />
[[Category:Blocks]][[Category:Consoles]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Rednet_message_(event)&diff=5648Rednet message (event)2013-05-12T02:21:58Z<p>TheVarmari: Removed NeedsWork, examples have been added earlier</p>
<hr />
<div>{{Event<br />
|name=rednet_message<br />
|desc=Fired when any Rednet message arrives through an open modem.<br />
|return1=The computer ID of the sender (see [[os.computerID|os.getComputerID()]]).<br />
|return2=The message as a [[string (type) | string]]. If message was previously a table see [[textutils.unserialize]]<br />
|return3=The distance between the modems.<br />
}}<br />
{{Example<br />
|desc=Prints a message <br />
|code=<br />
while true do<br />
event, senderId, message, distance = os.pullEvent("rednet_message")<br />
print( "Computer: "..senderId.." sent a message: "..message.." from "..distance.." blocks away!" )<br />
end<br />
}}<br />
{{Example<br />
|desc=Ignores messages from any computer other than the one with id 5<br />
|code=<br />
while true do<br />
event, senderId, message, distance = os.pullEvent("rednet_message")<br />
if senderId == 5 then<br />
print("Got a message from the boss saying: "..message)<br />
end<br />
end<br />
}}</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Shell.clearAlias&diff=5647Shell.clearAlias2013-05-12T02:13:41Z<p>TheVarmari: I should really check the notes before saving...</p>
<hr />
<div>{{Function<br />
|name=shell.clearAlias<br />
|args= {{type|string}} alias, {{type|string}} program<br />
|api=shell<br />
|returns=[[nil]]<br />
|addon=ComputerCraft<br />
|desc=Clears an alias.<br />
|examples={{Example<br />
|desc=Clears the alias "start" for program "startup".<br />
|code=shell.clearAlias("start", "startup")<br />
}}<br />
<br />
|notes=<br />
* It does not output anything, it just clears the alias.<br />
}}</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Shell.clearAlias&diff=5646Shell.clearAlias2013-05-12T02:12:59Z<p>TheVarmari: Added function page</p>
<hr />
<div>{{Function<br />
|name=shell.clearAlias<br />
|args= {{type|string}} alias, {{type|string}} program<br />
|api=shell<br />
|returns=[[nil]]<br />
|addon=ComputerCraft<br />
|desc=Clears an alias.<br />
|examples={{Example<br />
|desc=Clears the alias "start" for program "startup".<br />
|code=shell.clearAlias("start", "startup")<br />
}}<br />
<br />
|notes=<br />
* It does not output anything, it just sets the alias.<br />
}}</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Shell.setAlias&diff=5645Shell.setAlias2013-05-12T02:11:36Z<p>TheVarmari: Changed program argument from optional to required. My bad.</p>
<hr />
<div>{{Function<br />
|name=shell.setAlias<br />
|args= {{type|string}} alias, {{type|string}} program<br />
|api=shell<br />
|returns=[[nil]]<br />
|addon=ComputerCraft<br />
|desc=Sets an alias.<br />
|examples={{Example<br />
|desc=Sets the alias for program "startup".<br />
|code=shell.setAlias("start", "startup")<br />
}}<br />
<br />
|notes=<br />
* It does not output anything, it just sets the alias.<br />
}}</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Shell.setAlias&diff=5644Shell.setAlias2013-05-12T02:10:22Z<p>TheVarmari: Added function page</p>
<hr />
<div>{{Function<br />
|name=shell.setAlias<br />
|args= {{type|string}} alias [, {{type|string}} program]<br />
|api=shell<br />
|returns=[[nil]]<br />
|addon=ComputerCraft<br />
|desc=Sets an alias.<br />
|examples={{Example<br />
|desc=Sets the alias for program "startup".<br />
|code=shell.setAlias("start", "startup")<br />
}}<br />
<br />
|notes=<br />
* It does not output anything, it just sets the alias.<br />
}}</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=User:TheVarmari&diff=4471User:TheVarmari2012-12-02T09:10:31Z<p>TheVarmari: </p>
<hr />
<div>I'm the guy who fixes your mistakes. In a mean, mean way.</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Advanced_Turtle_Lumberjack_(tutorial)&diff=643Advanced Turtle Lumberjack (tutorial)2012-02-26T14:25:56Z<p>TheVarmari: Created page with " == Advanced Turtle Lumberjack == === Introduction === Welcome to this tutorial about Advanced Turtle Lumberjacks. See the [[Turtle_Lumberjack_(tutoria..."</p>
<hr />
<div><br />
== Advanced Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [[:Category:Tutorials|tutorial]] about Advanced Turtle Lumberjacks.<br />
See the [[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack Tutorial]] first.<br />
<br />
=== What are Advanced Turtle Lumberjacks? ===<br />
Advanced Turtle Lumberjacks are basically [[Turtle_Lumberjack_(tutorial)|Turtle Lumberjacks]] that can dig blocks above them.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
<br />
This makes us loop until there is no blocks in front of the turtle.<br />
<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
end<br />
</code><br />
<br />
This makes it dig the block. Now we make it see if there is a block ABOVE it.<br />
<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
if turtle.detectUp()<br />
turtle.digUp()<br />
end<br />
end<br />
</code><br />
<br />
This makes us dig the block above if there is one.<br />
Let's make us move up.<br />
<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
if turtle.detectUp()<br />
turtle.digUp()<br />
turtle.up()<br />
end<br />
end<br />
</code><br />
<br />
Now, let's make it come back down when there is no blocks to be digged.<br />
<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
if turtle.detectUp()<br />
turtle.digUp()<br />
turtle.up()<br />
end<br />
end<br />
while not turtle.detect() and not turtle.detectUp() and turtle.detectDown() do<br />
turtle.down()<br />
end<br />
</code><br />
<br />
This makes us check if there are no blocks to be digged, then we go down until we can't.<br />
That's it!<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[[Category:Tutorials]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=642Turtle Lumberjack (tutorial)2012-02-26T14:16:37Z<p>TheVarmari: /* The Code */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [[:Category:Tutorials|tutorial]] about Turtle Lumberjacks.<br />
<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[[Category:Tutorials]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=641Turtle Lumberjack (tutorial)2012-02-26T14:15:33Z<p>TheVarmari: /* Introduction */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [[:Category:Tutorials|tutorial]] about Turtle Lumberjacks.<br />
<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[[Category:Tutorials]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=640Turtle Lumberjack (tutorial)2012-02-26T14:14:12Z<p>TheVarmari: /* Category & Author */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this Tutorial about Turtle Lumberjacks.<br />
<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[[Category:Tutorials]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=639Turtle Lumberjack (tutorial)2012-02-26T14:13:47Z<p>TheVarmari: /* Introduction */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this Tutorial about Turtle Lumberjacks.<br />
<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[Category:Tutorials]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=638Turtle Lumberjack (tutorial)2012-02-26T14:13:24Z<p>TheVarmari: /* Introduction */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [[Category:Tutorials|Tutorials]]] about Turtle Lumberjacks.<br />
<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[Category:Tutorials]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=637Turtle Lumberjack (tutorial)2012-02-26T14:12:52Z<p>TheVarmari: /* Introduction */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [[Category:Tutorials|tutorial]] about Turtle Lumberjacks.<br />
<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[Category:Tutorials]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=636Turtle Lumberjack (tutorial)2012-02-26T14:12:09Z<p>TheVarmari: /* Turtle Lumberjack */</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [Category:Tutorials|tutorial] about Turtle Lumberjacks.<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[Category:Tutorials]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Turtle_Lumberjack_(tutorial)&diff=635Turtle Lumberjack (tutorial)2012-02-26T14:11:53Z<p>TheVarmari: Created page with " == Turtle Lumberjack == === Introduction === Welcome to this tutorial about Turtle Lumberjacks. === What are Turtle Lumberjacks? === Turtle Lumberjacks..."</p>
<hr />
<div><br />
== Turtle Lumberjack ==<br />
=== Introduction ===<br />
Welcome to this [[Category:Tutorials|tutorial]] about Turtle Lumberjacks.<br />
=== What are Turtle Lumberjacks? ===<br />
Turtle Lumberjacks are mining turtles that are programmed to chop down a tree.<br />
They are placed in front of a tree and then activated, and then you watch the tree get chop down!<br />
This can be also used to destroy pillars of sandstone, sand etc.<br />
<br />
== The Code ==<br />
First, we start with the basics.<br />
<code><br />
while turtle.detect() do<br />
<br />
end<br />
</code><br />
This makes it loop while there is a block in front of it.<br />
Let's add the digging part to it.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
turtle.up()<br />
end<br />
</code><br />
This makes it dig the block if it is detected, then move up.<br />
Let's add the print function to print what the turtle is doing.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
</code><br />
There we go!<br />
Let's make it come back down when there is no more blocks to be chopped, or there is a roof above it!<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
</code><br />
This makes it check that while there are no blocks to be chopped and it can go down, it goes down.<br />
Let's add a notification about the job being done.<br />
<code><br />
while turtle.detect() do<br />
turtle.dig()<br />
print("Digging the block")<br />
turtle.up()<br />
print("Moving up")<br />
end<br />
<br />
while not turtle.detect() and not turtle.detectDown() do<br />
turtle.down()<br />
print("Moving down")<br />
end<br />
<br />
print("Job done!")<br />
</code><br />
<br />
There you go! Now it is done!<br />
Your turtle will dig the tree down and then come back down.<br />
<br />
('''Helpful tip:''' Save this to your computercraft/lua/programs folder, then it will be on all turtles.)<br />
<br />
== Category & Author ==<br />
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!<br />
[Category:Tutorials]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=338Making an API (tutorial)2012-02-22T17:05:48Z<p>TheVarmari: /* A couple of words */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code><br />
os.loadAPI("exampleAPI")<br />
</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code><br />
exampleAPI.printMessage()<br />
</code><br />
Ta-da! It printed out "message"!<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did! <br />
[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)<br />
<br />
[[Category:Tutorials]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=337Making an API (tutorial)2012-02-22T17:05:08Z<p>TheVarmari: </p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code><br />
os.loadAPI("exampleAPI")<br />
</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code><br />
exampleAPI.printMessage()<br />
</code><br />
Ta-da! It printed out "message"!<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)<br />
<br />
[[Category:Tutorials]]</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=336Making an API (tutorial)2012-02-22T17:01:57Z<p>TheVarmari: /* Using the API */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code><br />
os.loadAPI("exampleAPI")<br />
</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code><br />
exampleAPI.printMessage()<br />
</code><br />
Ta-da! It printed out "message"!<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=335Making an API (tutorial)2012-02-22T17:01:40Z<p>TheVarmari: /* Including the API */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code><br />
os.loadAPI("exampleAPI")<br />
</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code>exampleAPI.printMessage()</code><br />
Ta-da! It printed out "message"!<br />
<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=334Making an API (tutorial)2012-02-22T17:01:19Z<p>TheVarmari: /* The code */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code>os.loadAPI("exampleAPI")</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code>exampleAPI.printMessage()</code><br />
Ta-da! It printed out "message"!<br />
<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=333Making an API (tutorial)2012-02-22T17:01:07Z<p>TheVarmari: /* The code */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code>os.loadAPI("exampleAPI")</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code>exampleAPI.printMessage()</code><br />
Ta-da! It printed out "message"!<br />
<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=332Making an API (tutorial)2012-02-22T17:00:57Z<p>TheVarmari: /* The code */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code>os.loadAPI("exampleAPI")</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code>exampleAPI.printMessage()</code><br />
Ta-da! It printed out "message"!<br />
<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=331Making an API (tutorial)2012-02-22T17:00:47Z<p>TheVarmari: /* The code */</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<code><br />
-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code>os.loadAPI("exampleAPI")</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code>exampleAPI.printMessage()</code><br />
Ta-da! It printed out "message"!<br />
<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Making_an_API_(tutorial)&diff=330Making an API (tutorial)2012-02-22T16:59:54Z<p>TheVarmari: Created page with " == MAKING AN API - a tutorial by TheVarmari == '''NOTE:''' There is a better tutorial in the forums. Use this if you prefer to use ccwiki. == Introduction == Hello, dear Co..."</p>
<hr />
<div><br />
== MAKING AN API - a tutorial by TheVarmari ==<br />
'''NOTE:''' There is a better tutorial in the forums.<br />
Use this if you prefer to use ccwiki.<br />
<br />
<br />
== Introduction ==<br />
Hello, dear Computercraft Wiki user!<br />
Today I will tell you how to make an functioning API.<br />
Let's get started!<br />
<br />
<br />
== Making the API file ==<br />
First we need to define what our API will be called.<br />
In this case, I use exampleAPI.<br />
Now edit the file you want your API to be called.<br />
''NOTE: If it exists, call it something else''<br />
<br />
=== The code ===<br />
Now, we need to put some functions in it!<br />
Why don't we start with the basics;<br />
<code>-- this is the file exampleAPI<br />
-- our first function:<br />
function printMessage()<br />
print("message")<br />
end<br />
</code><br />
Which basically prints "message" when excecuted.<br />
Save the file.<br />
<br />
=== Including the API ===<br />
Now that we have the API done, let's include it in some file!<br />
Because we speak about APIs, we do it the proper way.<br />
No shell.run's!<br />
<br />
Edit the file you want to include the API in.<br />
In my case, it is called exampleFile.<br />
Now, we include the API in it by typing this to the '''first''' row:<br />
<code>os.loadAPI("exampleAPI")</code><br />
This loads the API into the file's memory.<br />
''NOTE: You have to do this for every file you include it in.<br />
CC doesn't have long-term memory.''<br />
<br />
=== Using the API ===<br />
Now that that's over, let's include the printMessage command from our API.<br />
Lua loads API's as tables, so you have to use api_name.function_name(function_arguments)<br />
<br />
In my case, I use<br />
<code>exampleAPI.printMessage()</code><br />
Ta-da! It printed out "message"!<br />
<br />
<br />
== A couple of words ==<br />
Thank you for reading this tutorial, it sure was fun to make!<br />
Correct any mistakes I did,<br />
--[[User:TheVarmari|TheVarmari]] 16:59, 22 February 2012 (UTC)</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=Computer&diff=294Computer2012-02-18T20:07:29Z<p>TheVarmari: </p>
<hr />
<div>The console is the main block of ComputerCraft. This is the titular computer, which is the centerpiece of this mod.[[File:J4wd7.png|frame|right|The recipe for a console.]]<br />
<br />
[[Category:Blocks]]<br />
<br />
== Usage ==<br />
Place the console wherever you please, and just right click it to use.<br />
<br />
=== Keyboard Shortcuts ===<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
!style="background:#EEE" width="200px"|Shortcut<br />
!style="background:#EEE" width="*"|Usage<br />
|-<br />
|CTRL + T<br />
|Terminates the current program.<br />
|-<br />
|CTRL + R<br />
|Reboots the console.<br />
|-<br />
|CTRL + S<br />
|Forcefully shuts down the computer.<br />
|}<br />
NOTE: You have to hold the keyboard shortcuts down for atleast 1 second!</div>TheVarmarihttp://www.computercraft.info/wiki/index.php?title=User:TheVarmari&diff=219User:TheVarmari2012-02-04T19:29:28Z<p>TheVarmari: Created page with "'''TheVarmari''' ''Dat random guy that does random things with lua'' --~~~~"</p>
<hr />
<div>'''TheVarmari'''<br />
''Dat random guy that does random things with lua''<br />
<br />
--[[User:TheVarmari|TheVarmari]] 19:29, 4 February 2012 (UTC)</div>TheVarmari