The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on October 11, 2016, 09:54:06 AM

Title: [Tutorial] get the type of station.
Post by: Yona-TYT on October 11, 2016, 09:54:06 AM

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.
Title: Re: [Tutorial] get the type of station.
Post by: jameskuyper on October 11, 2016, 07:54:03 PM
Would halt_x::get_capacity() meet your needs?
Title: Re: [Tutorial] get the type of station.
Post by: 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.
Title: Re: [Tutorial] get the type of station.
Post by: 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.
Title: Re: [Tutorial] get the type of station.
Post by: Yona-TYT on October 12, 2016, 05:26:33 PM
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 ".

Title: Re: [Tutorial] get the type of station.
Post by: jameskuyper on October 12, 2016, 08:47:46 PM
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.
Title: Re: [Tutorial] get the type of station.
Post by: Dwachs on October 13, 2016, 06:48:06 AM
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.