PDA

View Full Version : Sending Variables



Dudex
07-22-2004, 06:51 AM
This is sort of my continuation from my other topic.

Ok, so, what I had was



function pluginRequest(hash) {
var caller = hash.get("ExecutingUserName").toString();
var method = hash.get("Method");

if (method == "move") {
DoMove(caller, x, y);
}
}


So, the DoMove function would require external variables, x and y. Question is how would I get it if I sent it from a flash client using es.pluginRequest(GlobInf.plugin, "move", UserInf); where UserInf would have UserInf.x and UserInf.y.

Would it take the form of my UserInf when i'm using has.get?

Thanks.

peterblaze
07-22-2004, 02:14 PM
Hi Dudex,
Working sample of something You want to get
DoMove(caller, x, y);
You may find in sample files of Monster game posted by Jobe,
link for Monster game: http://www.electrotank.com/Presentations/FF/NY2004/Monster.zip
In particular look for following function:

function pluginRequest(hash) {
var caller = hash.get("ExecutingUserName");
var method = hash.get("Method");
//...
if (method == "New Destination") {
setNewDestination(caller.toString(), Number(hash.get("x")), Number(hash.get("y")));
}
}
You may find that function in FightPlugin.as for server side game logic and in sample files for client side game.
Hth,
Peter

jobem
07-22-2004, 05:05 PM
Hi Dudex,

Peterblaze is exactly right. Only 1 hash map is passed into 'pluginRequest'. It contains only variables, no objects. So, you must access them via the 'get' method. Example: var name = hash.get("name");

Good luck :-)

Dudex
07-22-2004, 07:04 PM
I got it.

so when you send something like so:



GlobInf.x = 5;
GlobInf.y = 10
es.pluginRequest(GlobInf.plugin, "move", GlobInf);


For the flash client, you can access it in the server by



Number(get.hash("x"));


I got one last question... I bet you can guess what it is.. if you haven't already seen the topic :)

jobem
07-23-2004, 08:43 PM
Hi Dudex,

I was out of town on business for the majority of the week. I was connected to T-mobil in the airport yesterday and had a good response to this typed in. I hit 'enter' but my connection was lost and so too was the post, sorry :(

Anyway, there are a couple of problems with your code:

1) You wrote this:

es.pluginRequest(GlobInf.plugin, "move", GlobInf);

The first parameter must be a string name of the plug-in. The name that you gave it in the configuration.xml file. For instance:


es.pluginRequest("TestBeta", "move", GlobInf);

2) You wrote this:

Number(get.hash("x"));

You just reversed 'get' and 'hash'. 'get' is a method on 'hash', so it should be this:

Number(hash.get("x"));

Dudex
07-23-2004, 11:39 PM
GlobInf.plugin seems to work. It does have TestBeta as it's value.

I'm beginning to understand the concept behind this, but there's still that one thing that is really puzzling me. Receiving messages from flash. (which is discussed in the other post).

Thanks for your help nonethless.