Re: Messaging
Status: Alpha
Brought to you by:
cwalther
|
From: James C. W. <jfc...@ya...> - 2011-10-29 20:53:05
|
Oh, thanks. I personally didn't get that from the manual..Here's the original section:
3.6.2 Inter-Node Communication
Often some way of communication between one displayed node and another is needed.
The obvious naive way of achieving this would be defining a global function in node A
and calling it from node B. However, this doesn’t work as expected in many cases: Lua
doesn’t care in which file a function was defined. Even if it was defined in the node.lua file
of node A, calling the function from node B will make the code run in node B. Anything
it does that makes an implicit assumption about the “current node” will affect node B, not
node A.
To solve this problem, a messaging system is provided. By including
messages {
messagename = handler,
...
}
in its node.lua, a node can define a set of messages to which it responds. Each entry in
the messages table links a string messagename to a handler function that will be called
when the corresponding message is received. The message handler function then runs in
the node where it was defined, not in the one who sent the message. To send a message to a node, use its message method.
..And here's what I feel would be a bit clearer:
3.6.2 Inter-Node Communication
Often some way of communication between two or more simultaneously displayed nodes is needed.
How does that look?
Thanks,
James
--- On Sat, 10/29/11, Christian Walther <cwa...@gm...> wrote:
From: Christian Walther <cwa...@gm...>
Subject: Re: Messaging
To: "Content creation for the Pipmak Game Engine" <pip...@li...>
Date: Saturday, October 29, 2011, 5:19 AM
> The way you phrased your question leads me to belive the messaging system can only be used for nodes visible at the same time...is that so?
Yes. Is the documentation not clear enough about that? How could it be improved?
> The point is when a hotspot is clicked in one node, to move to node 34 and execute a function(in this case, panning to a different angle as a light flickers on).
There is no need for inter-node messaging for that. You can execute that function in an enternode handler of node 34, and if it shouldn't be done every time you enter the node, you decide whether or not based on some global setting, either an entry in the "state" table if it should be part of saved games or a plain global variable if it shouldn't, that you can set from the previous node.
-Christian
------------------------------------------------------------------------------
Get your Android app more play: Bring it to the BlackBerry PlayBook
in minutes. BlackBerry App World™ now supports Android™ Apps
for the BlackBerry® PlayBook™. Discover just how easy and simple
it is! http://p.sf.net/sfu/android-dev2dev
_______________________________________________
Pipmak-Users mailing list
Pip...@li...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
|