Jump to content
MakeWebGames

Need help with a coding question regarding mod development


TonyCisseroni

Recommended Posts

I've started building my own mod for GL2, it's a basic dice game.

The game works and shows the dice totals in the error / success message. 

And I'm storing the results of each dice in session variables, which I also see is working.

array(2) {
  ["userID"]=>
  string(1) "1"
  ["DICE_GAME"]=>
  array(2) {
    ["diceone"]=>
    int(2)
    ["dicetwo"]=>
    int(4)
  }
}

I'm looking at the BlackJack game MOD code as an example and I see they are reading session variables in the TPL file like this {card} {suite} etc.

I tried this same method using {diceone} and {dicetwo} in my TPL file but it's not showing my result.

Is there any documentation on the templating or does someone know what I'm missing here?

dicegamebet.jpg

<div class="dice">dice one: {diceone} dice two: {dicetwo}</div>

 

Edited by TonyCisseroni
Link to comment
Share on other sites

4 hours ago, TonyCisseroni said:

I see, building the element appears to be the part I was missing. I will look into that a little further. 😊

You’ll need to pass these from your controller into your view. This’ll be when you call the render function in the inc.php file, the {var} are actually just variables as part of the template system.

Im on a plane so can’t be more helpful but I’ll post some code when I can. 

So you’re basically wanting to pass your data to the template in these types of calls:

            $this->html .= $this->page->buildElement('theftHolder', array(
                "theft" => $theftArray
            ));

 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, Dave said:

You’ll need to pass these from your controller into your view. This’ll be when you call the render function in the inc.php file, the {var} are actually just variables as part of the template system.

Im on a plane so can’t be more helpful but I’ll post some code when I can. 

Hi Dave, I'm starting to get the hang of it. 👍 I'm able to pass the variables from the controller to the view and they are now appearing. 

Now I have a bug with everything being repeated twice, it's probably something small I'm overlooking.

 

double.jpg

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...