Author Topic: [Tutorial] get the type of station.  (Read 1166 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

[Tutorial] get the type of station.
« 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.
« Last Edit: October 11, 2016, 03:50:03 PM by Yona-TYT »

Online jameskuyper

Re: [Tutorial] get the type of station.
« Reply #1 on: October 11, 2016, 07:54:03 PM »
Would halt_x::get_capacity() meet your needs?

Offline Yona-TYT

Re: [Tutorial] get the type of station.
« Reply #2 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4236
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [Tutorial] get the type of station.
« Reply #3 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.
Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

Re: [Tutorial] get the type of station.
« Reply #4 on: October 12, 2016, 05:26:33 PM »
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:  ;)


Code: [Select]
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 ".


Online jameskuyper

Re: [Tutorial] get the type of station.
« Reply #5 on: October 12, 2016, 08:47:46 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4236
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: [Tutorial] get the type of station.
« Reply #6 on: October 13, 2016, 06:48:06 AM »
     
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.