Adding new objects to Simutrans

Discuss the free TT-like game Simutrans.
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Adding new objects to Simutrans

Post by Hajo »

There is a tool to add new objects to Simutrans. This includes things like trees, buildings and vehicles as well as abstract things like goods.

The tool is available here:
http://groups.yahoo.com/group/simutrans/files/Makeobj/

ATM I'm creating examples how to use this tool. The first few examples are available here:
http://groups.yahoo.com/group/simutrans ... /Examples/

I hope to be able to add more examples soon.

**
A similar topic exists in the Simutrans feedback forum:
http://www.simugraph.com/forum/viewtopi ... =6&t_id=11
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Re: Adding new objects to Simutrans

Post by Hajo »

MakeObj has now been released officially:

http://www.simugraph.com/forum/viewforum.php?id=12

Documentation is still very scarse, but the list of examples grew somewhat:

http://www.simugraph.com/forum/viewtopi ... =12&t_id=3

Each example contains a readme.txt that tells how to use the example and should provide enough information to allow you to create your own extensions of that type for Simutrans.

IMO particularly interesting is the "newspaper" example that adds a new good and new industries to Simutrans. Good starters, because very simple, might be the "city building", "tree" and "private car" examples.
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

ok... is this just eyecandy then?
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

City buildings and trees can be seen as eyecandy. But MakeObj not only allows to alter the images, but also the objects attributes, i.e. how many passengers a building will produce. So even new buildings exceed the eyecandy level a bit, although not much.

Vehicles, goods and industries are quite important for the player I think. I wouldn't consider them only eyecandy. They are core parts of the game.

The newspapers from the example can be carried with existing vehicles. This is because they are put into goods category 1 (piece goods) and quite a lot of vehicles can transport category 1 goods - due to historical reasons the vehicles still have names like "furniture car" or "books waggon", but the important fact is currently the goods category.

Category 0 means the vehicle can exclusively transport one type of goods. I.e. passengers. Category 1 are piece goods. Vehicles that are suitable for category 1 goods can transport any good of category 1. Category 2 is bulk goods like ore, coal and stones. Category 3 are cooled goods.

You can create new goods that need exclusive vehicles also (just put them in category 0, exclusive goods). I just was to lazy to draw new vehicles for the example. But think that newspapers are actually transported on crates, so they fit well into those vehicles.

If someone wants to have the infamous uranium mine, uranium refinery, uranium power plant and uranium transporters in Simutrans, he can do so. MakeObj allows to create all those for Simutrans - except for the greenpeace activists who try to sabotage your transports.

A better example would probably be to include farms, food factories etc which are completely missing in Simutrans currently. There is a category for cooled goods, which is completely unused ATM.

Let me put it this way:

MakeObj can create all kinds of objects with all their attributes, everything you find in Simutrans. Just take a look at the pak files supplied with Simutrans and you see this is a lot of things that you can change this way. You can create a completely new scenario with MakeObj, if you replace all objects.

I think this is way beyond eyecandy only.

What you can't change with MakeObj are the games mechanics, i.e. the vehicle pathfinding or how industries work. Those things are in the program code.
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

cool

So, you've got buildings, vehicles, industries and cargo types... any other "makeable" things?

Like roads and how fast you can go on them... eg a bumpy road is very cheap to build but you can only go 20mph, and a perfectly flat road costs insane amounts but the speed isn't limited.

Also, how about certain cargo types, and therefore certain vehicles and industries as well, could only be in use from one given year to another given year.

And, how about being able to make climates and set to use certain objects for temperate and so on.
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

BobXP wrote:cool

So, you've got buildings, vehicles, industries and cargo types... any other "makeable" things?
Currently these object types are supported (alphabetically ordered):

bridge (any type of bridge)
building (city buildings, also monuments and tourist attractions)
citycar (the private cars driving in the cities)
crossing (level crossings)
cursor (mouse pointers)
factory (also known as industries)
good (any kind of good)
ground (Basement, gras, outside, shore, water)
menu (Game menus)
misc (Construction, Overheadpower, PowerDest, PowerSource, Sidewalk, Signals)
pedestrian (those people walking around in cities)
smoke (for industries and vehicles)
symbol (Several pictures of miscelaneous usages)
tree (any kind of plant)
tunnel (any kind of tunnel)
vehicle (any kind of player-owned vehicle)
way (Road, Track, Powerline)
BobXP wrote: Like roads and how fast you can go on them... eg a bumpy road is very cheap to build but you can only go 20mph, and a perfectly flat road costs insane amounts but the speed isn't limited.
Currently Simutrans does not support speed limits for roads or tracks.
See also:
http://www.simugraph.com/forum/viewtopi ... =2&t_id=61

Simutrans is still in development, there are a lot of things to do. But once speed limits are implemented you'll be able to create suchlike different roads with MakeObj.
BobXP wrote: Also, how about certain cargo types, and therefore certain vehicles and industries as well, could only be in use from one given year to another given year.
Currently we have too few vehciles overall (mostly just one for each cargo type) so we couldn't introdiuce sucha feature yet - the player nees the vehicles right from the start. See:

http://www.simugraph.com/forum/viewtopi ... =2&t_id=16
BobXP wrote: And, how about being able to make climates and set to use certain objects for temperate and so on.
I think a climate would be a complete set of objects. Of course you can share objects between climates (you can copy the pak files any time), but I think climates will be created and maintained as separate object sets.
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

What's a 'powerline'?

Oh, and in that topic you said that it would be hard to make so many graphics for each of the track etc. types, so couldn't you just put a unlimited-speed one with the game, and let people make their own realistic ones?
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

BobXP wrote:What's a 'powerline'?
It transports electrical power. I had planned to let the power plants produce electrical power, and transport the power with powerlines. The idea was that factories that are supplied with electrical power raise their productivity and that cities that are supplied with electrical power grow faster.

Eventually there was the idea that electrified track must be supplied with electrical power and if the player fails to supply the powerplant continuously brownouts and blackouts will happen and electric engines will stop - currently I don't think this will work well in a game so I don't think we will introduce that in Simutrans.

Overall the powerlines aren't finished so far. The powerline code is incomplete and has bugs. A brief info how to try them is here:

http://www.simugraph.com/forum/viewtopi ... =6&t_id=12

ATM I think the current powerline code will be used for pipelines, and new, different code for powerlines has to be written. Power distribution should be nearly instantly.

Overall I'm afraid powerlines and pipelines would just clutter the map. Maybe pipelines should be put below the ground. This would also solve a lot of problem regarding crossings of pipelines and roads or railroad track ... regarding the fact that both powerlines and pipelines are several years in developemnt now without significant progress, I don't think they will be introduced officially soon. There are so many ideas, sometimes I don't even know where to start.
BobXP wrote: Oh, and in that topic you said that it would be hard to make so many graphics for each of the track etc. types, so couldn't you just put a unlimited-speed one with the game, and let people make their own realistic ones?
Yes, sure.

But I first need to change the code so that speed limits will be recognised and considered by the vehicles. Second is, there are no menus in the game to select different way types to be built, so the menus must be implemented also. If that's all done, it should be quite easy. I.e. just modify the existing images to introduce new track or road types with different speed limits.
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

You know what, everything you add to Simutrans tends to make it go more in the direction of WC. 8)

*goes to test out powerlines*
<!-- End Of Post !-->
Image
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

Ok:

*builds power line and inspects it*

Only the power line that came with the coal mine is on strong, the others are on fail.

*connects power line to coal mine*

Like that worked.

*makes a shorter connection*

*demolishes existing connection*

Game crashes.
<!-- End Of Post !-->
Image
User avatar
eis_os
TTDPatch Developer
TTDPatch Developer
Posts: 3603
Joined: 07 Mar 2003 13:10
Location: Germany
Contact:

Post by eis_os »

Hi Hajo

Could you explain me via email/pm how the internal powerline code works?
Like how you determine the profit... :)
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

eis_os wrote:Hi Hajo

Could you explain me via email/pm how the internal powerline code works?
Like how you determine the profit... :)
I've sent the powerline (also used for pipelines) sourcecode by email. I hope it will help you.

Payment is easy: for every delivered quantity of electrical power the player is paid a little amount of money.
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

What if the AI delivers the power?

BTW, can you make it so that electricity actually goes DOWN the wire?
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

BobXP wrote:What if the AI delivers the power?
Less work for the player? Maybe boring, maybe even annoying if the AI doesn't do it right and the player could do it better by himself.
BobXP wrote: BTW, can you make it so that electricity actually goes DOWN the wire?
I answer with a definite maybe.

Given the fact that over a time of more than two years I couldn't create well working powerlines, I'd rather tend to say no but yes.
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

Assuming that the whole map is stored in an array...
when the power line at a power station switches on or off, a one-liner:

SwitchPower (XCoordinateOfThePowerLine, YCoordinateOfThePowerLine, WhetherToTurnThePowerOnOrOff, 0)

And...

Sub SwitchPower (X as Long, Y as Long, Power as Boolean, Dir as Byte)
'(I'll ommit tabs as the tab key switches to 'Preview')
If TheMapArray (X+1,Y).ObjectType = PowerLine and Dir <> 1 Then SwitchPower (X+1,Y,Power,2)
If TheMapArray (X-1,Y).ObjectType = PowerLine and Dir <> 2 Then SwitchPower (X-1,Y,Power,1)
If TheMapArray (X,Y+1).ObjectType = PowerLine and Dir <> 3 Then SwitchPower (X,Y+1,Power,4)
If TheMapArray (X,Y-1).ObjectType = PowerLine and Dir <> 4 Then SwitchPower (X,Y-1,Power,3)
TheMapArray(X,Y).PowerIsOn = Power
End Sub

If you can't translate this to C, then tough.
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

Nice.

But you notice that this switches the whole network immediately?

I thought when you asked if the power could go down the line, you want to see how it spreads through the network - I mean spread slowly so that you can watch.

Also I had intended to have a maximum power restriction for lines, once consumers demand too much on that line, they get a brownout. I'm not quite sure how to simulate that by using your code ?
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

Imagine a row of lights powered by a switch. Turn the switch on, all the lights turn on at once. Unless the wires go round the Earth five times or somet. Get the hint?

About the demanding too much: In the SwitchPower procedure, you would have to have something to say which way the electricity went over each wire. Then, go through again and at every split, send one backward to increase the current, and at every merge, send one backward to decrease the current. This would take a while, and would need to be called every time you changed the power network. After that, route through again over each wire, and if the current was over the maximum for the wire, the wire would melt.

Assuming :arrow: is a tab...

When the power line switched on or off:

SwitchPower (XCoordinateOfThePowerLine, YCoordinateOfThePowerLine, WhetherToTurnThePowerOnOrOff, 0)
If WhetherToTurnThePowerOnOrOff = 1 Then
:arrow: SendCurrentCheck (XCoordinateOfThePowerLine, YCoordinateOfThePowerLine)
:arrow: SendMaxCurrentCheck (XCoordinateOfThePowerLine, YCoordinateOfThePowerLine)
End If

And when you changed the network:

X = XCoordinateOfWhereYouChangedIt
Y = YCoordinateOfWhereYouChangedIt
TrackToPowerSource (ByRef X, ByRef Y)
If TheMapArray(X,Y).PowerIsOn = 1 Then
:arrow: SendCurrentCheck (XCoordinateOfThePowerLine, YCoordinateOfThePowerLine)
:arrow: SendMaxCurrentCheck (XCoordinateOfThePowerLine, YCoordinateOfThePowerLine)
End If
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

BobXP wrote:Imagine a row of lights powered by a switch. Turn the switch on, all the lights turn on at once. Unless the wires go round the Earth five times or somet. Get the hint?
Sorry. This is the way I want to do it. I just thought you'd ask for something different.

The current code was written for pipelines actually. For pipelines it makes sense that the fluids need some time to spread. The powerlines need different code. There is a reason why the thing is hidden from the players. It's just nothing that could be used as it is.

Thank's for the examples anyways. At least now I know that you can code :) When will you start to write your own simulation?
BobXP
Tycoon
Tycoon
Posts: 2720
Joined: 04 May 2003 11:00
Location: Torquay, England
Contact:

Post by BobXP »

When

a) I get some graphics
b) I find a way to convert x/y of the mouse coordinates to x/y of the piece of terrain pointed to.

BTW, just noticed a bug in the code I gave you. If you have a powerline that goes round in a loop, the program will hang next time you modify it or the power switches on or off. I'll think about that for a while.

As for pipelines, call UpdatePipelines say, every second.

Sub UpdatePipelines ()
:arrow: For X = 1 to WidthOfMap
:arrow: For Y = 1 to HeightOfMap
:arrow: :arrow: If TheMapArray(X,Y).ObjectType = Pipeline And TheMapArray(X,Y).Water > 0 Then
:arrow: :arrow: :arrow: If TheMapArray(X+1,Y).ObjectType = Pipeline And TheMapArray(X+1,Y).Water = 0 Then Amt = Amt + 1
:arrow: :arrow: :arrow: If TheMapArray(X-1,Y).ObjectType = Pipeline And TheMapArray(X-1,Y).Water = 0 Then Amt = Amt + 1
:arrow: :arrow: :arrow: If TheMapArray(X,Y+1).ObjectType = Pipeline And TheMapArray(X,Y+1).Water = 0 Then Amt = Amt + 1
:arrow: :arrow: :arrow: If TheMapArray(X,Y-1).ObjectType = Pipeline And TheMapArray(X,Y-1).Water = 0 Then Amt = Amt + 1
:arrow: :arrow: :arrow: If TheMapArray(X+1,Y).ObjectType = Pipeline And TheMapArray(X+1,Y).Water = 0 Then TheMapArray(X+1,Y).Water = TheMapArray(X,Y).Water / Amt
:arrow: :arrow: :arrow: If TheMapArray(X-1,Y).ObjectType = Pipeline And TheMapArray(X-1,Y).Water = 0 Then TheMapArray(X-1,Y).Water = TheMapArray(X,Y).Water / Amt
:arrow: :arrow: :arrow: If TheMapArray(X,Y+1).ObjectType = Pipeline And TheMapArray(X,Y+1).Water = 0 Then TheMapArray(X,Y+1).Water = TheMapArray(X,Y).Water / Amt
:arrow: :arrow: :arrow: If TheMapArray(X,Y-1).ObjectType = Pipeline And TheMapArray(X,Y-1).Water = 0 Then TheMapArray(X,Y-1).Water = TheMapArray(X,Y).Water / Amt
:arrow: :arrow: End If
:arrow: Next:Next
End Sub

There's bound to be bugs in this though.
<!-- End Of Post !-->
Image
User avatar
Hajo
Route Supervisor
Route Supervisor
Posts: 420
Joined: 17 Jan 2003 09:52

Post by Hajo »

BobXP wrote: BTW, just noticed a bug in the code I gave you. If you have a powerline that goes round in a loop, the program will hang next time you modify it or the power switches on or off. I'll think about that for a while.
The fix is easy: Each powerline object needs a marker.

Then you can do

1) Clear markers of all powerline objects
2) Traverse the network like in your example. Mark each accessed powerline object. Only recurse if you hit a yet unmarked powerline object.
Post Reply

Return to “Simutrans”

Who is online

Users browsing this forum: No registered users and 0 guests