IndustryGS/ 40777 0 0 0 12217355443 6156 5 IndustryGS/info.nut 100777 0 0 3106 12032130446 7726 0 /*
* This file is part of IndustryGS, which is a GameScript for OpenTTD
* Copyright (C) 2012 Leif Linse
*
* IndustryGS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* IndustryGS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IndustryGS; If not, see or
* write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
require("version.nut");
class FMainClass extends GSInfo {
function GetAuthor() { return "Zuu"; }
function GetName() { return "IndustryGS"; }
function GetDescription() { return "Industry GS"; }
function GetVersion() { return SELF_VERSION; }
function GetDate() { return "2012-09-30"; }
function CreateInstance() { return "MainClass"; }
function GetShortName() { return "MINI"; }
function GetAPIVersion() { return "1.2"; }
function GetUrl() { return ""; }
function GetSettings() {
AddSetting({name = "log_level", description = "Debug: Log level (higher = print more)", easy_value = 3, medium_value = 3, hard_value = 3, custom_value = 3, flags = CONFIG_INGAME, min_value = 1, max_value = 3});
}
}
RegisterGS(FMainClass());
IndustryGS/lang/ 40777 0 0 0 12032130373 7063 5 IndustryGS/lang/english.txt 100777 0 0 46 12013010535 11311 0 STR_HELLO_WORLD :Hello {COMPANY}!
IndustryGS/main.nut 100777 0 0 7737 12217354021 7737 0 /*
* This file is part of MinimalGS, which is a GameScript for OpenTTD
* Copyright (C) 2012 Leif Linse
*
* MinimalGS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* MinimalGS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MinimalGS; If not, see or
* write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
/* Import SuperLib for GameScript */
import("util.superlib", "SuperLib", 24);
Result <- SuperLib.Result;
Log <- SuperLib.Log;
Helper <- SuperLib.Helper;
ScoreList <- SuperLib.ScoreList;
Tile <- SuperLib.Tile;
Direction <- SuperLib.Direction;
Town <- SuperLib.Town;
Industry <- SuperLib.Industry;
class MainClass extends GSController
{
_load_data = null;
constructor()
{
}
}
function MainClass::Start()
{
this.Init();
// Wait for the game to start
this.Sleep(1);
// Welcome human player
local HUMAN_COMPANY = 0;
GSNews.Create(GSNews.NT_GENERAL, GSText(GSText.STR_HELLO_WORLD, HUMAN_COMPANY), HUMAN_COMPANY);
while (true) {
local loop_start_tick = GSController.GetTick();
//GSController.Break("booo");
this.HandleEvents();
this.BuildIndustry();
//GSCompany.ChangeBankBalance(0, 1000, GSCompany.EXPENSES_CONSTRUCTION);
//GSCompany.ChangeBankBalance(0, -500, GSCompany.EXPENSES_SHIP_RUN);
// Loop with a frequency of five days
local ticks_used = GSController.GetTick() - loop_start_tick;
//this.Sleep(Helper.Max(1, 5 * 74 - ticks_used));
}
}
function MainClass::Init()
{
if (this._load_data != null)
{
// Copy loaded data from this._load_data to this.*
// or do whatever with the loaded data
}
else
{
for(local i = 0; i < 100; i++) {
this.BuildIndustry();
}
}
}
function MainClass::HandleEvents()
{
if(GSEventController.IsEventWaiting())
{
local ev = GSEventController.GetNextEvent();
if(ev == null)
return;
// check event type
// handle event
}
}
function MainClass::Save()
{
Log.Info("Saving data to savegame", Log.LVL_INFO);
return {
some_data = null,
some_other_data = null
};
}
function MainClass::Load(version, tbl)
{
Log.Info("Loading data from savegame made with version " + version + " of the game script", Log.LVL_INFO);
// Store a copy of the table from the save game
// but do not process the loaded data yet. Wait with that to Init
// so that OpenTTD doesn't kick us for taking too long to load.
this._load_data = {}
foreach(key, val in tbl)
{
this._load_data.rawset(key, val);
}
}
function MainClass::BuildIndustry()
{
local industry_type_list = GSIndustryTypeList();
industry_type_list.Valuate(GSBase.RandItem);
industry_type_list.Sort(GSList.SORT_BY_VALUE, GSList.SORT_ASCENDING);
for(local i = 0; i < 50; i++)
{
/*foreach(industry_type, _ in industry_type_list)
{
local tile = Tile.GetRandomTile();
if(GSIndustryType.ProspectIndustry(industry_type))
//if(GSIndustryType.BuildIndustry(industry_type, tile))
{
//Helper.SetSign(tile, "made by GS", true);
Log.Info("Built industry at " + Tile.GetTileString(tile), Log.LVL_INFO);
break;
}
//Helper.SetSign(tile, "failed ind.t. " + industry_type + " here", true);
Log.Info("Failed to build industry of type " + industry_type + " at " + Tile.GetTileString(tile), Log.LVL_INFO);
}
*/
local tile = Tile.GetRandomTile();
local name = "abc" + tile;
if(GSTown.FoundTown(tile, GSTown.TOWN_SIZE_LARGE, true, GSTown.ROAD_LAYOUT_3x3, name))
{
Log.Info("Built industry at " + Tile.GetTileString(tile), Log.LVL_INFO);
return;
}
else
{
Log.Info("Failed to build town at " + Tile.GetTileString(tile), Log.LVL_INFO);
}
}
}
IndustryGS/make_tar.py 100777 0 0 1354 12013012637 10403 0 #!python
import os
import re
# ----------------------------------
# Definitions:
# ----------------------------------
# Game Script name
gs_name = "Minimal GS"
gs_pack_name = gs_name.replace(" ", "-")
# ----------------------------------
# Script:
version = -1
for line in open("version.nut"):
r = re.search('SELF_VERSION\s+<-\s+([0-9]+)', line)
if(r != None):
version = r.group(1)
if(version == -1):
print("Couldn't find " + gs_name + " version in info.nut!")
exit(-1)
dir_name = gs_pack_name + "-v" + version
tar_name = dir_name + ".tar"
os.system("mkdir " + dir_name);
os.system("cp -Ra *.nut lang " + dir_name);
os.system("tar -cf " + tar_name + " " + dir_name);
os.system("rm -r " + dir_name);
IndustryGS/version.nut 100777 0 0 332 11701136763 10450 0 /*
* Warning: This file is loaded both by main.nut and info.nut
* thus, don't place anything here that is heavy or not required
* to be available when OpenTTD scans the info.nut file.
*/
SELF_VERSION <- 1;