Author Topic: [regions]¿player = null or player = 9 ?.  (Read 546 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 773
  • Helpful: 19
    • Simutrans-BLOG
  • Languages: ES
[regions]¿player = null or player = 9 ?.
« on: October 28, 2016, 11:21:23 AM »
error:



How to know if the player is null ?, I use player_x(pl).is_active()?


Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 1527
  • Helpful: 75
  • Languages: EN
Re: [regions]¿player = null or player = 9 ?.
« Reply #1 on: October 28, 2016, 03:56:25 PM »
Surely you could test the value?
Code: [Select]
local po = player_x(pl)
if (po) {
    // stuff that needs po to exist
}
[CODE]

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4072
  • Helpful: 146
  • Languages: EN, DE, AT
Re: [regions]¿player = null or player = 9 ?.
« Reply #2 on: October 30, 2016, 07:32:11 AM »
@DrSuperGood: No. This is a design flaw of the scripting api (by myself). It would need some minor changes.

@Yona: could you please always copy the relevant scripting code into your bug reports? Are you sure, you got the order of the parameters right?

Parsley, sage, rosemary, and maggikraut.

Offline Yona-TYT

  • Devotee
  • *
  • Posts: 773
  • Helpful: 19
    • Simutrans-BLOG
  • Languages: ES
Re: [regions]¿player = null or player = 9 ?.
« Reply #3 on: October 30, 2016, 05:06:19 PM »


Code: [Select]
if ((pl-2)<num && pl!=0 && pl!=1 && pl!=14)


{


if (playersave[pl-2].plsave==null && !tile_x(coord_label1[pl-2].x, coord_label1[pl-2].y, coord_label1[pl-2].z).find_object(mo_label))


{


local c_label = {x=coord_label1[pl-2].x, y=coord_label1[pl-2].y}


label_x.create(c_label, player_x(pl), translate("Entre player number (1-12)"))


player_x(pl).book_cash(10000)


}
      }