What are the possibilities of game scripts
Moderator: OpenTTD Developers
What are the possibilities of game scripts
After a few PM's with FooBar he came up with the idea to ask some stuff about script possibilities in public.
I was thinking about scripted events such as:
- offering of rare subtypes of vehicles if you have a set amount of that vehicle type active
- lower running costs if you have a set amount of vehicles from one type active
- higher revenue for vehicles if you have a set amount of vehicles from one type active
- subsidy offers to be achieved by a certain vehicle type
- reality-based news items
I was thinking about scripted events such as:
- offering of rare subtypes of vehicles if you have a set amount of that vehicle type active
- lower running costs if you have a set amount of vehicles from one type active
- higher revenue for vehicles if you have a set amount of vehicles from one type active
- subsidy offers to be achieved by a certain vehicle type
- reality-based news items
Re: What are the possibilities of game scripts
You are limited by openttd, limited by the AI API (even if the GS API might allow a bit more, you'll be tied to that anyway), and limit to not cheat (one cheat exist already)
So, except the new items, all others choices from your list aren't doable.
So, except the new items, all others choices from your list aren't doable.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: What are the possibilities of game scripts
Game scripts and AI share a lot of the API, but they are different in what is accessible to them. Game scripts can act as COMPANY_DEITY, thus they *can* change things a company (human or AI) could not change ever (like towns growing or not growing).krinn wrote:You are limited by openttd, limited by the AI API (even if the GS API might allow a bit more, you'll be tied to that anyway), and limit to not cheat (one cheat exist already)
So, except the new items, all others choices from your list aren't doable.
You find the API documentation for GS here: http://nogo.openttd.org/api/trunk/
A lot more things are thinkable as of what game scripts could be given access to (they can react on subsidies and create news items so far).
Wrt vehicles being offered conditionally is something entirely new and GS cannot change availability of vehicles at all. That's at least a thorny and stony path to go as it basically means to break NewGRFs to some degree. It might possibly be part of NewGRFs domain rather (it's hard to define clear boundaries between GS and NewGRFs)
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
-
- Transport Coordinator
- Posts: 259
- Joined: 16 Mar 2009 21:00
Re: What are the possibilities of game scripts
I do like the idea of running costs being reduced once you have a number of the same vehicle types. Is this something that existing newGRFs could incorporate (after all, 2cc, I think, already reduced the running costs for some engines when you have them on double-headed trains)?
- SquireJames
- Tycoon
- Posts: 1863
- Joined: 07 Aug 2004 11:56
- Skype: squirejames5
- Location: Stoke-on-Trent
- Contact:
Re: What are the possibilities of game scripts
Digging up a slightly old post here, but I see that you have said that news items are doable?
Making a HUUUGE assumption here, but I am gathering the code is rather simple for such items, in psuedocode basically being "If date = 01-09-1939 then display news item 'War Declared!' " I will happily volunteer to make such a script, it's something i've been after for a while (I loved the real world items in Railroad Tycoon for example).
Beyond that, is it possible to trigger certain economic events with script also? What I am thinking is, as you might have gathered with the above example, is that during the First and Second World War, massively increase production, demand and payment for coal, iron, oil, steel etc, and have passenger income reduce. I know that even the original TTO had "Recession" events where payments dropped, but I am not sure if the scripting allows such precise managements of cargo as I am suggesting. I also imagine that i'd have to tailor the script to any industry set I was using. For example, I use FIRS, so I'd need to make a FIRS specific version which referred to FIRS cargos rather than vanilla.
Anyway, I'll have a search for a scripting tutorial and give it a go. Is it anything like LUA script? I use that a lot in other games I mod.
Making a HUUUGE assumption here, but I am gathering the code is rather simple for such items, in psuedocode basically being "If date = 01-09-1939 then display news item 'War Declared!' " I will happily volunteer to make such a script, it's something i've been after for a while (I loved the real world items in Railroad Tycoon for example).
Beyond that, is it possible to trigger certain economic events with script also? What I am thinking is, as you might have gathered with the above example, is that during the First and Second World War, massively increase production, demand and payment for coal, iron, oil, steel etc, and have passenger income reduce. I know that even the original TTO had "Recession" events where payments dropped, but I am not sure if the scripting allows such precise managements of cargo as I am suggesting. I also imagine that i'd have to tailor the script to any industry set I was using. For example, I use FIRS, so I'd need to make a FIRS specific version which referred to FIRS cargos rather than vanilla.
Anyway, I'll have a search for a scripting tutorial and give it a go. Is it anything like LUA script? I use that a lot in other games I mod.
Re: What are the possibilities of game scripts
People are just beginning to investigate how to use game scripts for games. News items is definitely possible, the other stuff may be more difficult.
While I don't like war as reason ("Upcoming super power Hawaii needs resources" would do just as well imho), I think the sort of things you want should be possible in some way.
If it is not currently, perhaps we should consider how to extend the scripting capabilities.
It is just a bit tricky, the system should function well both with and without game script, so it should be carefully considered what knobs the system should have, and who controls their settings.
Last but not least, imho it would be useful if your script is also useful for other industry sets. Again, nobody knows how feasible it is, it needs experimentation.
While I don't like war as reason ("Upcoming super power Hawaii needs resources" would do just as well imho), I think the sort of things you want should be possible in some way.
If it is not currently, perhaps we should consider how to extend the scripting capabilities.
It is just a bit tricky, the system should function well both with and without game script, so it should be carefully considered what knobs the system should have, and who controls their settings.
Last but not least, imho it would be useful if your script is also useful for other industry sets. Again, nobody knows how feasible it is, it needs experimentation.
- SquireJames
- Tycoon
- Posts: 1863
- Joined: 07 Aug 2004 11:56
- Skype: squirejames5
- Location: Stoke-on-Trent
- Contact:
Re: What are the possibilities of game scripts
I know there has been a lot of discussion about war-related items in OTTD and the pros and cons to this. The good thing about a game script is that it's not forced on anyone. If you want historical news items, along with the economic factors (war, recession, rise and fall of personal transport) then you can download and install the script. If not, you don't have to.
As mentioned I could make several versions, including one that omitted anything war-related.
I downloaded the tutorial script and examined how it was structured etc. So far I only foresee two issues with news items. First is that I can't find any code that brings up a news window (the tutorial uses messages windows, similar to the "we designed a new vehicle" windows). The second is that the AIDate callbacks seem to use relative dates rather than fixed dates. So, if you started on January 1st 1900, that would be day 1. If you started on January 1st 1950, that would also be day 1. There may be a different variable that calls the exact calendar date, much like how vehicles in GRFs do, but I've yet to find it. I am sure that the code is there though, I am just scratching the surface

I downloaded the tutorial script and examined how it was structured etc. So far I only foresee two issues with news items. First is that I can't find any code that brings up a news window (the tutorial uses messages windows, similar to the "we designed a new vehicle" windows). The second is that the AIDate callbacks seem to use relative dates rather than fixed dates. So, if you started on January 1st 1900, that would be day 1. If you started on January 1st 1950, that would also be day 1. There may be a different variable that calls the exact calendar date, much like how vehicles in GRFs do, but I've yet to find it. I am sure that the code is there though, I am just scratching the surface

Re: What are the possibilities of game scripts
Yes, the tutorial doesn't use the news popup. If you want to check a GS that does that, you could read the Split GS, TransportGoals, etc. Actually, most GS except the Tutorial use the news popup for at least one message.SquireJames wrote:I downloaded the tutorial script and examined how it was structured etc. So far I only foresee two issues with news items. First is that I can't find any code that brings up a news window (the tutorial uses messages windows, similar to the "we designed a new vehicle" windows).
You may also want to check the API docs for creating news:
http://nogo.openttd.org/api/1.2.1/classGSNews.html
Did you check the API docs?SquireJames wrote:The second is that the AIDate callbacks seem to use relative dates rather than fixed dates. So, if you started on January 1st 1900, that would be day 1. If you started on January 1st 1950, that would also be day 1. There may be a different variable that calls the exact calendar date, much like how vehicles in GRFs do, but I've yet to find it. I am sure that the code is there though, I am just scratching the surface
http://nogo.openttd.org/api/1.2.1/classGSDate.html
GSDate::GetYear(GSDate::GetCurrentDate()) should give you the current year.
Is this the function that you tried to use?
Last, you may want to check some other Game Scripts for inspiration. The tutorial code is heavily engineered towards a linear step-by-step tutorial. Most other game scripts would probably not benefit from the structure used there.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
- SquireJames
- Tycoon
- Posts: 1863
- Joined: 07 Aug 2004 11:56
- Skype: squirejames5
- Location: Stoke-on-Trent
- Contact:
Re: What are the possibilities of game scripts
I did check the API documentation, I didn't see anything related to dates. That code certainly seems to be the thing though 
I'll download the split GS and find the code that brings up a news story. I am hoping this should be a fairly easy game script to code, as it's essentially just a huge series of linear checks that only hit once. I can start trying to add economic effects to these events later.

I'll download the split GS and find the code that brings up a news story. I am hoping this should be a fairly easy game script to code, as it's essentially just a huge series of linear checks that only hit once. I can start trying to add economic effects to these events later.
Who is online
Users browsing this forum: No registered users and 24 guests