Topic: Functions request

Please add here any suggestion about lua functions you are missing.

I'm also using this thread to tell you that you can add custom script functions using c++ plugin (using the MScriptContext class)
http://www.maratis3d.org/engine_docs/cl … ntext.html (it's a basic lua wrapper)

If you used it and would like to share your additional functions to be added to the next Maratis release, please tell us smile

Re: Functions request

I'll start with a few missing functions :

Current todo list :
- is mouse on top of objects
- ray-tracing test (for fps, etc)
- bones access : getBone, rotate, translate...
- get current window size

Under reflexion :
- save Level (xml or bin) ?
- translating the cpp GUI-Demo in lua ?

Re: Functions request

-mouse on top of objects
-window size
-Get window width/height.
-Set/Change resolution.

That is what I am about to write it here. It is really important to make menu buttons.

And also the HUD. It would be nice if another scene could be set up as overlay scene through script like the demo. HUD is very important part of a game.

- disable Escape key quit. Then quit the application through script.

I am making a fps game. I will upload it in showcase forum in a couple of days. May be during its development I could find some more required functions.

Thanks
Regards

Re: Functions request

- createGameVariable("name", value) + set/get, for sharing simple variables

- improve "getObject" function to access other scenes :
getObject("box") will get current scene box like currently
getObject("Scene2", "box") will get Scene2 box object

- cloning

Re: Functions request

Well basically all kind of vector math functions for the things that getPosistion returns (a table of 3 elements, 3d vector tongue). Maybe some matrix math too? But I don't know if it has any use in the Lua api. I know for sure that Vector math is vital though, right now I have to do that stuff by myself which is a bummer.

Also delta time. Oh god please deltatime. getDeltaTime() or something like that. How does anyone live without deltatime?

Re: Functions request

Hi, yes a minimum vector match would be good,

for delta time : you don't need delta time for the scipt, it's handled internally, the script is always synchronized at 60hz.
(in c++, the game update too)

Re: Functions request

Will the locked hz work even at framerate drops?

Also regarding vector math, I've started implementing Maratis vector library here: https://github.com/BitPuffin/MLuaUtil/b … /MVec3.lua

Edit:
Keep in mind though that I haven't even tested it yet. And I'm not that good at Lua tongue

Last edited by BitPuffin (2012-08-05 15:16:39)

Re: Functions request

Hi,
nice ! you look to know more about lua than me smile

For the framerate drops, yes it works, even if the rendering is 60fps or 15fps (the logic and the rendering are separated).
It just stops synchronizing if the framerate goes below 1fps (because the system cannot recover).

Re: Functions request

Awesome work BitPuffin!

I've been thinking about this sort of modular API for a while. I was wondering whether it could be integrated with the normal API, but after having a look at lua, building the objects (well, tables) in C/C++ seems incredibly painful without designing the code to work like that from the ground up.

Implementing it in lua seems like a nice way to do it though. Can easily wrap up entity/object functionality in a lua MEntity object or something. If there's ever anything that proves to be too slow, it could be moved back into the standard C/lua interface.

Distributing it with Maratis might be more... interesting. I was actually talking to lqez a few days ago and he's had a couple of requests to be able to load libnpk packages from a buffer, so I guess it would be possible to have the standard modules in an embedded npk package in Common. That shouldn't be too hard to do, and should be able to be integrated into the build system. It looks like there's even python bindings for libnpk... so even scons should work (although VS/XCode may be more interesting...) Anyway, if you want me to set up this system, I can take a look at it smile

Re: Functions request

I personally don't know how to do a class like system in lua, after doing some research to find how to do it from c++ I felt it was complicated, I didn't think about doing it in lua, it's quite a fast language, if you are interested in doing that for the rest of the engine it will give some nice manipulating classes smile

Re: Functions request

I did exactly the same thing for Maratis, and for another project, I took a look at how to expose classes, started trying, then decided it was far too difficult to be worth it tongue

I will try and help BitPuffin with whatever time I can afford to get some of the functionality wrapped up nicely... and will make sure MPackageManager is robust enough to load an embedded npk file. Still have to think about how to run the embedding script at compile time... but I'm sure I'll figure something out smile

Re: Functions request

Delta Time: Ah I see. But what if an update takes more time than expected? Wouldn't that have implications on the script updating? If so, still a good idea to have delta time. Because then even if updates slow down it will update values according to how much time since the old update smile

Well, if we want a class system we should really take a look at adding Squirrel as a scripting language. Squirrel is incredibly light weight and has a lot of nice features. It's a lot like Lua, but a bit more familiar if you've used C++, C#, Java etc. It has tables and comes with classes! I personally prefer much compared to Lua and think it's quite a spectacular language! Lua is good, but Squirrel takes the good from Lua and adds other goodies too big_smile If you read some of what the developer says, you'll notice that he loves Lua - but has some valid criticisms!

Re: Functions request

I have some requests,
getMass(Object)
setMass(Object)
getFriction(Object)
setFriction(Object)
These would be useful for if I were to add some buttons for customisation to the car in my car game.
And maybe something like reloadLevel could be useful for resetting every object in a level.

Last edited by Almighty Laxz (2012-08-14 08:21:50)

Re: Functions request

A function for toggling shadows on lights, for lower spec systems shadows off would help the fps and on higher spec systems shadows can be on. Example enableShadows(Light0) and disableShadows(Light0), that sort of thing.

Re: Functions request

transitions between scenes

Re: Functions request

I would like to be able to change a meshs texture from script, so insted of having one mesh for summer and one for winter I can just have summer and winter textures. For my use case snow on my buildings or terrain.

Re: Functions request

some way to turn off physics for an object and make things a ghost from script like

setPhysics(Object, 1) --turns physics on
setPhysics(Object, 0) --turns physics off

setGhost(Object, 1) --turns ghost on
setGhost(Object, 0) --turns ghost off

EDIT:
and thumbs up to a mouse over function its needed

Last edited by Rapdorian (2013-02-05 00:37:52)

Re: Functions request

Hi, this is a nice thread.
Unless i missed something, i think Pause function is needed, so we don't have to hard code everything, if we want to pause the game.

Re: Functions request

getting all entities of the scene


1) I've not read the code, so, I'm only guessing, I suppose the entities (if not parented with any other) are children of the current scene, so, the getChilds() function, without any parameter, may return a table of them.

2) even better a new function like this:
getEntities(scene, type, needle) where parameters are optionals. "scene" is needed to get entities from specified scene, "type" specifies the kind of entity you wish returned in the table (objects, sounds, camera, texts or lights), needle is a string useful for getting entities with particular name containing it, for example you may wish to get all objects named enemy (enemy1, enemy2,...) so, as needle you write "enemy"

Re: Functions request

I don't know if that's possible to do, but that will be very cool to have a
isSoundOver(object), quite similiar to isAnimationOver

Re: Functions request

Seems like you can't do scalar/vector multiplication currently. Please add this . It should be fairly trivial. Just assume that if the metatable of one component is not a vec3, then it's a scalar.

Re: Functions request

For sounds something like

makeSoundGlobal() this would be used to make particular sounds able to be heard anywhere on the level, good for ambient sounds or sounds that are constantly near the player (like foot steep sounds) right now my foot steep sounds change volume and i think even pitch every time i mouse look on a FPS camera.

Re: Functions request

Argoon :
for global sounds, you can use a stereo sound (only mono sounds are 3d)
or select the "local" option in the sound property and the sound position will be local to the camera (the global effect you want) > set the position to "0 0 0" for a centered sound

Re: Functions request

Thanks anael that will do.

Now is it possible to tag objects ( is different from the name, objects with different names can have the same tag), if not something like getObjectTag() would be helpful.

anael i can't seam to find the local option that you talk about on the sound properties, thres only a relative option is that what you are referring to?

Last edited by Argoon (2013-08-26 23:51:46)

Re: Functions request

yes, sorry it's "relative"