Question: Make a custom window in GameScript?

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
User avatar
HayabusaShinkansen
Engineer
Engineer
Posts: 14
Joined: 10 Feb 2023 01:04

Question: Make a custom window in GameScript?

Post by HayabusaShinkansen »

Is its possible to create a custom window in GameScript?

Just a simple window with a few dropdowns and input fields.

Ideally want to activate that window when I click on a station (ideally add a button there). The idea is to use a script to do some tasks relating to that station.

Found this but AFAICT it only allows interaction with existing windows: https://docs.openttd.org/gs-api/classGSWindow

Did find a "GoalQuestionWindow" https://docs.openttd.org/source/d5/d0d/ ... tionWindow though no doc on how to call it from GameScript. Maybe limited to just a few predefined buttons. Not other widgets?

There was a proposal to do "CustomWindow" https://wiki.openttd.org/en/Development ... m%20Window but no other reference to the keyword exists so probably never implemented because doesn't seem to be in window_type.h: https://github.com/OpenTTD/OpenTTD/blob ... dow_type.h

Tutorials on GameScript are almost non-existent. There are some on AI, but for GS this is all there is: !? https://wiki.openttd.org/en/Manual/Game%20script and doesn't say much. The best thing I've found is MinimalGS, and that doesn't show how to do windows. Looked at the list of Game Scripts and none of them seem to do their own windows either. If it's not possible, how to raise a request with the Openttd devs for a custom window? Alternately happy to write it myself if someone can point me in the right direction.

links found
https://wiki.openttd.org/en/Manual/Game%20script
https://docs.openttd.org/gs-api/classGSWindow
https://wiki.openttd.org/en/Development ... m%20Window
User avatar
jfs
Tycoon
Tycoon
Posts: 1865
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Question: Make a custom window in GameScript?

Post by jfs »

No.

What you can do right now is use the StoryBook API. It mainly consists of text and buttons, where the buttons can do various different things, including let the player pick tiles or vehicles on the map.
https://docs.openttd.org/gs-api/classGSStoryPage

I don't recall if there is a way to open a query window to ask for the player to input text.
User avatar
HayabusaShinkansen
Engineer
Engineer
Posts: 14
Joined: 10 Feb 2023 01:04

Re: Question: Make a custom window in GameScript?

Post by HayabusaShinkansen »

Thanks @jfs. Seems the controls are limited (no dropdowns, no text or numeric inputs, no popup queries either https://docs.openttd.org/gs-api/classGS ... 641b9a2ddd ) but seems being able to select a location and click on a button is just enough to trigger a script, so that's enough to start. Thank you for the pointer.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 19 guests