Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

todo: dynamically code editing #4

Open
brownman opened this issue Mar 19, 2011 · 1 comment
Open

todo: dynamically code editing #4

brownman opened this issue Mar 19, 2011 · 1 comment

Comments

@brownman
Copy link

is it possible to change+reload some mvc part of the code?

my suggestion includes an option to make this framework more scriptable.

@sinisterchipmunk
Copy link
Owner

As of last night, Jax controllers support an update() function. (I haven't yet committed the code though, so expect it within another 24 hours or so.) If you define this function, it will be called automatically periodically, and it will be passed a timechange argument representing the number of seconds passed since the last update. You could use this to calculate AI, move a space ship, operate a combat system, and other off-screen logic. I don't think this addresses the idea of a scripting language, however, so let's talk about that:

Javascript is by its very nature dynamic. You should be able to execute custom code on the fly by simply passing it into eval(). This is also very unsafe, however, unless the code has first been sanitized. Otherwise a malicious user could hijack the game, especially if you save the script anywhere (such as for use in multiplayer). So, a domain-specific language (DSL, or scripting language) would have to be written. It would be interesting indeed for Jax to support such a DSL out of the box, but I'm not convinced of the viability. Jax has no up-front knowledge of the structure of your game (is it a flight simulator? first person shooter? RPG?), so I don't know if we can expect it to be able to manipulate it very effectively.

On the other hand, it could possibly provide a very limited scripting language that could, for example, redirect to other controllers, add instances of models to the world, add particle systems, etc.; and also provide "hooks" for the developer to add their own scripting commands (such as stopEngines() or reloadAmmo()).

It's an interesting idea in any case, but a very long-term improvement and certainly not something I'll add before the first official release. I'll leave this ticket open as a reminder, and if anyone else wants to take a shot at implementing this, they're more than welcome to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants