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

Allow "Extra" values to be defined via code #196

Open
Jeronimoo opened this issue Jun 27, 2013 · 2 comments
Open

Allow "Extra" values to be defined via code #196

Jeronimoo opened this issue Jun 27, 2013 · 2 comments

Comments

@Jeronimoo
Copy link

Hi,

I am currently looking into using AwayBuilder as a level editor. One of my needs is to retrieve data based on a helper mesh orientation, scale, and other data accessible from AwayBuilder, and transform it into game specific data (i.e. "Extra").

These "helper meshes" exist for level designer's convenience and productivity. They do not appear in game. Their orientation, position and other data are visual representations of other informations required by the game. There can be a lot of those meshes, and when the formula to translate helper mesh data into information usable by the game is complex enough, it's not ideal to compute them at runtime.

If AwayBuilder allowed to store code into the "Extra" value fields, and save the actual results in AWD files, this problem would be solved :)

(and eventually add the result of the formula in AwayBuilder's UI, next to the Extra value field)

What do you think about this ?

If you like it but don't have time for implementation, I could do it for you (unfortunately, for a price).

Either way this feature would be nice addition in that it makes AwayBuilder more useful for more types of games :)

@rob-bateman
Copy link
Member

Hey Jeronimoo

can you elaborate a bit on what you mean by "code"? do you mean actionscript code? how would you execute the code? How would it have bearing on what you are trying to calculate and how would you calculate it ahead of compilation?

@Jeronimoo
Copy link
Author

My bad, by code I meant script. There probably exist several open source interpreters written in AS3 that we could include within AwayBuilder. They turn string input into executable AS3 code at runtime.

The scripting language itself can look like AS3 or not, it depends on the interpreter we use. I use hscript, but it's in Haxe so it would have to be turned into a SWC or ported to AS3. I heard a long time ago about AS3Eval, which I believe is an AS3 interpreter written in AS3. There must be several others I would guess.

Anyway to go on with the example from first post, let's say one type of helper mesh I use is a cone. The level designer uses X/Y/Z, rotationX/Y/Z and scaleY of such cones to visually represent, let's say, a trigger that will affect the player with a force.

To allow AwayBuilder to output correctly formed game data into the AWD file, the level designer would for instance create a template cone and add Extra field(s). Values for these fields are Strings that will go through the script interpreter so that the helper cone position, rotation and scale are transformed into game data.

To make it super simple let's say we just add up x, rotationX and scaleX, then the Extra value field would be
x + rotationX + scaleX

Things could get more complex if you want to access other helper mesh data. Let's say the cone is tied to a sphere or a cube representing the area covered by the trigger. The script should be able to access the sphere data from its mesh name with a dot syntax, for instance. Or maybe both the sphere and cone are within a container, and that container's Extra would then access cone and sphere children using for example Away3D API, except it will be script (a string interpreted by AwayBuilder at runtime). hScript could do that, so there should be other existing interpreters able to pull that off as well.

I'm not sure my explanation is clear enough. If you think of your own example maybe that'll help you better see the use of this feature, and maybe you'll also find a better way to implement it for all I know :)

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