Sign in to follow this  
FDsagizi

Build -> Build -> Build and kill all global variables :(

Recommended Posts

[font="arial, sans-serif"][size="2"]Hi all, sorry for my english - use google.translate[img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img][/size][/font]

[font="arial, sans-serif"][size="2"]Next problem, I have 3 scripts.( it is exemple...[img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img] )[/size][/font]


[font="arial, sans-serif"][size="3"]
[code]root.as

int exemple_gloval_var = 1;

script_1.as
#include "root.as"

void main(){
exemple_gloval_var = 10;
...
}

script_2.as
#include "root.as"

void main(){
print( exemple_gloval_var );
}[/code]
[/size][/font]


[font="arial, sans-serif"][size="2"]and I need to compile them, but not all at once.[/size][/font]
[font="arial, sans-serif"][size="2"]When the game starts, it compiles the script 2.[/size][/font]

[font="arial, sans-serif"][size="2"]and running.[/size][/font]

[font="arial, sans-serif"][size="2"]time passes, I need a script 3, the game loads it, and compiles.[/size][/font]
[font="arial, sans-serif"][size="2"]This compilation will kill all global functions.[/size][/font]

[font="arial, sans-serif"][size="2"]I need it to not kill them[/size][/font]
[font="arial, sans-serif"] [/font]
[font="arial, sans-serif"][size="2"]I understand that I can compile all scripts at once, but it's bad, I want to compile as needed.

I also understand that I can use different modules, it is not appropriate, I have to use one global module

need your help! [/size][/font][img]http://public.gamedev.net/public/style_emoticons/default/unsure.gif[/img]

Share this post


Link to post
Share on other sites
Why not just compile them at one time, unless you are working in extremely low memory situations. In that case, you may want to rethink using a scripting language altogether.

Share this post


Link to post
Share on other sites
Currently the only way you can keep the global variables between recompilations is by serializing them, i.e. before the recompilation you enumerate all the global variables and store their values, then after the recompilation you enumerate the variables again and restore their previous values.

Share this post


Link to post
Share on other sites
What I actually do in my engine is I use the 'any' type and the boost unordered_map and hash the values to strings somewhere in the engine's global scope. Still have no idea what it does to the reference counting, but it is something you could consider.

Share this post


Link to post
Share on other sites
[quote name='WitchLord' timestamp='1307160072' post='4819307']
Currently the only way you can keep the global variables between recompilations is by serializing them, i.e. before the recompilation you enumerate all the global variables and store their values, then after the recompilation you enumerate the variables again and restore their previous values.
[/quote]


[font=arial, sans-serif][size=2]Please look at this topic, there is a code - like I restore global variables. But I have a problem with asTYPEID_OBJHANDLE.[/size][/font]


[url="http://www.gamedev.net/topic/604890-dynamic-reloading-script/page__gopid__4827553#entry4827553"]http://www.gamedev.net/topic/604890-dynamic-reloading-script/page__gopid__4827553#entry4827553[/url]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this