Page 1 of 1

Trying to load a GameScript for a Dedicated Server

Posted: 03 Feb 2021 09:03
by gregdek
I'm working on some code to run a tournament of AIs, and as part of that I'd like to have a gamescript that does some logging. I'm trying to run the gamescript against a dedicated server.

I've got AIs working, and that's fine. But I've got a dead-simple Gamescript, and it's failing silently and I can't figure out why.

Here's the info.nut:

Code: Select all

class Arbiter extends GSInfo {
  function GetAuthor()      { return "gregdek"; }
  function GetName()        { return "Arbiter"; }
  function GetDescription() { return "An arbiter of AI-only games"; }
  function GetVersion()     { return 1; }
  function GetDate()        { return "2021-02-02"; }
  function CreateInstance() { return "Arbiter"; }
  function GetShortName()   { return "ARBX"; }
  function GetAPIVersion()  { return "1.9"; }
  function GetSettings();
}

/* Tell the core we are a GS */
RegisterGS(Arbiter());
And here's the main.nut:

Code: Select all

class Arbiter extends GSController 
{
    constructor()
}

function Arbiter::Start()
{
  GSLog.Info("[arbi] I am here!");
  GSController.Sleep(1);
  while (true) {
    // we just wait every 10 ticks and ping
    GSLog.Info("[arbi] I am still here!");
    GSController.Sleep(10);
  }
}
And here's how I'm invoking it in openttd.cfg:

Code: Select all

[game_scripts]
arbiter = foo=1
And nothing. I've got debug logs turned up to 9 across the board, and I know that OpenTTD finds the tar file and the .nut files, but then it's just silent failure.

Any hints? I'm tearing my hair out. Thanks!

Re: Trying to load a GameScript for a Dedicated Server

Posted: 03 Feb 2021 15:01
by Firrel
You are missing semi collon after the constructor, the well known hair tearer :D

Re: Trying to load a GameScript for a Dedicated Server

Posted: 03 Feb 2021 17:51
by gregdek
Firrel wrote: 03 Feb 2021 15:01 You are missing semi collon after the constructor, the well known hair tearer :D
Sadly, that is not the problem. I added the semicolon, no luck. :)

I mean, I'm sure it's something dumb like that -- maybe I'm not invoking it properly in the config file -- but there's no hints anywhere in the logs at all, nothing, even with -d 9. I know the dedicated server sees the tarball

Code: Select all

dbg: [misc] Found dir in tar: arbiter/
dbg: [misc] Found file in tar: arbiter/info.nut (524 bytes, 3072 offset)
dbg: [misc] Found file in tar: arbiter/main.nut (286 bytes, 5632 offset)
dbg: [misc] Found tar '/home/openttd/content_download/game/arbiter.tar' with 2 new files
...but then: nothing.

Re: Trying to load a GameScript for a Dedicated Server

Posted: 04 Feb 2021 18:04
by Firrel
The semicolon was a problem, without it, it was crashing.

Tested it in a dedicated server with a visible element, pauses, and it was working well.

Code: Select all

class Arbiter extends GSController 
{
    constructor();
}

function Arbiter::Start()
{
  GSLog.Info("[arbi] I am here!");
  GSController.Sleep(10);

  while (true) {
    // we just wait every 10 ticks and ping
    GSLog.Info("[arbi] I am still here!");
    GSController.Sleep(100);
    GSGame.Pause();
    GSController.Sleep(100);
    GSGame.Unpause();
  }
}

Code: Select all

[game_scripts]
Arbiter = 
Snímka.PNG
Snímka.PNG (9.81 KiB) Viewed 1193 times