[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/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 - Decouple precompiled scripts from virtual machine object

GameMonkey Script

GameMonkey Script Forums
It is currently Sat Sep 26, 2020 9:02 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun May 13, 2012 4:26 pm 
Offline

Joined: Sun May 13, 2012 4:16 pm
Posts: 5
Is there a way to create a series of functions from a single script string, and place them outside of an instantiated gmMachine object?

I have the following restrictions on my use of GM:

* I have thousands of game objects that need a unique script of their own (I tried doing gmMachine machine[1024], and that used over 70 megabytes of RAM) [I refuse]
* Objects use non-unique function names for event functions, such as onDeath() etc

I've heard about CompileStringToLib() and ExecuteLib(), but I still need a way to differentiate between two identically named functions from two separate game objects.

My apologies if I haven't explained this properly. Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Mon May 14, 2012 12:31 pm 
Offline

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


Top
 Profile  
Reply with quote  
PostPosted: Tue May 15, 2012 8:25 am 
Offline

Joined: Sun May 13, 2012 4:16 pm
Posts: 5


Top
 Profile  
Reply with quote  
PostPosted: Tue May 15, 2012 12:48 pm 
Offline

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


Top
 Profile  
Reply with quote  
PostPosted: Sun May 20, 2012 6:36 pm 
Offline

Joined: Sun May 13, 2012 4:16 pm
Posts: 5
Here's a diagram of what I'm trying to do (at least this is what I would do if I wrote my own little toy language):

BTW, I've read the documentation that came with GM, and looked through some of the C code, but still for the life of me can't figure out what I'm supposed to do to even compile a script (bar the method described in the tutorial, which I cannot use). Perhaps the problem lies in the fact that I'm thinking about the language in the wrong terms. It's seems very generic, designed to be useful to a wide variety of clients, but in my case, the hassle involved in getting it to work is slowly becoming farcical.

I'd take a leaf out of SFML's book in doing user-friendliness. I've had little trouble getting that system to work for my needs, and their documentation is utterly supreme. It really facilitates getting things working quickly.


Attachments:
example.png [14.64 KiB]
Not downloaded yet
Top
 Profile  
Reply with quote  
PostPosted: Mon May 21, 2012 11:23 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 708
Yes, there seems to be some misunderstandings going on. If you are willing to persist, hopefully myself and other forum members can make helpful suggestions.

I looked at your diagram. Here's some comments:
o C++ functions bound to script - This is expected normal usage, gmScriptEx and gmBind can help with C++ binding. Note that script bindings use a C style callback so they may need extra routing to C++ class instances. Often applications implement their own reflection system which simplifies conversion from messages, schedulers, remote calls and also scripting.
o Machine represents the script virtual machine.
o Object templates - not sure the format, but default functions, generic functions or templates where parts are actually replaced are all possible. GM can help here depending on what you have in mind.
o Compiled and non-compiled script - Sure, compile to byte code in advance or execute strings (which internally runs a compile phase).
o Object instance with UIds, local vars, event handlers. - Event function calls are a great use of script (as opposed to writing great chunks of time critical code in relatively slow script). Object instances can be specialized with GM. Local variables though? What do you want to do with them? In GM, local variables are local to the current function and not accessible outside. This can be problematic and hard to understand vs C/C++ and some other scripts. Unfortunately GM does not implement closures so scopes to not work like C/C++. For 'local' to object variables, the best thing is to use 'member' variables, which look like 'this.someVar' or '.someVar'. It is good practice to avoid the global table in GM apart from perhaps a handful of true globally accessible things.


Further resources:
Compile to byte code: viewtopic.php?f=5&t=65
Articles/Tuts: viewtopic.php?f=14&t=160 (Not sure if this is the tutorial you mention reading.)
GM ScriptEx + gmBind: viewtopic.php?f=14&t=422


Top
 Profile  
Reply with quote  
PostPosted: Tue May 22, 2012 3:06 pm 
Offline

Joined: Sun May 13, 2012 4:16 pm
Posts: 5


Top
 Profile  
Reply with quote  
PostPosted: Wed May 23, 2012 3:59 am 
Offline

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 22, 2012 5:51 am 
Offline

Joined: Sun May 13, 2012 4:16 pm
Posts: 5


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 22, 2012 10:53 pm 
Offline

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


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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