Cannot access information in material.inc.php from game layout

Game development with Board Game Arena Studio
Post Reply
sygnas
Posts: 2
Joined: 25 April 2020, 07:20

Cannot access information in material.inc.php from game layout

Post by sygnas » 23 May 2020, 11:52

I accessed the information in material.inc.php in the game layout. But I got an error.

Code: Select all

Notice: Undefined property: xisizetest::$TEXT in /var/tournoi/release/games/xisizetest/999999-9999/xisizetest.view.php on line 35
material.inc.php

Code: Select all

$this->TEXT = [
  'PLAYER' => "Player",
  'CARD_EXP' => "Experience card",
  'CARD_SKL' => "Skill card",
  'CARD_AST' => "Assist card",
];
xisizetest.view.php

Code: Select all

public function build_page($viewArgs){
  ...
  $this->tpl['EXP_CARDS'] = $this->game->TEXT['CARD_EXP'];
  ...
}
Why can't i access?

The document says that it can be accessed from the game object.
http://en.doc.boardgamearena.com/Game_l ... mename.tpl

Code: Select all

// Access to some game elements description described in your "material.inc.php":
$my_cards_types = $this->game->card_types;

// Access to any (public) method defined in my .game.php file:
$result = $this->game->myMethod();

sygnas
Posts: 2
Joined: 25 April 2020, 07:20

Re: Cannot access information in material.inc.php from game layout

Post by sygnas » 25 May 2020, 18:16

solved! :D

I used require_once to load an external file from material.inc.php.
I solved it by changing here to require.

I noticed by doing var_dump () in material.inc.php.

I apologize for the trouble.

before:

Code: Select all

require_once __DIR__. '/modules/php/material/TEXT.php';
after:

Code: Select all

require __DIR__. '/modules/php/material/TEXT.php';

Post Reply

Return to “Developers”