Jump to content

Editor events in Lua


Rick
 Share

Recommended Posts

@Josh, are you thinking of letting our Lua scripts in LE3 tap into editor events (that you would have to define of course)?

 

For example when a new entity is added to the scene it would be nice to know about that via an event that any of our Lua scripts could hook into and maybe passing in the entity as a parameter. For me personally I would want to know that because I'm creating an in LE editor terrain pathfinding thingoid. A person drops this pathfinding thingoid into the scene and it generates a grid on the terrain. Then when they are placing objects in the scene I would like to automatically set the nodes that the object is over to closed. The most efficient way I can see to do this is via an event that the editor would fire saying a new entity was added that any script can tap into.

 

I think for logical scripts there is probably a good number of events from the editor that could be useful to tap into.

Link to comment
Share on other sites

@Josh, are you thinking of letting our Lua scripts in LE3 tap into editor events (that you would have to define of course)?

 

For example when a new entity is added to the scene it would be nice to know about that via an event that any of our Lua scripts could hook into and maybe passing in the entity as a parameter. For me personally I would want to know that because I'm creating an in LE editor terrain pathfinding thingoid. A person drops this pathfinding thingoid into the scene and it generates a grid on the terrain. Then when they are placing objects in the scene I would like to automatically set the nodes that the object is over to closed. The most efficient way I can see to do this is via an event that the editor would fire saying a new entity was added that any script can tap into.

 

I think for logical scripts there is probably a good number of events from the editor that could be useful to tap into.

 

 

Another option could be a button in the interface to "refresh" or "recalculate" the grid after placing objects.

Caus some people will prefer to drop objects fast, move them etc ... in a first pass , than on a second phase say : "Ok my level will be that,

now let's make the grid"

I find that way of working lot more logic , than having the grid recalculated at each user action like entity drop or more ?

Stop toying and make games

Link to comment
Share on other sites

That is one options but if I know when an entity was added and what entity, I'm pretty sure I can make it have 0 delay in updating the grid to close those nodes. I guess I would also need an entity move event also to update nodes as it moves. Why not shoot for the stars I guess :P Real-time updating would be pretty sweet! I can do this now but I have to maintain a list of all objects and compare every so often to find what is there or gone and positions.

 

I would take a button feature also.

 

Thinking more I'd need to have a remove entity event fired before it actually gets removed also.

 

I find that way of working lot more logic

 

Having to press a button to do the calculation is more logical than it just automatically happening? I think your assumptions is that it'll take a little while to calculate. I compare this feature to lighting where you used to have to generate the light map in a scene. Isn't it easier and more convenient in LE when you don't have to do that and it just works real-time :P

Link to comment
Share on other sites

out of curiosity, why are you asking to do this in LE3? Josh just implemented recast into the engine and i would suspect its been worked somehow into the editor...

 

but in any case, you can always just make it when the path is being created and while actually going to the space to make sure it is not occupied... that way the pathfinding is responding to its surroundings...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Eventually, I intend to have an editor script system that plugs into editor events and can control objects in the engine. As for letting entity scripts themselves access the editor, that seems difficult, because they would need to run with and without the editor.

 

I am not going to include any plugin or editor script functionality in the first release because I can't design a system to solve an undefined problem. I'll let people use the editor for a while, find out what kinds of things they want to do with it, and then design a plugin system with that knowledge. If I tried to design that now we would end up with a system that doesn't really work.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

out of curiosity, why are you asking to do this in LE3? Josh just implemented recast into the engine and i would suspect its been worked somehow into the editor...

 

Asking for editor events accessible via Lua. My pathfinding was just an example usage as to why editor events could be useful in general. There will be other useful scripts that could be created if we are able to tap into these events.

 

but in any case, you can always just make it when the path is being created

 

The example I was looking at was more around the grid creation not so much the path. In the system I have so far you put the terrain pathfinding model in your scene and it builds the grid to the terrain over multiple cycles allowing you to do other things while it's making the grid. When an object is added in design mode ideally I would know that via an event and again over multiple cycles if required close the nodes the object is sitting on. Similarly if the terrain is altered an event would be fired and over multiple cycles the pathfinding model automatically adjusts the height of the nodes in the area the terrain is on. Would just be nice to make this all automatic right in the editor as I like that sort of thing personally. Again, pathfinding just an example, but there will be other situations where it'll be nice to know when editor events are happening in design mode in our scripts. I don't feel scripts have to just be game scripts, but design mode functionality can be added to give more functionality and easier usage. Again, just a preference I have and would like to provide anyone using my scripts.

 

Eventually, I intend to have an editor script system that plugs into editor events and can control objects in the engine. As for letting entity scripts themselves access the editor, that seems difficult, because they would need to run with and without the editor.

 

Which is why having a global variable that tells you when you are in edit mode vs run mode would be ideal. This is what I do with my Pi-Main so all my other Pi scripts know what mode I'm in because it's nice to have different functionality depending on the mode.

 

 

If I tried to design that now we would end up with a system that doesn't really work.

 

Not really asking for a plugin system (although it would be nice eventually), just asking that you think of a bunch of different events the editor could fire and let Lua hook into them so scripts can know when the event is fired and they can react if the script developer so wishes.

 

Possible Events

=============

Terrain modified

Terrain created

Terrain deleted

Save command

Entity added to scene

Entity removed from scene

Link to comment
Share on other sites

What will probably end up happening is I will expose various hooks and events, with the disclaimer that the system is completely experimental and could change at any time. Then after a long period of trial and error, the system will be finalized and become a real supported feature.

My job is to make tools you love, with the features you want, and performance you can't live without.

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.
Note: Your post will require moderator approval before it will be visible.

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...