NoGo - A Scriptable Game Framework - v1.5

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework

Post by MinchinWeb »

A couple thoughts about trying to program a game script:
  • - Game Scripts move really fast. Since they start immediately following map creation, by they time you get the debug screen up, they can have run several hundred lines of code.
  • - Game Scripts keep running fast. They don't stop running when you push "pause" either. I might have to adapt Zuu's "break" signs...
  • - I miss the libraries. I've been trying to move WmDOT over to run on the GameScript framework, but it depends on 5 or so libraries. I've managed to move most of the libraries to be internal files, but that's introduced some strange bugs (like the pathfinder always returns "null"...). Libraries support is at the top of my feature request list.
  • - Bug: all GameScript options are changable in-game. I don't think this the intended behavior. (AI's can have settings you can set anytime or just before you start the game)
  • - if a GameScript crashes, it does not pull up the debug screen with a message to submit a crash report, like it does if an AI crashes. Instead, the game continues to run.
I quite like the idea of Game Scripts, am amazed at what they can already do, and excited to see what can be developed.

Out of curiosity, what needs to happen before NoGo can be added to the trunk? Is the goal for it to be part of the 1.2 release?

@Zuu: I would be interested in helping with the tutorials. Do you have a basic curriculum drawn up yet?
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
fieari
Engineer
Engineer
Posts: 9
Joined: 01 Nov 2011 06:14

Re: NoGo - A Scriptable Game Framework

Post by fieari »

If you don't have a curriculum set up yet, I have some recommendations for a tutorial. I only recently learned to play, using a guide, but I think this would be a good way to start:

Start with basic point-to-point RR between coal and power plant. This should be step by step (build stations, build tracks, build depot), and the two shouldn't be super far away.

Then teach RoRo, and add a second train (to a single lane station).

Then start teaching signals with a second lane in the station, maybe even adding another train to the line. Make it necessary by boosting production. Explain pre-signals! Perhaps cover another industry chain as well.

Then teach about transfers... do it with oil, so you can use oil tankers and trains combined, and teach how sea travel works. For added fun, make them build a canal.

Since oil leads to goods, next might be a good idea to teach about town growth. Also, get a local bus service up (make sure there's a big city in tutorial land).

Next, get forced transfers into play by shipping passengers via bus to an airport, which will take them to a distant city, and explain distance bonuses.

That covers trains, ships, roads, and planes, and gets the basic ideas across. In between these concepts, each of the industry chains should be covered as well, so that by the end of the tutorial, all vanilla industries have been serviced.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NoGo - A Scriptable Game Framework

Post by planetmaker »

fieari wrote:If you don't have a curriculum set up yet(...)
That sounds like a good route to go. Only thing I'd switch are setting up a bus transfer to an airport and getting a local bus service running. The latter is better to have setup first in order to make sure the town will continue to like you :-) (serviced stations can improve your standing with towns)
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework

Post by MinchinWeb »

Crash report... I trying to write a GameScript, and when I tried to exit the game, it gave me this message box and then crashed OpenTTD. I'm running 64-bit on Windows 7. I believe I have the newest version (h21d1ebea).
Fullscreen capture 04122011 94542 PM.bmp.jpg
Fullscreen capture 04122011 94542 PM.bmp.jpg (46.55 KiB) Viewed 3956 times
Attachments
crash.png
Crash Screen capture
(251.81 KiB) Downloaded 1 time
crash.dmp
Crash Dump File
(2.06 MiB) Downloaded 92 times
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework

Post by MinchinWeb »

(Crash report continued)
Attachments
WmDOT-GS-20111204.zip
Game Script, at the time of the crash
(354.07 KiB) Downloaded 98 times
crash.log.txt
Crash Log
(9.11 KiB) Downloaded 97 times
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework

Post by MinchinWeb »

Coding help please!

I'm trying to write a Game Script, but I can't figure out why the following code doesn't work. It runs without errors, moves the viewport, but it doesn't do anything else. I'm expecting it to pay off most of the loan, then build a road section and a road depot.

I don't know if something in my code is failing or if something in OpenTTD isn't working the way it's supposed to... I'm running version h21d1ebea of OpenTTD-NoGo.

The code is question: (The full code is attached below)

Code: Select all

	local comp = GSCompanyMode(0);
	local exec = GSExecMode();
	GSLog.Info("Company " + GSCompany.ResolveCompanyID(0));
	GSCompany.SetLoanAmount(GSCompany.GetLoanInterval());
	GSLog.Info("Loan set to zero");

	local x = 50;
	local y = 40;
	GSViewport.ScrollTo(GSMap.GetTileIndex(x,y));
	GSRoad.BuildRoadDepot(GSMap.GetTileIndex(x,y), GSMap.GetTileIndex(x,y+1));
	GSRoad.BuildRoad(GSMap.GetTileIndex(x-1,y-1), GSMap.GetTileIndex(x-1,y));
Attachments
info.nut
(non-working) Test Game Script
(5.28 KiB) Downloaded 97 times
main.nut
(non-working) Test Game Script
(1.43 KiB) Downloaded 109 times
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework

Post by TrueBrain »

GSCompanyMode is broken atm, and only works for the next statement. Will fix that with the next release :)
The only thing necessary for the triumph of evil is for good men to do nothing.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoGo - A Scriptable Game Framework

Post by Zuu »

Currently there exist a bug that GSCompanyMode is reset an the next DoCommand. In addition I've reported a bug to TrueBrain that I couldn't build a road bus stop as company 0.
fieari wrote:If you don't have a curriculum set up yet, I have some recommendations for a tutorial. I only recently learned to play, using a guide, but I think this would be a good way to start:
Great! I haven't set up any plan for what the tutorial will contain. There is one in the wiki to use as inspiration but ideally this one doesn't need to follow it completely. The in-game tutorial should probably contain less text to read as reading a website is easier than reading text in the game, and we don't have to explain so much about where to click but rather use highlighting etc.
MinchinWeb wrote:@Zuu: I would be interested in helping with the tutorials. Do you have a basic curriculum drawn up yet?
Great! I as said before, I haven't though so much yet about the text/tasks etc. in the tutorial. More on the architectural side. When the bug mentioned above is fixed, I will continue to work on the code and soon post a draft.

I think we should probably create a thread for this project. Will do that tonight I think.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: NoGo - A Scriptable Game Framework

Post by Eddi »

for a tutorial it could maybe be useful to highlight a TileArea.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework

Post by TrueBrain »

MinchinWeb wrote:(..)
  • - Game Scripts move really fast. Since they start immediately following map creation, by they time you get the debug screen up, they can have run several hundred lines of code.
Add a Sleep() at the beginning of your script if you don't like this. Read one of my posts in this thread on the hows and whys
MinchinWeb wrote:
  • - Game Scripts keep running fast. They don't stop running when you push "pause" either. I might have to adapt Zuu's "break" signs...
The way it was meant to be :)
MinchinWeb wrote:(..)
  • - Bug: all GameScript options are changable in-game. I don't think this the intended behavior. (AI's can have settings you can set anytime or just before you start the game)
GetSetting() system is identical to the one used by AIs. (they share identical code). So I need a bit more to go on than only this, if you think it really is a bug.
[Edit]Nevermind, finally found what you meant. But please do be bit more verbose with bug reports, my mind-reading machine is still broken :( Tnx :)
The only thing necessary for the triumph of evil is for good men to do nothing.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework

Post by TrueBrain »

MinchinWeb wrote:Crash report... I trying to write a GameScript, and when I tried to exit the game, it gave me this message box and then crashed OpenTTD. I'm running 64-bit on Windows 7. I believe I have the newest version (h21d1ebea).
Fullscreen capture 04122011 94542 PM.bmp.jpg
Should be solved with next update .. I hope. Let me know if it doesn't.
The only thing necessary for the triumph of evil is for good men to do nothing.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework

Post by TrueBrain »

MinchinWeb wrote:Coding help please!
(..)
Besides the GSCompanyMode bug, there is one other mistake in your script. Like explained in one of my posts, the GameScript runs during map generation. In that time there is no company active yet. You should wait for the Company Create event before assuming there is one. In multiplayer for example this can be a while.
The only thing necessary for the triumph of evil is for good men to do nothing.
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Re: NoGo - A Scriptable Game Framework

Post by Expresso »

I'm willing to help out with the tutorial, but it would be nice if GS can actually highlight user interface elements. That would spare a lot of explanation.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework - v0.1

Post by TrueBrain »

Today I started to release based on versions, instead of Mercurial hashes. So, today I give you NoGo 0.1. The first of many I am sure :)

Fixes:

- GSCompanyMode is now fixed
- You can no longer configure a GS when it becomes active (read: start a game)
- Some minor GUI bugs
- Logging in GSCompanyMode no longer happens to the wrong window

Tnx all for reporting the issues. Hope you can now start building routes :D
The only thing necessary for the triumph of evil is for good men to do nothing.
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework - v0.1

Post by MinchinWeb »

I seem to have managed to crash it again... I'm running NoGo v0.1 this time.

If I were to guess, it's because I tried to do something as "Company 1", which doesn't exist.

Keep reporting bugs here?
Attachments
crash.dmp
(2.07 MiB) Downloaded 94 times
crash.log.txt
(11.42 KiB) Downloaded 99 times
Fullscreen capture 07122011 60602 PM.bmp.jpg
Fullscreen capture 07122011 60602 PM.bmp.jpg (55.05 KiB) Viewed 3689 times
Last edited by MinchinWeb on 08 Dec 2011 01:24, edited 2 times in total.
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework - v0.1

Post by MinchinWeb »

Crash report continued...
Attachments
WMTest-GS-20111207.zip
The GameScript running at the time of crash.
(2.51 KiB) Downloaded 98 times
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
User avatar
MinchinWeb
Traffic Manager
Traffic Manager
Posts: 225
Joined: 01 Feb 2011 12:41
Contact:

Re: NoGo - A Scriptable Game Framework - v0.1

Post by MinchinWeb »

TrueBrain wrote:But please do be bit more verbose with bug reports, my mind-reading machine is still broken :( Tnx :)
lol, I don't think my mind reading machine works either...
TrueBrain wrote:
MinchinWeb wrote: (..)
  • - Bug: all GameScript options are changable in-game. I don't think this the intended behavior. (AI's can have settings you can set anytime or just before you start the game)
GetSetting() system is identical to the one used by AIs. (they share identical code). So I need a bit more to go on than only this, if you think it really is a bug.
I was hoping for the option to change some options ingame; a GSCONFIG_INGAME flag to match the AI version. At the moment, using that flag cause the GameScript to fail to compile. Bug: I checked again, and it still seems like all setting can be configured once the same is started by using 'flags=0'.

Is it/will it be possible to build roads without making a player do it? I'm working on porting WmDOT, my AI which basically builds out the highway system, to the NoGo framework. If I have to go thru a company to build it, especially the player's company, I'm not sure I'm any further ahead. In order of preference, the options I wish were possible:
  • 1. Build roads as the game (as town authorities?) That way they don't cost anyone any money, the bridges don't disappear when WmDOT goes bankrupt, and the roads can be removed by the player if they got in the way.
  • 2. Start an AI, either WmDOT or a 'dumb' company directly run by the GameScirpt. This is about the same as the AI version...
  • 3. Build stuff as the human player, and then have a way to "refund" him the cost of construction.
Are any of those three things (build roads as the game, start an AI, or give money to players) likely to be added to NoGo soon?
Alberta Town Names - 1500+ real names from 'Acme' to 'Zama City'
MinchinWeb's Random Town Name Generator - providing 2 million plus names...
WmDOT v13 - An AI that doubles as your highway department
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework - v0.1

Post by TrueBrain »

MinchinWeb wrote:(..) a GSCONFIG_INGAME flag (..)
http://devs.openttd.org/~truebrain/nogo ... 92bd834bd1

The flag is called: CONFIG_INGAME, like per documentation

PS: in the AI changelog is also mentioned that it is no longer AICONFIG_INGAME, but CONFIG_INGAME. In fact, for all settings the AI part is removed.
The only thing necessary for the triumph of evil is for good men to do nothing.
ToxicSheep
Engineer
Engineer
Posts: 4
Joined: 16 Feb 2011 23:53

Re: NoGo - A Scriptable Game Framework - v0.1

Post by ToxicSheep »

a little bit offtopic... does a anyone know the PW to xaroth.nl NoGo #2 server? I'm getting a 403 when I want to go on his site.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoGo - A Scriptable Game Framework - v0.1

Post by TrueBrain »

Locally fixed the crash. Turns out that functions around Balance did not validate the validate-ness of a company. Nasty bug :D
Also locally fixed up the GUI to work with INGAME setting. It now used some kind of fifty-fifty system, it was funny :)
The only thing necessary for the triumph of evil is for good men to do nothing.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 54 guests