• 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.
Sign in to follow this  
Followers 0
waheyluggage

a few questions...

6 posts in this topic

Hi Firstly congratulations on writing a nice bit of software. I'd implemented Lua but switched to AngelScript as it seems to suit my needs and it's a bit clearer on how to get things working. The majority of my code is written in straight C. So far everything has gone smoothly but I have a few questions. * In AddScriptSection what's the relationship between module and section? What exactly is a section? I have several scripts (.as files) for my frontend - would I use the unique filename as the module name? If so what do I put for the section? * I have a C structure type called Screen and I want the scripts to use this but by reference only. So I have a Screen_SetPosition( Screen *scr, U32 x, U32 y ). How do I handle something like this? * How do I pass variables to script functions. I can't find an example for the life of me. I have a script like this... void Initialise( int a ) { Script_Printf(a); } The Printf function works fine (it's not a proper print, just wanted to debug it), so if I pass it Script_Printf(20) it prints 20 but the passed in variable is always comes out as 0. I call ctx->SetArguments( 0, (asDWORD*) &val, 1 ); before Preparing and executing the script. I've tracked this down to something to do with the argument size but I don't know what else I need to do. * Is there a problem with having several scripts with the same function name? That's all the questions I have (for the moment :) ). As a suggestion would it be possible on having a tutorial about getting a basic system up and running? What I mean is, it's straightforward to get a script in there and running but how do you work with 20 or 30 scripts? One for each enemy ai? at the same time? Even if it was something as simple as having two script files that print a message over a period of time. eg. // script 1 void Update( void ) { while (true) { Print( "hello world", 10, 10 ); Wait(1000); Print( "I've waited a second", 10, 10); Wait(500); } } // script 2 void Update( void ) { while (true) { Print( "I'm waiting for the application before carrying on", 400, 10 ); Wait(); Print( "Ok. Now I'll wait a bit before going back to the start, 400, 10 ); Wait(500); } } It would help me loads as getting a script to run isn't a problem but multiple scripts together is another matter entirely. I'm a bit scared that I'll do something stupid and have bugs creep in later on. Thanks and keep up the good work! This is definately more application friendly than lua. I found lua to be too much about the lua language and not enough on embedding it in real world situations (ie. games).
0

Share this post


Link to post
Share on other sites
First of all I would like to thank you for choosing AngelScript. If you find that there is something missing in the library please let me know.

I recognize that AngelScript is still missing a lot of things, tutorials and examples are one such thing. I will try to write some, but I have a lot of features that I want to implement in AngelScript and that is my priority right now.

* The module name is kind of like a namespace. You could for example have two different modules with the exact same function signatures. The application can then choose in which module to call the functions by specifying the module name.

The script section name is only used for compiler messages, so that the user is able to identify in what part of the script the error is. If you are compiling files, then a good section name is the file name.

* You have several options for this. You could let the script store the pointer to the screen object directly, like "Screen *screen;". You could also register a special handle object, that would allow the script engine to do automatic reference counting on the screen object (if you're using this). Another option would be to register the screen object as a global property.

The fact that your screen functions take a pointer to the screen object, allows you to register the screen functions in several ways:

RegisterGlobalFunction("void Screen_SetPosition(Screen &, uint, uint)", asFUNCTION(...), asCALL_CDECL);
RegisterGlobalFunction("void Screen_SetPosition(Screen *, uint, uint)", asFUNCTION(...), asCALL_CDECL);

You may even register it so that it appears like an object method to the script.

RegisterObjectMethod("Screen", "void SetPosition(uint, uint)", asFUNCTION, asCALL_CDECL_OBJFIRST);

* I believe the problem is that you are doing it in the wrong order.

ctx->Prepare(...);
ctx->SetArguments(0, (asDWORD*)&val, 1);
ctx->Execute();

Prepare() sets the context up for executing the function, and also defines how many parameters that are expected, etc.

* No, there is no problem with this. If the two functions have different parameter types they can even be in the same script module (function overloading). If they have the same parameter types you need to compile them into two different modules (namespace).

To have 20-30 scripts that all have the same script function signatures, you would compile the scripts into different modules, where the module name ideally reflect the AI type.

---

I agree with you. In my opinion Lua was written in order to accomodate new language constructions such as the metatables, which I believe is a good thing, but not useful for everyone. With AngelScript I'm not trying to invent new language constructs, I'm simply trying to write a scripting library that is as easy as possible to use and embed in C++ applications.

Regards,
Andreas
0

Share this post


Link to post
Share on other sites
Hi

Thanks for the quick reply!

Regarding the module\section name thing. That makes sense - I was going with the module name as the filename but I see how it works now. Thanks.

And you were spot on with the Prepare thing, just had to move a function call and it all worked fine!

Thanks again!

Scott
0

Share this post


Link to post
Share on other sites
Quote:
Original post by WitchLord
* The module name is kind of like a namespace. You could for example have two different modules with the exact same function signatures. The application can then choose in which module to call the functions by specifying the module name.


Sorry to hijack the thread with something unrelated, but are there any plans in version 2.0 to allow namespaces declared in the script, then perhaps we wouldn't need to worry about the whole module thingy?

Quote:

The fact that your screen functions take a pointer to the screen object, allows you to register the screen functions in several ways:

RegisterGlobalFunction("void Screen_SetPosition(Screen &, uint, uint)", asFUNCTION(...), asCALL_CDECL);
RegisterGlobalFunction("void Screen_SetPosition(Screen *, uint, uint)", asFUNCTION(...), asCALL_CDECL);

You may even register it so that it appears like an object method to the script.

RegisterObjectMethod("Screen", "void SetPosition(uint, uint)", asFUNCTION, asCALL_CDECL_OBJFIRST);


In version 2.0 you're going to remove pointers and pass objects by references. How will this work exactly? If you pass them by reference by default and in the function I modify the variable, it shouldn't be altered when the function returns, but because you're passing them by reference, it will be modified. Perhaps the solution is to pass them as a constant reference, unless a special modifier is used (such as function(object & modifyable);)


Like I said, I know this isn't helping the original posters' questions, but I was just reading your reply and thought of those questions.

Thanks in advance.
0

Share this post


Link to post
Share on other sites
I don't think he minds, after all he already got the answers he wanted. And the topic title still suits your post. :)

I don't have any immediate plans to add namespaces in the scripts, but it would certainly be possible. Maybe in a future version of 2.x.x.

An object will be passed by reference to functions, but it will be transparent to the script writer. This means that if the script writer writes a function that takes an object parameter by value, the script engine will make a copy of the object before passing it to the function. Passing the parameters as const refernence would be faster, but would also require changes to the language that I don't want to do. Anyway, if the script writer wants the extra performance he could himself declare the function to take the arguments as const ref.

The fact that all objects are stored by reference instead of directly on the stack, allows me to have better control over the objects. For example the exception handler can identify the object type dynamically, which makes it much easier to write. It will make it much easier to write context serialization, which is something that has been asked for. The interface between application and script functions should also become easier to work with. It will also allow the application to register functions that take references to objects it doesn't know anything about beforehand, for example if the script writes a class that inherits from an application object, it can send the derived object to the application, and the application can dynamically determine the script object's properties and methods.

There are some drawbacks with this, as it puts restrictions on the application functions that can be registered, but I believe that in the end it will be for the better. I will try my best to minimize the restrictions, hence less need for wrapper functions.

Regards,
Andreas
0

Share this post


Link to post
Share on other sites
I'm just wondering how these references fit in with the host code. If you register a function with AS2, do you have to use references there, or are pointers also allowed (I don't know how C(++) deals with references internally).
0

Share this post


Link to post
Share on other sites
Internally references and pointers are the same thing to C/C++, it's just the allowed operations that are different.

AngelScript will hold the references in a handle object (kind of like a smart pointer), so it is not a direct reference like in C++. However I plan to have AS2 automatically convert these handle objects to direct pointers/references to the true object, so the application still can register normal functions that take pointers to objects. It will be possible to access the handle object as well, for example if the application wish to query properties on script declared classes.

Obviously this will cause a performance hit when it comes to handling objects, but I think the greater flexibility will compensate for it.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0