Digilines

A complete guide to Lua controllers can be found at: http://mesecons.net/luacontroller
Some of the crafting recipes are different.

The Noobs Guide to Digilines

written by Sivarajan (but grammar fixed by 56independent),
published by Banana publications, Grapeyard superb.

Third edition.
All the live Apparatus are presented in automation museum

Preface

Hey this is sivarajan. I'm happy to present to you the Digiline tutorial page. This contains all the basics for a beginner to meddle with digilines. Digilines are powerful tools used for sending and receiving data, and conducting through wires. I hope this book will be a guide to begin Digilines. Thanks for reading this book.

Chapter 1 : Introduction.

Digilines is a mod by Jieja. It consists of:
  1. RTC (Real Time Clock): to get the in-game time.
  2. LCD : display text.
  3. light sensor: for sensing light level.
  4. Chest: inform players what is inside it .

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.

Crafting:
Look at your inventory for details.

Chapter 2 : Hello world

Apparatus required:
  1. Lua controller
  2. digiline cable
  3. digiline LCD display.
Crafting digiline: Steps to print hello world with Lua controller circuit:
  1. Place the LCD and Lua contoller
  2. right click the digiline LCD
  3. set the channel to "tv". Click proceed
  4. connect the digiline LCD to the lua controller via digilines
  5. right click the Lua controller.
  6. Type the following:
    digiline_send("tv","Hello World!")
  7. The format to print a string on the digiline Display is :
    digiline_send("<channelname>","<message>")
  8. click execute to run the code. "Hello world" is printed on LCD.

Chapter 2 : your own digiline Clock:

Required aparatus:
  1. LUA controller
  2. Digiline Display
  3. Digiline Wire
Circuit:
(if you have destroyed your previous Apparatus, skip the following) place the lcd, and set the channel to "tv". place a luacontroller, somewhere else, and connect them both using a digline wire. Program:
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

Chapter 3: Communication between two or more LUA controllers using Digiline.

Introduction: we can send or process the digiline signals by using a Lua controller.

Connection: Connect the Lua controllers with digilines. Also connect the Slave Lua controller to the LCD display. Set the channel of the LCD to "TV". Code:

  1. Master/sender:
    digiline_send("ch","Hi")
  2. Slave:
        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 consists of :
    
        event ={
        type =""
        [Variables] =[values]
        }
    
        here the received event table will be
        event={
            type = "digiline",
            channel ="ch"
            msg ="hi"
        }]]
        

Click Execute on Slave first and then click execute on Master. you can see the following output:

Channel:ch
Message: hi
--slave controller

Note : a digiline message ie event.msg. can be in the form of a Table. it must be noted that we cannot print a table. We can only print a particular value of the table. Say this code is executed by the master digiline

digiline_send("ch",{a=1,b=2})

--[[In that case the Table will be
event = {
    type ="digiline"
    msg= {
        a=1,
        b=2
        }
    }  ]]

So if we try to print the msg on a digiline display, it will show 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.

Chapter 4: Digline Injector and Autocrafter

Introduction : these come with pipeworks.

4.1 Auto crafter

Introduction: the autocrafter is a useful tool when it comes to automation. If you put a crafting recipe in the 3*3 box, and place materials in the large box at the bottom, it will commence automatically crafting stuff (hence its name).

To control auto crafter using lua controller:

  1. Place Lua controller near the Autocrafter/ Connect them with digiline wire.
  2. In auto crafter type the channel name (say c).
  3. Now the format to send the craft recipe is
    digiline_send("<channel>",{
    {"node1","node2","node3"}
    , {"node4","node5","node6"}
    ,{"node7","node8","node9"}})

Note: if there should be no node in the grid type e in place of nodeN format of nodeN is modname:nodename it can be checked in the inventory.

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.

4.2 Injectors

Craft a digiline injector and connect it with lua controller. Now here is the digiline requests format to be sent to injector:

{
    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.
}

Some example code:
  1. Operating as a stack wise injector:
    interrupt(1) -- pulse delay
    if event.type == "interrupt" then
        digline_send("injector",{}) --or {count =99}
    end
  2. Operating it as an item wise injector:
    interrupt(1)
    if event.type =="interrupt" then
        digline_send("injector",{count =1})
    end
  3. Send only default:stone by the injector.
    interrupt(1)
    if event.type=="interrupt" then
        digline_send("injector",{name="default:stone"})
    end 

Chapter 5: Digiline Chest

Introduction: A digiline chest is a powerful node that says what stuff is put/moved/taken from it.

let's see how the event tables look by seeing examples.

Here the digiline channel for all event table will be "d".

  1. A node (Default:stone99):
    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 is the condition of the tool
        },
        action = "uput",
        to_slot = 1 --denotes which slot the stuff is
        }
    }
    
  2. A Technic node with charge (Blue energy Crystal)
    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
        }
    }
    
  3. A book with Title "my book" of content: hello world
    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 players 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
        }
    }
    

Note:

here :

action takes the value :

"uput" - when you put stuff inside the chest.

"tput" - when a tube puts stuff inside the chest.

"empty" - when digiline chest is empty*.

"utake"- when you take stuff from inside the chest.

"ttake" - when a tube takes stuff from inside the chest.

"full" - when the digiline chest is full*

"umove"- moving stuff from one slot to another.

* /!\ be careful : "empty" and "full" action messages are sent just after "*take" and "*put" one !

from_slot says from which slot the node is moved

to_slot says in which slot the node is placed.

from_slot is available when moving a stuff inside the chest.

Chapter 6 Digilines and Technic

This chapter describes how to interface technic components to digilines. We can get the data of these technic machines to make useful things like a system that warns when the supply is at 0.

6.1 Switches

A switching station is an important node that connects all of your techinc components. It sends the EU (Electronic Units) 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 :

event{
    type="digiline",
    channel=""
    msg={
        supply = (integer value)
        demand = (integer value)
    }
}
--Before, you must send GET String to the switching station. This is decribed in 1.4.

6.2 Supply converter

It converts HV power to LV power, MV to LV,HV to MV Vise versa.(MV is not available in this server). The Channel of the converter can be set by right clicking on it and renaming the default channel. General form of Event table:

event ={
type= "digiline"
msg={
	mesecon_mode = (intergervalue),
	enabled = (integervalue),
	power = (integervalue)
    }
}

Messages that can be sent:
1. "on": turn on the power supply
2. "off": turn off the supply
3. "toggle": Change the state of supply
4. "GET": get the state of supply converter(returned as a Table).

6.3 Batteries

HV and Lv batteries store charge here is example table for that:

event ={
    type = "digiline",
    channel = "",
    msg = {
        input = (integer),
        --input voltage
        supply = 40000,-
        --upgrade 1 and 2 are availabe only for HV tools
        upgrade1 = {
            meta = {

            },
            metadata = "",
            count = 1,
            name = "",
            -- 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\"] = }",
            count = 1,
            name = "technic:",
            wear = (integervalue)
        }
    }
}

6.4 Interfacing Technic and Digiline

This is an example for using techic data in digiline. Here we are printing the demand in a digiline LCD

Items required:

  1. Blinky Plant.
  2. Any Technic node. In this case, a Switching station.
  3. Digiline LCD.
  4. LUA controller.
  5. Digiline and Mesecon wires.

Procedure:

  1. Connect the switching station and digiline display seperately with Lua Controller and digiline cable.
  2. Connect blinky plant in seperate port with mesecon wire.
  3. Assign the channel Name of the switching station and LCD as ch and LCD respectively or any name that you prefer.

Program:

-- 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