Sign in to follow this  
Followers 0
aleReimondo

Where to add my global scripts?

3 posts in this topic

Hi!

I want to add some custom modifications and extensions to String and other

base methods (changes at javascript level).

That changes must be visible at any page of the game and while playing the game.

Where is the place to add the expression to load my script files ?

thanks in advance,

Ale.

p.d. I have tried to inject scripts in a new page, but when loading another

page in the game from main menu, the methods fail execution

with error (shown in console)

------------------------------------

ERROR: Javascript error: s8/8AD.js line 436

TypeError: "hello".printMe is not e afunction

@s8/8ad.js:436

ERROR: GUI: Error executing script s8/8AD.js: Scripting_LoadFile_EvalErrors

------------------------------------

When I query using console

typeof "Hello".printMe it is returned "function"

and it is correctly defined.

Share this post


Link to post
Share on other sites

Changing the standard global objects is generally a very bad idea in JS, so don't do that :). It's particularly problematic in our GUI system since we have a separate global scope per GUI page, with some magic to resolve properties on the real global object when necessary, and SpiderMonkey's JIT optimisations interact in complex ways with global objects too, so it gets confusing and fragile. Just use a normal function instead.

Share this post


Link to post
Share on other sites

I use normal functions, all normal functions and delegation; and all works w/o any problem on V8, IE, etc (without surprises, nor limitations and also fast).

I see that design can impose us limitations to "protect execution success" and can be not safe/possible to run my frameworks here.

IMO the safety at expense of "each page/stage a world" is a severe limit for scripting a game.

Is there a simple way to load js code when booting top context? (at root)

I am asking for a place to patch the engine to load my file

into javascript at boot... as it was part of core js impl.

thanks for your time,

Ale.

p.d.: I am too old to stop when someone say "dont´do that". So if it is possible, I will try;

if it is not possible (at js level), it is also ok; I can try to run in one page.

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  
Followers 0