Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Strife

Scripting

This topic is 6846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Cool, thanks for the reply, but one more question.

So would you recommend a wrapper class that would
hold the Lua instance, and its functions would be mapped
into Lua. Sort of like the LuaWrapper acts like a V-table?


class LuaWrapper
{
Lua* pL (or however it is done )
ICurrentThing* pT (An object being ''ran'')

LuaWrapper()
{
// Set up Lua and map LuaWrapper''s functions,
// isDrunk and Jump, into it.
}

void RunScript( ICurrentThing* pO )
{
pT = PO;
// RUn the script found in pO into Lua
}

void isDrunk( ... )
{
... pT->IsDrunk();
}

void Jump( ... )
{
,,, pT->Jump()
}
}

Share this post


Link to post
Share on other sites
Advertisement
Taulin:

I think with the registered functions Philomath means stuff like EnemyNear() and EnemyStrength(enemy). Those are the hooks back into your engine.

Philomath:

I''ve looked at Lua before for scripting in a programming game (people write AI scripts and they can compete against each other). The project never got beyond the planning stage, but that''s another issue. Nevertheless, I found the Lua documentation to be a bit lacking in terms of ''example code''. I''ve also been looking at stuff like SeeR, Small, EiC and even Python (which was quite amazing in some ways). None of the scripting languages I mentioned above have been able to provide a rather seamless integration of Script-C/C++ and C/C++-Script. Take Lua for example, you still have to write wrappers which push/pop stuff from the stack. Although this in itself is fairly trivial, it''s still a pain in the ass.

OK, I might be a bit lazy here , but I''ve been researching cooler ways for almost seamless integration. For a native DLL, which were to be used by the script, you wouldn''t have to register a thing (just use the exports and unmangle the names). Of course, calling scripted-functions from C/C++ is another issue. But, how about letting the script-compiler generate a C/C++ file which does all the wrapping for you ... that would be a great help and save development time! I know, that some of these features are used in current scripting languages, but I''m still waiting for *the* scripting language ... if I have some spare time, I might have to do my own (I''ve done a C-Parser before).

Please don''t get me wrong about Lua ... it''s really fast and cool, but sometimes I''m just wondering why it''s so hard working with these things...

MK42

Share this post


Link to post
Share on other sites
Thats the way I''ve used it. I''m sure that there are other ways of setting it up. In fact as you can have multiple lua "environments" you could have a seperate lua environment for each object with only object specific data and functions available. I have never tried that but it would work as well (unless you hade too many objects or create them on the fly -vs- existing in a pool from level loadup). It really is up to personal preference and the task at hand. I use a seperate lua environment for user interface elements (buttons, pulldown boxes etc...)with its own unique set of C bound functions and data. I also setup and control my particle emmiters with lua scripts (usually precompiled, and no the script does not get called every frame). I figure the more I can accomplish with scripts the more generic and reuasable I can make the engines and tools.

Philo.

Share this post


Link to post
Share on other sites
Thanks for the replies. The scripting part
was never a problem. I just never read or saw any
examples of actual code ( pref. some class ) using
a scripting engine or VM. Have you all looked into
the JScript vm? I read on Gamasutra that I think
it was the Vampire:Masq used it.

Thanks!

Share this post


Link to post
Share on other sites
MK42:
EnemyNear() and EnemyStrength(enemy) are hooks to the engine, anything that takes extensive calculation (like pathfinding and line of sight stuff) is not suitable for any scriping language(Yea, I know EnemyStrength is just a lookup but hey its an example). I agree with you about the lua documentation, it does not have many examples. However the language itself is simple enough not to need to many (16 odd reserved words for lua3.2). Unfortuantly the implementation side of it could use many more examples and there explanation of tables is horrible (and they are so easy to use.. go figure).

I don't pretend lua is the best language by any strech of the imigination, every language has its pros and cons. Any of the languages you listed could be used effectively. I use lua because of its ease of implementation (one call to lua_open(), register your 'C' functions, and remember to call lua_close() when you are done, 20 min, depending on how many functions you need to register), its speed, I have yet to see a scripting language beat it in a comparison, and its extensability.

As far as registering you functions it can be a bit of work if you are adding it to an existing project. However Tolua is supposed to do this for you from header files (I've never used it though).

VBA with its com interfacing is close to what I think you are asking for, but I won't go there

Philo


Edited by - Philomath on October 17, 2000 5:24:35 PM

Share this post


Link to post
Share on other sites
Philomath:

I didn''t mean to bash lua ... it''s just that these ''limitations'' don''t make the scripting solution easier to work with. I guess tolua just looks at the PE Image of the LIB file and undecorates the mangled names ...

You are right, though, that lua is still one of the simplest scripting languages to use ... but, wouldn''t it be cool to have a scripting solution, which you could just drop into your project (no matter how complex it is) and it would work ...

VBA is *not* an option ... I refuse to use it

MK42

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!