News:

SimuTranslator
Make Simutrans speak your language.

Event logic

Started by leopard, May 15, 2009, 08:27:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

leopard

probably complex, however:

suggest adding a system of trigger events and actions.

e.g. a vehicle gets an event trigger when it enters a stop, and when it leaves. the event being notified what the stop is

e.g. a time based event similar to 'cron' which could be used to enforce a schedule of sorts in some areas.

something that could be added to any vehicle or stop, but as an option. essentially adding a very limited player controlled script language.

purpose:
allowing some vehicles to act with a degree of intelligence, e.g. a train enters a station, unloads and is then routed to a waypoint, where it will stop (a stabling siding, maybe a seperate station that never loads anything) here it waits until a time trigger routes it back to the station (maybe by removing a minimum load criteria holding it somewhere it can't load) thus allowing passengers to build up, without hogging a platform.

e.g. a bus operating a schedule where by as it enters a certain stop, it will wait until an event trigger releases it

this allows better use of a limited number of vehicles, and allows a 'commuter' type service, with some units operating part time, and spending the rest of the time stabled out of the way.

envisaged as a pure option, that would only be used on some units in special circumstances, but allows a vastly more flexible operation scheme to be devised
My Simutrans on the apple mac homepage http://www.aleopardstail.com/simutrans/Index.html

VS

I have thought about exactly this some time ago. It would be useful mostly for goods transport... but probably not at all for Joe The Average Player.

Sometimes I wonder, what exactly is the audience Simutrans tries to capture - casual players, serious railroad modellers, "city builders", traffic coordinators... we can't have it all :-\

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Isaac Eiland-Hall

Oh wow... that would be... AMAZING. And time-consuming. But amazing.

leopard

in thoery not too hard to do, in practice well you know. it depends if you need logic of a simple linear script (i.e. do you need 'if' statements)

its a case of tagging a text field into an object that the user can place a 'script' into, and having something that can process these scripts within the object class.

having written a script language for another project its not that hard, though its not fast (so you'd want to limit it to a few units where its needed, i think requiring the user to enter them will manage that)

then its a case of adding the 'triggers' somewhere, thats the harder bit.

still thinking about this, the potential is amazing, in some circumstances, but only in some.

the hard bit is allowing the script to 'see' the game envirnonment not strictly required but useful, the simple time based events would help hugely though and would be theoretically easier. have increments of say 1 hour, every 'hour' the vehicle object gets a prod to run the script, and is given the hour as a parameter, if the script is set to work on that hour its fired.

as a simple way of saying "go to sleep until the time is 'x'" this is very useful, even in the standard schedule system, e.g. a destination waypioint/station instead of getting a minimum load paramter (or in addition to it) could have an hour added, so the train pulls into a station, and will not leave until the hour is equal to a preset value (or values) forcing a delay and allowing some basic schedulling to be handled

that would probably be easier than a full blow event scripting system and provides many of the benefits.

thinking specifically for low density routes, as a way of forcing a train to wait a while at the end points, but after a set time to move, regardless of the load. allowing a more optimal usage of the investment
My Simutrans on the apple mac homepage http://www.aleopardstail.com/simutrans/Index.html

Isaac Eiland-Hall

Having a way to change which line a convoi was assigned to also would be nice, for example. :)

jamespetts

Leopard,

can you write C++? ;-)
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

leopard

I have a grounding in basic C, and am slowly getting better with objective-C (I run an apple mac c++ doesn't get much use here)

having said that I have written a reasonably powerful (and modular) script language in vb.net, and am about halfway through porting it to obj-c.

what I don't have is enough of an understanding of the way the game is structured to make this work.

it did occur to me that another way to handle this would be a special stop class, which 'captures' anything that visits it until a preset time before letting it go. thus allowing the idea of stabling sidings or a parking lot to be implemented without anything complex.

I'm still considering this one, Having added a hook or two into the core code I've got a few ideas as to how such events could be managed (essentially its just a case of expanding the code for loading/unloading, which should trigger at a stop) to call another function and pass it a string (the script).

needs more thought.
My Simutrans on the apple mac homepage http://www.aleopardstail.com/simutrans/Index.html

jamespetts

The reason that I ask is that there isn't a great deal of spare coder capacity at present - the main developers are bevering away on underground mode and bug fixes (and the lead developer, I think, is generally very busy), and I'm spending much time debugging Simutrans-Experimental, and have frozen the features indefinitely some time ago to allow for debugging.

It would be extremely useful to have another developer on board. This particular idea is a rather complicated one, but perhaps you could start by implementing some minor improvements just to get used to the code?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

leopard

sadly I won;t be on line much longer, a house move will knock me off line in any serious way for a year or so probably, I hope to get a 3G dongle whatsit but won't be right away. I will be grabbing a snapshot before I vanish though, to play with.

hopefully when I return I'll be more useful
My Simutrans on the apple mac homepage http://www.aleopardstail.com/simutrans/Index.html

jamespetts

Gosh - that must be some house move! Best wishes with 3G dongles, and with moving house... :-)
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

leopard

not exactly a huge move, a few miles at the most, just going rented, and not willing to sign up to an 18 month contract with BT with a 6 month house rental contract.

can play on the forum with an iPhone but won't be able to post stuff with it, or sadly download anything
My Simutrans on the apple mac homepage http://www.aleopardstail.com/simutrans/Index.html

colonyan

Um I guess its little late to say but I like this idea. Would certainly be fun...

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

leopard

cable... 18 month contract also, assuming the house is wired already. if its not forget it, chances are minimal.

not to mention I've had dealings with the f**kwits before, and won't touch them again with anything other than a club with a nail in it. the only company ever to make BT look competent, even worse than British Gas...
My Simutrans on the apple mac homepage http://www.aleopardstail.com/simutrans/Index.html

whoami

@leopard: would UMTS be an option in you area/country? OK, 6 months of it might cost the same or more as 18 months with BT.

On topic (well, not really): using linear scripts (having only if and waitfor) with vehicles (running in loops) might allow to model a programming language with the simulator itself. It might even be Turing-complete. ;D