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
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: NoGo - A Scriptable Game Framework - v1.5

Post by andythenorth »

For industry / newgrf / NoGo interaction, I had an idea which is not feasible for NoGo as far as I can understand it. I'm posting it anyway...

- allow NoGo to handle IndustryMonthlyLoop (industry_cmd.cpp) as an event
- give it two passes over the industries, the first is to read properties / variables
- the second is to set production level variables (prod_level[0], prod_level[1]) for each industry
- the second pass appears to newgrf exactly as current production cb, unchanged, and newgrf can choose to defer to game (NoGo), or handle its own production change (no spec change)
- the first pass could possibly be exposed to newgrf, allowing newgrf to handle reporting values to NoGo

This would work for handling closure for all industry classes, and handle production for primaries that don't use production cb. Handling secondary industry production should be well out of scope for NoGo and is the domain of the newgrf.

The industry random production change could be handled identically to monthly. (I would bin the random one as pointless, but that's unlikely to happen).
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: NoGo - A Scriptable Game Framework - v1.5

Post by idioty »

I would like a function like this: GSCompany::GetQuarterlyCargoDelivered(CompanyID company, uint32 quarter, CargoID cargo_type); :)
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: NoGo - A Scriptable Game Framework - v1.5

Post by idioty »

Helo!

Sorry my bad english! :)
I wrote this code:

Code: Select all

	local cargoList = GSCargoList();
	for (local i = 0; i < cargoList.Count(); i++) {
		local currentCargoType = cargoList[i];
		local cargoLabel = GSCargo.GetCargoLabel(currentCargoType);
		GSNews.Create(GSNews.NT_GENERAL, "cargo " + i + ": " + cargoLabel + "!", GSCompany.COMPANY_INVALID);
	}
and the cargoLabel is always PASS.
Why?
Last edited by idioty on 29 Apr 2012 14:44, edited 1 time in total.
Sorry my bad english, I don't speak english!
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Zuu »

I see no Log calls in your code. Please provide that as well so we know where you are inspecting the value.

Also, generally it is not a good idea to rely on the cargo labels. They are mostly there for debug purposes.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: NoGo - A Scriptable Game Framework - v1.5

Post by idioty »

I edited my code!

I want get the cargo name. I want to show in News this name...
Sorry my bad english, I don't speak english!
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: NoGo - A Scriptable Game Framework - v1.5

Post by TTFTCUTS »

Hi there - not 100% sure that this is the place to be asking, but is there an easy way to concatenate GSText items, such that you can use more than one with, say, GSTown.SetText?

Concatenation of normal strings is fine, but that doesn't let you use colour tags, and adding a string to a GSText object just ends up giving the object instance name as a string. I see that it can be done in a roundabout way by setting a parameter of the GSText to a string and putting another one in, but this can be quite a pain for variable numbers of objects (I was using it to list the neighbouring towns in the NAI script, and have had to resort to 3 strings for 1, 2 or 3 neighbours so far.)


Also, is there a way to make a town want other specific cargoes, be it by setting more specific goals or adding to the existing list? I already messed around with the different demand types since FIRS returns goods as petrol and water as goods in-game, and would like to expand the demands at higher population levels to include things like building materials and alcohol. From what I've seen so far this can't really be done at the moment.

On that note, is there a way to detect if a specific newGrf is in operation? That way the cargo type corrections for things like FIRS can be automatic, and wouldn't throw a hissy-fit when it isn't loaded.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NoGo - A Scriptable Game Framework - v1.5

Post by frosch »

Currently there is no method to specify demands for cargos which have no town effect. We considered adding support for that, but so far there is no working concept for it.

There is no way for a script to detect specific NewGRFs, nor will there ever be a method for it. But you can check the availability of specific cargotypes. So, if you have special behaviour for alcohol, you can check for the presence of the cargo "BEER". That way your script will work with any NewGRF which provides this cargo, no matter whether it is FIRS or something else.

References:
GSCargo.GetCargoLabel(): http://nogo.openttd.org/api/1.2.0/class ... 1b4ff5478a
Cargo labels of all defined cargo so far: http://newgrf-specs.tt-wiki.net/wiki/CargoTypes
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: NoGo - A Scriptable Game Framework - v1.5

Post by TTFTCUTS »

Ah! Yes, checking the cargo types does make more sense - thanks for pointing that one out. Shame about the cargo demands thing too.

However, I'm still at a loss over how to concatenate GSText objects - adding them results in it saying the operation is undefined, and I detailed the other outcomes in my last post.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Eddi »

note, that the GUI has a limitation where it only lists the first cargo for a given towneffect, so even though Petrol, Alcohol and Building Materials all have TE_GOODS, the GUI will only say "Requires Petrol", while it actually counts all three.
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: NoGo - A Scriptable Game Framework - v1.5

Post by TTFTCUTS »

Does that mean that any of the items can fulfill the condition? I'm sure it doesn't mean that a town needs all of them, since towns will grow without building materials.

However, why does water return goods in that case? In FIRS tests the goods delivered don't fulfill the goods category (appearing as petrol on the ui).
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Eddi »

yes, it is "any of these", not "all of these".

Goods appear in the TE_WATER category because FIRS redefines it as such. this was done because you need at least one cargo in this category for desert towns, and FIRS has no space for actual water.
TTFTCUTS
Engineer
Engineer
Posts: 24
Joined: 15 Oct 2009 00:25

Re: NoGo - A Scriptable Game Framework - v1.5

Post by TTFTCUTS »

Ah, that makes things much clearer. Thanks for all the info!
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Expresso »

Perhaps it's a bit late to ask, but can the scripts instead of being interpreted be turned into decision trees (like happens with newgrfs) so the scripts don't need to be interpreted each time?

The reason I'm asking this is because I tend to play on large maps together with a friend and we tend to fill the map up with HUGE cities and lots of wonderful trains.

A while ago we tried with some scripts and the performance hit made the game unplayable on an older machine.
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Korenn »

Sorry for Necroing this thread, but I just want to congratulate TrueBrain on writing this and having it added to trunk. Great work!

It's been a long time since I first wrote the Openttd Challenge Spinoff, but finally there's the option of having goal gameplay with the basic game. hurrah!

I'll have to see if the features list tickles my brain to write a game script :wink:
Torrasque
Engineer
Engineer
Posts: 94
Joined: 19 Aug 2004 13:33
Contact:

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Torrasque »

Korenn wrote:Sorry for Necroing this thread, but I just want to congratulate TrueBrain on writing this and having it added to trunk. Great work!

It's been a long time since I first wrote the Openttd Challenge Spinoff, but finally there's the option of having goal gameplay with the basic game. hurrah!

I'll have to see if the features list tickles my brain to write a game script :wink:
I have great memories of your Challenge Spinoff. I would love to see a revival.
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: NoGo - A Scriptable Game Framework - v1.5

Post by aantono »

in the GSTile.IsDesertTile(GSTown.GetLocation(TownID)) the check always returns "false" even when the town is clearly on the desert. Looks like the IsDeserTile function only returns true if the tile is empty (i.e. has no buildings, roads or anything else on it). Is this an intended behavior, and if so, can a function be added to GSTown object to check if the town is in the desert?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoGo - A Scriptable Game Framework - v1.5

Post by Zuu »

This problem have been reported earlier. It has just not been solved because noone have prioritized this over other things that they wanted to do more.

I think there should be a task at bugs.openttd.org about this issue. If not, you could add it there as a reminder.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
aantono
Traffic Manager
Traffic Manager
Posts: 211
Joined: 15 Apr 2010 21:01
Location: Midwest, US

Re: NoGo - A Scriptable Game Framework - v1.5

Post by aantono »

Didn't find it in the bug tracker, but maybe I wasn't searching properly. :(
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NoGo - A Scriptable Game Framework - v1.5

Post by planetmaker »

Zuu wrote:This problem have been reported earlier. It has just not been solved because noone have prioritized this over other things that they wanted to do more.

I think there should be a task at bugs.openttd.org about this issue. If not, you could add it there as a reminder.
aantono wrote:Didn't find it in the bug tracker, but maybe I wasn't searching properly. :(
Maybe read again Zuu's posting. It offers conclusive hints on how and where to find it.
EDIT: If it's not in the bug tracker, you might want to open an issue about it :-) - if it's there, someone will find it and merge or link the topics.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 16 guests