News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

[Tutorial] get the type of station.

Started by Yona-TYT, October 11, 2016, 09:54:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


I need to determine if a station is for passengers or goods for Chapter 3.
Or better yet, if we can show on the toolbar stations merchandise only.

jameskuyper

Would halt_x::get_capacity() meet your needs?

Yona-TYT

Actually what I want is to prevent players choose stations passengers or email when what is needed is to load goods.

Dwachs

halt_x::get_capacity() is the only available method right now. Just pass an arbitrary good-descriptor (not passenger/mail) to this function.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on October 12, 2016, 06:21:02 AM
halt_x::get_capacity() is the only available method right now. Just pass an arbitrary good-descriptor (not passenger/mail) to this function.
Already found this solution:  ;)


if ((is_station_build(0, stb4, good_alias.passa)==null)||(is_station_build(0, stb4, good_alias.mail)==null)){
   pot8=0
   backward_pot(7)
   tile_x(stb4.x, stb4.y, 0).remove_object(player_x(0), mo_building)
   return result=format(translate("The station Nr. %d should be for goods!."),count2)+" ("+stb4.tostring()+")."             
}

     
I hope this code no problem, because it is in the function "
is_work_allwoed ".


jameskuyper

Quote from: Yona-TYT on October 11, 2016, 09:36:51 PM
Actually what I want is to prevent players choose stations passengers or email when what is needed is to load goods.
If you have a specific good in mind, call halt_x::get_capacity() to determine whether that halt has any capacity to store that good. Since all goods other than passengers and mail are interchangeable as far as storage capacity is concerned, if you don't have a specific good in mind, feel free to use any convenient good.

Dwachs

Quote from: Yona-TYT on October 12, 2016, 05:26:33 PM
I hope this code no problem, because it is in the function "
is_work_allwoed ".
You cant call the remove_object in this function in network games. For a tutorial it should work.
Parsley, sage, rosemary, and maggikraut.