[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
GameMonkey Script • View topic - passing associated member from table as this

GameMonkey Script

GameMonkey Script Forums
It is currently Tue Nov 24, 2020 12:58 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon May 31, 2010 7:45 am 
Offline

Joined: Mon May 31, 2010 7:40 am
Posts: 5


Top
 Profile  
Reply with quote  
PostPosted: Mon May 31, 2010 9:15 pm 
Offline

Joined: Mon May 31, 2010 9:12 pm
Posts: 1


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 01, 2010 1:01 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 708
Welcome to the forum dasmatarix and crapshoot :) Glad you sorted that out.
Yes, the scoping can be a bit confusing at first. Global, local and member are quiet explicit and independent scopes, except for global read access. Using members rather than globals can often make code simpler and safer.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 01, 2010 5:04 am 
Offline

Joined: Mon May 31, 2010 7:40 am
Posts: 5
*hides head in shame* a typo, woah, thats bad :(

Ok maybe a better question then is what is the best IDE for script editing, with helpful things like script editing and compilation errors like, "well done moron, you made a spelling mistake".

Fixed the typo and it worked fine, no scoping problems (yet).

Thank-you very much :P


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 01, 2010 12:49 pm 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 708


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 01, 2010 1:16 pm 
Offline

Joined: Mon May 31, 2010 7:40 am
Posts: 5
Thanks, I'll definitely check that out


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 05, 2010 11:23 am 
Offline

Joined: Thu Jan 01, 2004 4:31 pm
Posts: 307


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 05, 2010 3:39 pm 
Offline

Joined: Mon May 31, 2010 7:40 am
Posts: 5
Yeah, it's a terrible example of script, I'm not actually using it for anything other than testing can use a associated member keyVar from a table to call a function. Where I am using it is part of some net code integration with the script, GM gets the name of the player and the gm variables they have changed from my c netcode, and now it uses that name to reference one of the players in my table of players, and apply the changes.
eg.

// getSyncSource() - c bound function that returns a string containing the name of the source of the net packet
// getSyncType() - c bound function that returns a string containing the name of the variable that has changed
// getSyncVal() - c bound function that gets the value that has changed

// Player is a function that creates a player and has other functions to manage it
player = function(thePlayerName, theIP)
{
thisPlayer = table(playerName = thePlayerName, IP=theIP);
thisPlayer.getName = function(){return .playerName;};

// set method for setting class variables
thisPlayer.set = function(func, param)
{
if (func=="playerName")
{
this.playerName=param;
}
};
return thisPlayer;
};

players = table(player1 = player("mike","145.0.0.1"), player2 = player("john","122.0.0.1"));
players[getSyncSource()].set(getSyncType(),getSyncVal());

I've since changed how it works a bit, but it does help to know I can use a name, not just an index, since if I'm understanding the script reference pdf correctly, gm reorders a table as it expands and contracts, so players[0] might be a different player next time I try to sync, especially across multiple computers.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group