the settings
Code: Select all
KOH_SCORE 1
KOH_SCORE_TIME 5
Code: Select all
SPAWN_ZONE koh posx posy radius growth xdir ydir interactive(1 or 0) r g b target_size
a sample script wrote in python
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
from sys import stdout, stdin
from os import stat
from time import sleep, time
from random import randint
from re import match
########################################################################
## Configuration setting ##
########################################################################
# file_paths
ladderlog = '/path/to/ladderlog.txt'
output_file='/path/to/cmds.txt' # file to read into server
# miscellaneous settings
next_round=0
game_time=-5
# Create a string from a a position in an array to the end of array
def g_build_string(array, startval):
str=""
for i in range(startval, len(array)):
str += array[i]
str += " "
return(str.strip())
#output the data to server
def o_writter(text):
stdout.write(text)
stdout.flush()
f = open(output_file, 'a')
f.write(text)
f.close()
file = open(ladderlog,'r')
st_results = stat(ladderlog)
st_size = st_results[6]
file.seek(st_size)
while 1:
where = file.tell()
line = file.readline()
if not line:
sleep(1)
file.seek(where)
else:
# START Strip the [L] if we are getting console log
game_end_last=False
if match("^\[L\]", line):
line = line.replace("[L]","", 1)
line = line.strip()
# END Strip the [L] if we are getting console log
# START PLAYER_ENTERED <player> <ip> <grid name>
if match("^PLAYER_ENTERED", line):
keywords = line.split()
o_writter("CONSOLE_MESSAGE 0xff1c15* 0xeeff00Welcome 0xff1c15%-15s 0xeeff00to Crazy Tronners King of the Hill. 0xff1c15*\n" % (g_build_string(keywords , 3) ))
# END PLAYER_ENTERED
# START GAME_TIME watch the game time to update settings based on time
if match("^GAME_TIME", line):
keywords = line.split()
game_time=int(keywords[1])
if (game_time == -1):
y=randint(0, 450)+25
x=randint(0, 450)+25
radius=randint(0, 15)+20
o_writter("SPAWN_ZONE n king koh "+str(x)+" "+str(y)+" "+str(radius)+" 0\n")
if (((game_time%25) == 0) and (game_time is not 0)):
o_writter("COLLAPSE_ZONE king\n")
y=randint(0, 450)+25
x=randint(0, 450)+25
radius=randint(0, 15)+20
o_writter("SPAWN_ZONE n king koh "+str(x)+" "+str(y)+" "+str(radius)+" 0\n")
# start of deadly bouncy balls
# END of GAME_TIME
# START ROUND_COMMENCING A new round is starting, let's prepare the following round.
if match("^ROUND_COMMENCING", line):
keywords = line.split()
# find the current map being played, for settings.
next_round=int(keywords[1])
if ( (next_round > int(keywords[2])) or (next_round < 0) ):
next_round=1
if ( next_round == int(keywords[2]) ):
o_writter("CENTER_MESSAGE Final Round \n")
else:
o_writter("CENTER_MESSAGE Round " + str(next_round) + " of " + keywords[2] + "\n")
sleep(1)