Skip to content

Instantly share code, notes, and snippets.

@blam23
blam23 / getbouts.py
Last active December 18, 2015 16:08
Gets all users in specified room, and the max count. Returns: * (maxCount, ip, [users], desc) * If it doesn't find anything it returns: * (-1, None, None, None) *
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:
@blam23
blam23 / bot.py
Last active December 18, 2015 17:29
Toribash <-> IRC bot
# 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
@blam23
blam23 / timer.lua
Created June 20, 2013 14:13
A timer class for Toribash Comes with helper functions that relate to javascript timing: setInterval, setTimeout, clearInterval, clearTimeout
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
@blam23
blam23 / silatnu.py
Last active December 18, 2015 19:18
Enables you to watch any toribash server that isn't password protected, while keeping your name out of the bout list. Note: The only people that can tell you are on the server are those that have access to the servers themselves. To use: First launch the .py file, type in the name of the server you want to join, in Toribash type '/co 127.0.0.1:9…
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
@blam23
blam23 / Toribash-Tutorial-Introduction.md
Last active December 19, 2015 23:08
The first in my Toribash Script tutorials.

Toribash Scripting Tutorial

What is this tutorial about?

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

Toribash Scripting Tutorial

Programming Basics

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)

How does the text become a program?

@blam23
blam23 / Toribash-Tutorial-Inserts-ConditionalOperators.md
Last active December 20, 2015 00:28
Conditional Operators Segment

I took this out of the main tutorial to keep the size down, and keep this accessible.

This is part of the Toribash Scripting Tutorial.

  • > - Greater Than - If the variable on the left is greater than the variable on the right, it's true. If they are equal or the left is smaller it's false.

      10 > 20 = false
      20 > 20 = false
      30 > 20 = true
    

While

A while loop will keep going round and round until it's condition is met. Conditions are explained in the "Conditional Statements" section of the [main tutorial][tut].

Here is an example of a while loop:

x = 1
while(x < 20) do
    x = x * 2
    echo("X: " .. x)

end

Toribash Scripting Tutorial

Programming Basics Part Two

In this tutorial I am going to be going to present another simple script, and then go through step by step how it works, breaking it down and explaining it.

This time I will be explaining about Conditional Statements, Loops, Array Types and Comments.

-- Run this script in multiplayer!
people = get_bouts()

for i = 1,#people do

@blam23
blam23 / animations.lua
Created July 21, 2013 19:36
A little and basic animations library and example usage.
-- (c) 2013 Blam
-- Animations.lua
animation = { }
animation.__index = animation
animation.all = { }
function animation.delay(frames)
local a = animation:new{
a = 0,