web/tutorials/digilines.html

416 lines
13 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script language="javascript" src="../js/main.js"></script>
<script language="javascript">
start_page("../"); //path to root direction
</script>
<h1>Digilines</h1>
A complete to Lua controller can be found at: <a href="http://mesecons.net/luacontroller/">http://mesecons.net/luacontroller</a><br>
Some of the crafting recipes are different.
<h1>Noobs Guide to Digilines</h1>
written by,<br>
Sivarajan.<br>
published by Banana publications, Grapeyard superb.<br>
<br>
Third edition.<br>
All the live Apparatus are presented in automation museum
<h2>Preface</h2>
<p>
Hey this is sivarajan. I'm happy to present you the Digiline page. This contains all the basics for a beginneer to middle with digilines. Digilines are powerful tool for sending and receiving data , counducting the stuffs. I hope this book will be a guilde to begin Diglines. Thanks for reading this book.
<h2>Chapter 1 : Introduction.</h2>
Digiline is a mod by Jieja. It consist of:<ol>
<li>RTC (Real Time Clock): to get in-game time.
<li>LCD : display text.
<li>light sensor: for sensing light level.
<li>Chest: it can be used to inform players what is inside it .
</ol><p>
Some mods that use diglines:Digiterms(not included in this server), Pipeworks , Technic , Mescons.
Mesecons are needed since we need Lua controller to control our Diglines.
<p>Crafting:
<br>Look at your inventory for details.
<ul>
<li><a href="http://mesecons.net/luacontroller">A guide to use lua controller</a>
<li><a href="https://www.tutorialspoint.com/lua/index.htmc">Lua tutorials</a>
</ul>
<h2>Chapter 2 : Hello world.</h2>
Apparatus used
<ol>
<li>Lua controller
<li>digiline cable
<li>digiline LCD display.
</ol>
Crafting digiline:
<script language="javascript">
images = [
{img:"digiline_lcd.png", txt:"Digiline LCD"},
{img:"digiline_digiline.png", txt:"Digiline wire"},
{img:"digiline_lua.png", txt:"Lua controller"},
];
galery(images, "200px");
</script>
Steps to print hello world with Lua controller circuit: <ol>
<li>Place LCD and Lua contoller
<li>right click the digiline LCD.
<li>set the channel name say "tv". Click proceed
<li>then connect the digiline LCD with lua controller
<li>right click the Lua conttoller.
<li>Type the following: <pre>digiline_send("tv","Hello world")</pre>
<li>The format to print a string in digiline Display is : <pre>digiline_send("&lt;channelname&gt;","&lt;message&gt;")</pre>
<li>click execute to run the code. There you go "Hello world" is printed on LCD.
</ol>
<h2>Chapter 2 : your own digiline Clock:</h2>
Required aparatus: <ol>
<li>LUA controller
<li>Digiline Display
<li>Digiline Wire
</ol>
Circuit:<br>
Connect the digiline and lua controller with using Digiline Wire
Program:<pre>
interrupt(1)
if event.type== "interrupt" then
time = os.datetable()
-- this is a built in fuction that returns time
digiline_send("tv",time.hour..":"..time.min..":"..time.sec)
-- to run press execute in lua controller
end
</pre>
<h2>Chapter 3: Communication between two or more LUA controllers using Digiline.</h2>
<p>Introduction: we can send or process the digiline signals by using a Lua controller.
<p>Connection:
Connect the Lua controllers with proper digiline cables. Also connect the Slave Lua controller with LCD display. Set the channel of LCD. Say TV here.
Code:<ol>
<li> Master/sender:<br>
<pre>digiline_send("ch","Hi")</pre> </li>
<li>Slave:
<pre>
if event.type =="digiline" then
--TV is channel of LCD
digiline_send("TV","channel: " .. event.channel ..
"message: " .. event.msg)
end
--[[Where: Event is a table generated by the lua controller when a
particular event is recoginzed by the LUA controller. It consist of :
event ={
type ="<eventtype>"
[Variables] =[values]
}
here the received event table will be
event={
type = "digiline",
channel ="ch"
msg ="hi"
}]]
</pre>
</li>
</ol>
<p>Click Execute on Slave first and then click execute on Master.
you can see the following output:
<pre>
Channel:ch
Message: hi
--slave controller
</pre>
<p>
Note : a digiline message ie event.msg. can be in form of a Table so it must be noted that we cannot print a table. We can only print the pariticular value of table.
Say this code is executed by the master digiline
<pre>
digiline_send("ch",{a=1,b=2})
--[[In that case the Table will be
event = {
type ="digiline"
msg= {
a=1,
b=2
}
} ]]
</pre>
<p>So if we try to print the msg on a digiline display, it will show up an error: Message is too complex. But you can print a table to the command line (works if you have server privs). by using print()
function in Lua.Note that minetest must be started using commandline.Or you can use digiline termial to print values
<h2>Chapter 4: Digline Injector and Autocrafter</h2>
<p>Introduction : these come with pipeworks.
<h3>4.1 Auto crafter</h3>
<p>Introduction: auto crafter is a useful tool when it comes to automation
If you set the craft receipe and trun it on and feed in items, It crafts stuffs according to the guide.
<p>To control auto crafter using lua controller:<ol>
<li>Place Lua controller near the Autocrafter/ Connect them with digline wire.
<li>In auto crafter type the channel name (say <span class="alt">c</span>).
<li>Now the format to send the craft receipe is <br>
<pre>digiline_send("&lt;channel&gt;",{
{"node1","node2","node3"}
, {"node4","node5","node6"}
,{"node7","node8","node9"}})</pre>
</ol>
<p>Note: if there should be no node in the grid type e in place of nodeN
format of nodeN is <span class="alt">modname:nodename</span>
it can be checked in the inventory.
<p>after clicking execute the code.
send "on " to the appropriate digiline chanel to turn it on.
send "off" to the appropriate chanel to turn it off.
<h3>4.2 Injectors</h3>
<p>Craft a digline injector and connect it with lua controller.
Now here is the digiline requests format to be sent to injector:<br>
<pre>
{
slotseq = "priority",
-- priority | random | rotation
exmatch = true,
-- true | false
name = name,
-- here we give the node name to be sent.
count = count,
-- no of count of node to be sent.
}</pre><br>
Some example codes:<ol>
<li> Operating it as stack wise injector <pre>
interrupt(1) -- pulse delay
if event.type == "interrupt" then
digline_send("injector",{}) --or {count =99}
end</pre>
<li> Operating it as item wise.<pre>
interrupt(1)
if event.type =="interrupt" then
digline_send("injector",{count =1})
end</pre>
<li> Send only default:stone by the injector. <pre>
interrupt(1)
if event.type=="interrupt" then
digline_send("injector",{name="default:stone"})
end </pre>
</ol>
<h2>Chapter 5: Digiline Chest</h2>
<p>Introduction: A digiline chest is a powerful node that says what stuff is put/moved/taken from it.
<p>let us see how the event tables look like by seeing examples.
<p>Here the digiline channel for all event table will be "d".
<ol>
<li>A node (Default:stone99):
<pre>
event = {
type = "digiline",
channel = "d",
msg = {
stack = {
meta = {
-- this field contains additonal memory for the node
},
metadata = "",
count = 99,
name = "default:stone",
--name and count will chage according to the node
wear = 0
-- this says about the condition of tool
},
action = "uput",
to_slot = 1 --denotes which slot the stuff is
}
}
</pre>
<li>A Technic node with charge (Blue energy Crystal)
<pre>
event ={
type = "digiline",
channel = "d",
msg = {
stack = {
meta = {
},
metadata = "return {[\"charge\"] = 450000}",
-- charge tells the amout of charge that crystal
count = 1,
name = "technic:blue_energy_crystal",
wear = 1
},
action = "uput",
to_slot = 2
}
}
</pre>
<li>A book with Titile "my book" of content:
hello world
<pre>
event ={
type = "digiline",
channel = "d",
msg = {
stack = {
meta = {
owner = "sivarajan",
title = "my book",
page_max = "1",
text = "hello \ world",
-- \represents a new line in a book
page = "1",
description = "\27(T@default)\"\27Fmy book\27E\" by \27Fsivarajan\27E\27E"
--this is the text shown to other player viewing the book
},
metadata = "",
count = 1,
name = "default:book_written",
wear = 0
},
action = "umove",
from_slot = 11,
-- when moving stuff read the Notes
to_slot = 3
}
}
</pre>
</ol>
<h3>Note:</h3>
<p>
here :
<p>action takes the value :
<p> "uput" - when you put stuffs .
<p> "tput" - when a tube put stuffs.
<p> "empty" - when digi-chest is empty*.
<p> "utake"- when you take stuffs.
<p> "ttake" - when a tube take stuffs.
<p> "full" - when digi-chest is full*
<p> "umove"- moving stuffs from one slot to another.
<p> * /!\ be careful : "empty" and "full" action messages are send just after "*take" and "*put" one !
<p>from_slot says from which slot the node is moved
<p>to_slot says in which slot the node is placed.
<p>from_slot is available when moving a stuff inside the chest.
</p>
<h2>Chapter 6 Digilines and Technic</h2>
<p>This chapter describes how to use interface technic components to digiline.We can get the data of these technic machine to make useful things like a system that warns when supply is 0.
<h3>6.1 Switches</h3>
<p>A swtiching station is a important node that connects the all of your techinc components. It sends the EU supply and Eu demand to the digiline controller (LUA controller). A channel name for a switching station can be set by right clicking on it. Its event table will be in form of :
<pre>
event{
type="digiline",
channel="<channelname>"
msg={
supply = (integer value)
demand = (integer value)
}
}
--Before that you must send GET String to the switching station. This is decribed in 1.4.
</pre>
<h3>6.2 Supply converter</h3>
<p>It converts HV power to LV power, MV to LV,HV to MV Vise versa.(MV is not available in this server). Channel of digiline can be set by right clicking on it and rename the default channel name.General form of Event table:
<pre>
event ={
type= "digiline"
msg={
mesecon_mode = (intergervalue),
enabled = (integervalue),
power = (integervalue)
}
}
</pre>
<p>
Message can be sent:<br>
1. "on": turn on the power supply <br>
2. "off": turn off the supply <br>
3. "toggle": Change the state of supply<br>
4. "GET": get the state of supply converter(returned as a Table).<br>
</p>
<h3>6.3 Batteries</h3>
<p>HV and Lv batteries store charge here is example table for that:</p>
<pre>
event ={
type = "digiline",
channel = "<channel>",
msg = {
input = (integer),
--input voltage
supply = 40000,-
--upgrade 1 and 2 are availabe only for HV tools
upgrade1 = {
meta = {
},
metadata = "",
count = 1,
name = "<modname:node>",
-- here the node will be a valid upgrade node
wear = 0
},
upgrade2 = {
meta = {
},
metadata = "",
count = 1,
name = "technic:battery",
wear = 0
},
demand = (integervalue)
charge = (integer value),
-- amount of charge it contains
max_charge = (integer),
-- maximum charge
src = {
meta = {
},
metadata = "return {[\"charge\"] = <integer>}",
count = 1,
name = "technic:<toolname>",
wear = (integervalue)
}
}
}
</pre>
<h3>6.4 Interfacing Technic and Digiline</h3>
<p>This is an example for using techic data in digiline. Here we are printing the demand in a digiline LCD</p>
<p>Apparatus required:
<ol>
<li>Blinky Plant.
<li>Any Technic node.Here it is Switching station.
<li>Digiline LCD.
<li>LUA controller.
<li>Digiline and Mesecon wires.
</ol>
<p>Procedure:
<ol>
<li> Connect switcting station and digiline display seperately with Lua Controller with digiline cable.
<li> Connect blinky plant in seperate port with mesecon wire.
<li> Assign the channel Name of the switching station and LCD as ch and LCD respectively or any name that you prefer.
</ol>
<p>Program:
<pre>
-- change the channel according to your needs
if event.type=="program" or event.type =="on" then
-- event on triggered when mesecon signal is obtained by Lua Controller
-- event program is triggered when execute button is clicked
digiline_send("ch","GET") --sending GET to ch
elseif event.type =="digiline" then
digiline_send("LCD",event.msg.demand)
end
</pre>
<script language="javascript">
end_page();
</script>
</html>