• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

cnirrad

Scripting Languages

22 posts in this topic

I would like to use a scripting language from C++, but the only things I''ve found are about making your own languages from scratch. Is there anyone out there not trying to re-invent the wheel and has some experience with using some existing language? I would like to know what language can be used from C++ easily, and where I can find some info about it. Thanks.
0

Share this post


Link to post
Share on other sites
I have actually tried using Lua, both through ClanLib, and straight c/c++, but could not get it to work. It gave me about 16 errors, all of which were in the headers provided by Lua.

In fact, here are the errors straight from MSVC:

--------------------Configuration: luaTest - Win32 Debug--------------------
Compiling...
test.cpp
c:\program files\microsoft visual studio\vc98\include\lua++.h(60) : error C2146: syntax error : missing '';'' before identifier ''d_lo''
c:\program files\microsoft visual studio\vc98\include\lua++.h(60) : error C2501: ''lua_Object'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\lua++.h(60) : error C2501: ''d_lo'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\lua++.h(125) : warning C4003: not enough actual parameters for macro ''lua_pushcfunction''
c:\program files\microsoft visual studio\vc98\include\lua++.h(189) : error C2146: syntax error : missing '';'' before identifier ''d_table''
c:\program files\microsoft visual studio\vc98\include\lua++.h(189) : error C2501: ''lua_Object'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\lua++.h(189) : error C2501: ''d_table'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\lua++.h(192) : error C2629: unexpected ''class LuaObject (''
c:\program files\microsoft visual studio\vc98\include\lua++.h(192) : error C2334: unexpected token(s) preceding '':''; skipping apparent function body
c:\program files\microsoft visual studio\vc98\include\lua++.h(200) : error C2629: unexpected ''class LuaObject (''
c:\program files\microsoft visual studio\vc98\include\lua++.h(200) : error C2334: unexpected token(s) preceding '':''; skipping apparent function body
c:\program files\microsoft visual studio\vc98\include\lua++.h(247) : error C2146: syntax error : missing '';'' before identifier ''getobject''
c:\program files\microsoft visual studio\vc98\include\lua++.h(247) : error C2433: ''lua_Object'' : ''virtual'' not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\lua++.h(247) : error C2501: ''lua_Object'' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\lua++.h(260) : warning C4183: ''getobject'': member function definition looks like a ctor, but name does not match enclosing class
c:\program files\microsoft visual studio\vc98\include\lua++.h(284) : warning C4003: not enough actual parameters for macro ''lua_isnil''
c:\program files\microsoft visual studio\vc98\include\lua++.h(305) : warning C4003: not enough actual parameters for macro ''lua_isfunction''
c:\program files\microsoft visual studio\vc98\include\lua++.h(312) : warning C4003: not enough actual parameters for macro ''lua_isuserdata''
c:\program files\microsoft visual studio\vc98\include\lua++.h(319) : warning C4003: not enough actual parameters for macro ''lua_istable''
c:\program files\microsoft visual studio\vc98\include\lua++.h(543) : warning C4003: not enough actual parameters for macro ''lua_register''
c:\program files\microsoft visual studio\vc98\include\lua++.h(543) : warning C4003: not enough actual parameters for macro ''lua_pushcfunction''
c:\program files\microsoft visual studio\vc98\include\lua++.h(547) : error C2061: syntax error : identifier ''lua_Object''
c:\my documents\luatest\test.cpp(23) : error C2440: ''type cast'' : cannot convert from '''' to ''class LuaValue''
No constructor could take the source type, or constructor overload resolution was ambiguous
c:\my documents\luatest\test.cpp(23) : error C2228: left of ''.store'' must have class/struct/union type
Error executing cl.exe.

luaTest.exe - 16 error(s), 8 warning(s)

------------------------------------------------

I probably have Lua installed wrong, since the example that this is from is straight from a working example I found on the website. Any ideas?
0

Share this post


Link to post
Share on other sites
I''ve never heard of a "lua++.h" header. I just read their reference manual to figure it out. Here''s a short example of how to parse a single script file named "test.lua":
  
#include <lua.h>


int main(void) {
lua_State *State;

State = lua_open(0);
lua_dofile(State, "test.lua");
lua_close(State);

return 0;
}

The "test.lua" file can just be empty for now. That''s meant to be a C file, not C++. If you want it to be C++, replace the include with:

#ifdef __cplusplus
extern "C" {
#endif
#include <lua.h>
#ifdef __cplusplus
}
#endif

Link whatever libraries are required and build it; Make sure it works. If it doesn''t, something is setup incorrectly.

0

Share this post


Link to post
Share on other sites
The example complied correctly! I don''t remember exactly where I found the lau++.h, but I got it because I thought I needed it for cpp. Anyway, it seems to be working, thanks a lot!
0

Share this post


Link to post
Share on other sites
You might also want to check out:
http://www.mozilla.org/js/spidermonkey/

That way you can use java-scripting for scripting language.
It has a really good searchable API specification, though the tutorials are a little bit lacking.
Anyway, its quite easy to use.
0

Share this post


Link to post
Share on other sites
I use python for all of my scripting needs. It''s pretty easy to set up, and I''m working on some macros to make it even easier.

Take care,
Bill
0

Share this post


Link to post
Share on other sites
Here''s a link to lua++ just incase someone is interested.. Personally I''ve been struggling for a long time to try to embed Python into my app.. Still got a long way to go before it works as it is supposed to do..

Don''t give up..

Wannabe
0

Share this post


Link to post
Share on other sites
Never heard of Lua, will give it a try, after giving up embeding PERL, I decided to go with TCL, get the ActiveState implementation if interested, its simple both to program and embed, but it is more suited to work with C than C++.

anyway, good luck!

0

Share this post


Link to post
Share on other sites
I had originally started using spidermonkey (java-script) and got it to compile into my test app. But became quite irritated with their implementation of classes around classes.

I finaly wound up with a nice little scripting language that you guys might want to check out; Simkin. I read about it here and then went to download it... you have to send a request and provide information regarding it''s use... but in all honesty it''s worth the trouble.

I haven''t been working with it lately but I like the way it implements scripts - you can use XML and what the author calls treenode. I personally like the treenode because the parser is built-in, the XML script needs another parser not included in the package. But if you have a class and want to expose it to the interpreter it''s really easy - much easier than spidermonkey.

Happy coding (and scripting)

Dave "Dak Lozar" Loeser
0

Share this post


Link to post
Share on other sites
Just go for COM and ActiveX Scripting (or .NET hosting if you want to be fancy schmancy). Much easier in the long run -- if someone wants to use their preferred scripting language then they just have to install an appropriate ActiveX control.
0

Share this post


Link to post
Share on other sites
I''d have to second the nomination for python. Python is very slick and well supported. You can find lots of online tutorials and actual books on it. It also comes with a very useful set of libraries.
0

Share this post


Link to post
Share on other sites
a Word on COM + ActiveX, its only supported in Windows, be 100% sure you want your game to run on nothing but Windows before taking that option, or well be prepared to do a lot of porting afterwards.

Checked LUA, seems great, C like syntax, object support, small and portable out of the box, no strings attached, I think thats the way to go, have to do some more checking though

0

Share this post


Link to post
Share on other sites
quote:
Original post by Kwizatz
Never heard of Lua, will give it a try, after giving up embeding PERL, I decided to go with TCL, get the ActiveState implementation if interested, its simple both to program and embed, but it is more suited to work with C than C++.

anyway, good luck!




I'm using TCL for my game engine's embedded interpreter. It works great. I had to jump through a couple of hoops to make my command extensions (written in C) work with C++, but it was mostly painless.

If anyone's curious, TCL somewhat resembles LISP, but with a lot fewer parentheses ;-)

[EDIT] Sorry for the double post.


Edited by - DaTroof on March 7, 2002 12:30:42 PM
0

Share this post


Link to post
Share on other sites
I cant speak for the other scripting languages mentioned here, but using the SpiderMonkey java-script engine is real easy, and you can compile scripts on program initilization.

It really isnt much harder than calling
JSScript* scriptPointer = JS_CompileScript(char* script, a few standard params) as soon as possible and then JS_ExecuteScript(scriptPointer,..standard params..) when the script is needed. Better than a pure interpreter anyway.

Defining native functions that are exposed to the script, is also very easy, but i dont think its possible to check very well for number of passed arguments and their type before its too late.

Also java-script is a pretty good scripting language, the syntax is simple but is reminiscient(spelling?) of Java/C/C++.

And no, im in no way affiliated with the people who made it

Edited by - ziphnor on March 7, 2002 3:56:13 PM
0

Share this post


Link to post
Share on other sites
I''m in need of a scripting language suited to a text-based rpg. Anyone who''s played around with MOO will know what kind of capabilities I want. Any recommendations? At the moment I''m looking at Python because it''s OO and (supposedly) plays nice with C++.

-----------------------------------
"It''s groin-grabbingly transcendent!" - Mr. Gamble, my teacher, speaking of his C++ AP class
0

Share this post


Link to post
Share on other sites
compiled script are better than interpreted since they are faster, and has a smaller size.. i personally dont like the idea of linking native functions using a table since its not practical and harder to code. i prefer compiled script (virtual assembly) so the VM function can be created just like normal assembly i.e. via interrupt. parameters are stored in stack.

''compuphase small'' is a good and fast scripting language, but not easy to implement native functions because it uses dynamic-typed variables. normal typed variable are faster and easier to code.

my recommendation for building your own ''c'' style scripting lang. is by using Gold Parser, quite efficient but not easy..

(phew.. always anonymous)
0

Share this post


Link to post
Share on other sites
quote:
Original post by Ziphnor
It really isnt much harder than calling
JSScript* scriptPointer = JS_CompileScript(char* script, a few standard params) as soon as possible and then JS_ExecuteScript(scriptPointer,..standard params..) when the script is needed. Better than a pure interpreter anyway.


Hi Ziphnor,
I started out investigating spidermonkey... I got the interpreter into my code and compiled without much fuss. But, when it came time to expose my objects I became frustrated by the manner in which they force you to wrap the java-script classes around your classes. Did I miss something or are you not exposing classes to the interpreter?

I was sold on using Spidermonkey because of the language itself and how easy it is for non-programers to pick it up and write script... so the only thing I have to solve before moving back to the monkey is how to expose my objects (or rather the API that I want the script writers to use).

Thanks,


Dave "Dak Lozar" Loeser
0

Share this post


Link to post
Share on other sites
I decided to go with a handle based system.

For example(in AI script)

getNearestEnemy() returns a handle(integer) to the nearest hostile game object. The script language can then call for example setTarget(myHandle, getNearestEnemy()) etc.

You can also expose factory methods to the script, that can construct objects on the native(C/C++) side, but only recieving a handle to it.

Forgot this: Performance wise, a handle system is also pretty smart because it means there is less conversions going on between the native and script side. Sending alot of data between the 2 is expensive.

Edited by - ziphnor on March 8, 2002 4:49:27 PM
0

Share this post


Link to post
Share on other sites

Hi!

If i want to use python - do i have to open the source of my game ?

I interpret the "open source definition 1.9" in the way that i have to publish the source of my commercial projects to be able to use python.

McMc
0

Share this post


Link to post
Share on other sites

has anyone tried CLEAR PARSE OE. a great parser builder.
i already stucked with it...

(always anonymous)
0

Share this post


Link to post
Share on other sites
quote:
<i>Original post by McMcDonald</i>

Hi!

If i want to use python - do i have to open the source of my game ?

I interpret the "open source definition 1.9" in the way that i have to publish the source of my commercial projects to be able to use python.

McMc


Don''t think so. Ultima Online uses Python for the AI scripts. That''s the only game I know that uses Python, but it sure isn''t open source..

0

Share this post


Link to post
Share on other sites
cnirrad,
I found an interesting couple of articles on Scott Bilas''s web site LINK. The article titled FuBi: Automatic Function Exporting
for Scripting and Networking
might be one of interest to anyone implementing there own scripting language...

While this isn''t everything you need to know to implement a scripting language it is informative with respect to providing an API for your scripting language - or rather, how to expose your functions (C or C++) to the executor.

Dave "Dak Lozar" Loeser
0

Share this post


Link to post
Share on other sites