So here begins your journey into how to create some simple programs. We will first start out by saying how Toribash runs the script file. If we take the example in the last tutorial:
echo("Hello!")
result = 4+4
echo("4 + 4 is " .. result)
So here begins your journey into how to create some simple programs. We will first start out by saying how Toribash runs the script file. If we take the example in the last tutorial:
echo("Hello!")
result = 4+4
echo("4 + 4 is " .. result)
This tutorial is about using and creating 'scripts' in Toribash. In this first tutorial I will be covering what scripts are, how to use them, how they are made and what tools you will need to make them.
There is a very simple exercise at the end of the tutorial that will test what you have learned.
The proceeding tutorials will then go into detail about how to make scripts, including going over the basics of programming.
These tutorials are created for people with no experience in programming, but are also recommended for people who know programming but are not sure in how to create scripts specifically for Toribash
| import socket | |
| import threading | |
| # Shamelessly stolen from: http://stackoverflow.com/questions/5179467/equivalent-of-setinterval-in-python | |
| def setInterval(interval): | |
| def decorator(function): | |
| def wrapper(*args, **kwargs): | |
| stopped = threading.Event() | |
| def loop(): # executed in another thread |
| Timer = { } | |
| Timer.__index = Timer | |
| Timer.Count = 0 | |
| function Timer.New(Time, Recurring,Function) | |
| Timer.Count = Timer.Count + 1 | |
| local timer = { } | |
| setmetatable(timer,Timer) | |
| timer.ref = Timer.Count | |
| timer.interval = Time |
| # Made by Blam of the Toribash community | |
| # Anyone is free to use, modify and do whatever they want to this code | |
| import socket, threading, re | |
| import string | |
| import datetime | |
| print "Announce Bot 1.0" | |
| # Shamelessly stolen from http://stackoverflow.com/questions/1551382/user-friendly-time-format-in-python |
| def getBouts(name): | |
| bsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| bsocket.connect(("176.9.64.22", 22000)) | |
| buffer = bsocket.recv(4096) | |
| done = False | |
| inserver = False | |
| ip = "" | |
| lastCount = 0 | |
| clients = None | |
| while not done: |
| --dofile("dbg.lua") | |
| -- start of graph class | |
| graph = { | |
| LINE = 0, BAR = 1, | |
| Colors = { {1,0,0,0.4}, {0,0,1,0.7}, {0,1,1,0.7}, {1, 0, 1,0.7}, {1, 1, 0, 0.7}, {0, 0.7, 0, 0.7}, {1, 0.5, 0, 0.7}} | |
| } | |
| graph.__index = graph | |
| function graph.new(gtype, x, y, width, height, max) |
| #!/usr/bin/env ruby | |
| ## Bot, sits in TB server and pings periodically to | |
| ## remain connected. Parses SAY strings for globals | |
| require 'socket' | |
| require 'digest/md5' | |
| require 'io/wait' | |
| def resolver(server) | |
| puts "Trying to resolve #{server} to IP..." |
| //REPL Script 1.1 | |
| #module <Ax/STD.dll> // Needed for console output | |
| #module <Ax/Exit.dll> // Needed for exit hook | |
| // Exit Handler function. | |
| // Whenever the script is stopped this function is called. | |
| // It can be used to catch errors and continue the script. | |
| ~(exit: type error | | |
| ( |
| List<String> groups = new ArrayList<String>(); | |
| groups.add(strLine); |