Jump to content

Where to add my global scripts?


aleReimondo
 Share

Recommended Posts

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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...