# Best method for getting information (not a property) from another game object?

**URL:** <https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144>\
**Category:** Questions\
**Created:** [June 14, 2016, 10:21am UTC](https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144 "2016-06-14T10:21:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronburr](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@aaronburr](https://forum.defold.com/u/aaronburr)\
**Post date:** [June 14, 2016, 10:21am UTC](https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144/1 "2016-06-14T10:21:40Z")

</div>

I’m currently working on a project where I have a game board similar to a match-3 style game. I have 2 scripts right now: game.script and board.script.

**game.script** - handles all things related to gameplay and validating the players input and managing what to do with the data

**board.script** - essentially handles the gameboard itself and is essentially a data structure for it. game.script posts messages to the board.script to tell it what to do.

The problem I’m having is I’m trying to do something along the lines of determining whether a boardspot is a valid one for the player to do an action upon. I’m getting input in my game.script, but essentially I’m trying to do a IsValid(x, y) function onto the board.script and get the value back into the game.script.

What is the best method for this, or am I completely doing this the wrong way?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 14, 2016, 10:56am UTC](https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144/2 "2016-06-14T10:56:10Z")

</div>

A couple of different ideas comes to mind:

- Can’t you let the board.script acquire and validate the user input instead of game.script?
- Or can you msg.post() any user interaction from game.script to board.script and then post the result of the board validation back (this makes it become very asynchronous, but that might be fine?)
- Move the board data structure to a Lua module and share it between board.script and game.script

---

<div class="post-metadata">

**Author:** ![aaronburr](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@aaronburr](https://forum.defold.com/u/aaronburr)\
**Post date:** [June 15, 2016, 5:19am UTC](https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144/3 "2016-06-15T05:19:16Z")

</div>

Hmm…I’ll look into the Lua module and see. I was hoping to keep the game and the board separate so that I could potentially reuse the board if I wanted to make a different type of game. (Match-3 Swap game script handles input validation differently than the line draw game.) It seems like I won’t be able to do that easily.

> [@britzl](#):
>
> Or can you msg.post() any user interaction from game.script to board.script and then post the result of the board validation back (this makes it become very asynchronous, but that might be fine?)

Is there a way for a script to wait for a msg response before continuing the rest of the script?

Thanks!

---

<div class="post-metadata">

**Author:** ![Andreas\_Jirenius](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/andreas_jirenius/32/114_2.png) [@Andreas\_Jirenius](https://forum.defold.com/u/Andreas_Jirenius)\
**Post date:** [June 15, 2016, 7:34am UTC](https://forum.defold.com/t/best-method-for-getting-information-not-a-property-from-another-game-object/2144/4 "2016-06-15T07:34:55Z")

</div>

This is a design question that has been discussed several times within the King teams using Defold. I believe there are cases where it is best to use a lua module prior to scripts. Having a big grid is better off centralized (imho) as soon as you need to do all these matching checking, pathfinding etc.  
This is how we did it in Blossom Blast Saga and I would personally do it again like that.
