[Request] Automatic spectator script

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Hezkore
Engineer
Engineer
Posts: 21
Joined: 02 Sep 2008 07:45

[Request] Automatic spectator script

Post by Hezkore » 01 Jan 2019 21:23

I have no idea how "scripts" actually work and what they could do.
But is there a script or perhaps a way to write a "automatic spectator script"?

The idea is that someone would host a server and play like you normally would with your friends.
Then you'd have a separate client join and run the spectator script on that client.
The script would pan around the map and look at what everyone's doing, and also now and then show the stats of each player.
That client could then be streamed to Twitch (or similar) for everyone to enjoy.

Is this something a script could do?

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Request] Automatic spectator script

Post by Zuu » 02 Jan 2019 01:36

No, not using AI or Game Scripts of current official release versions.

- Game Script has an API to pan the view, but it only work in single player.
- AI doesn't have this API as they control companies. Also the AI code only runs on the server in multiplayer.

With the possibility of custom source code changes, it is possible you just have to figure out how to implement it. (this is not an offer to do it for you)

Edit: Also, note that there may be other solutions using console scripts or admin port that could solve your problem, but as you posted in the AI and Game Script sub forum, the answer focus on this area.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Hezkore
Engineer
Engineer
Posts: 21
Joined: 02 Sep 2008 07:45

Re: [Request] Automatic spectator script

Post by Hezkore » 02 Jan 2019 19:18

Good to know!
Is there perhaps some way to output information about the current game to a text file of some sort?
Perhaps the server could write each new event, along with its position and who created the event, to a log file.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9270
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [Request] Automatic spectator script

Post by planetmaker » 02 Jan 2019 20:15

Hezkore wrote:Good to know!
Is there perhaps some way to output information about the current game to a text file of some sort?
Perhaps the server could write each new event, along with its position and who created the event, to a log file.
You can do that via the admin port. One of its purposes is logging. SOAP is the incarnation I use for accessing it.

_dp_
Engineer
Engineer
Posts: 114
Joined: 18 Dec 2013 12:32

Re: [Request] Automatic spectator script

Post by _dp_ » 03 Jan 2019 19:58

CityMania client has a spectator patch. You can select one player or whole company and it will continuously pan to a place of last action. It's not a particularly nice viewing experience as you only see the end result of each action not player's mouse or building process. But it's the best you can do without requiring players to run a heavily modified game or some video recording software.

Hezkore
Engineer
Engineer
Posts: 21
Joined: 02 Sep 2008 07:45

Re: [Request] Automatic spectator script

Post by Hezkore » 05 Jan 2019 16:35

Is there anywhere I can read about this "Admin Port" without looking at pure source code?
Any sort of documentation?

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Request] Automatic spectator script

Post by Zuu » 05 Jan 2019 17:19

There is docs/admin_network.txt with protocol documentation.

On the wiki, you can find some starting points for libraries/utilities to use as is or to read in order to learn and build your own.
https://wiki.openttd.org/Server_admin_port
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Hezkore
Engineer
Engineer
Posts: 21
Joined: 02 Sep 2008 07:45

Re: [Request] Automatic spectator script

Post by Hezkore » 05 Jan 2019 18:45

I've got a bot running that can connect and send and receive data.
But the data structure of each packet is a mystery.
Having to decode someone else code (in a different language) is quite the chore.
The wiki should really have a brief overview of each packet and its data structure.

Hezkore
Engineer
Engineer
Posts: 21
Joined: 02 Sep 2008 07:45

Re: [Request] Automatic spectator script

Post by Hezkore » 06 Jan 2019 21:10

I ended up creating an Admin Port library for the open-source language Monkey2

You can read more about it in this thread

Image

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 0 guests