• 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
daerid

Questions on implementation

2 posts in this topic

I'm testing out a rudimentary AngelScript console, and am running into a problem with it. It has to do with how asCScriptEngine::ExecuteString is implemented. Right now I want to be able to do something like this (I have registered the string type and print() function):
AngelScript Console 0.1 (AS Ver: 1.10.1b)

>> string test = "Hello, World!\n";
>> print(test);
This does nothing at the moment, because my console loop looks like this (pseudo-code):
string line;
while(1)
{
  getline(cin,line);
  if(!cin)
    break; // Use CTRL+Z to exit
  
  pEngine->ExecuteString("as_console",line.c_str());
}

Now, I'm pretty sure the reason this doesn't work is because of how asCScriptEngine::ExecuteString works: It wraps the string in a "void ExecuteString() {\n" + str + "}" script chunk. This turns the above line string hello = "Hello, World!\n"; into a local variable, which isn't found in the subsequent call to print(hello); Is there anything way to create a variable in one call to ExecuteString() and then reference it in another call? Or am I completely missing how AngelScript works?
0

Share this post


Link to post
Share on other sites
You can't reference a global variable throught ExecuteString, and you have discovered why : the script you pass to ExecuteString is simply parsed and executed in a local defined function.

What you can do :

Scan the input collecting it into a string. When you scan that the input is "run" then, call execute string with the collected string.


string line, alllines;
while(1)
{
getline(cin,line);
if(!cin)
break; // Use CTRL+Z to exit

if (line != "run")
alllines += line;
else
pEngine->ExecuteString("as_console",alllines.c_str());
}



hope it helps.

AbrKen.

0

Share this post


Link to post
Share on other sites
Variables declared in ExecuteString() are as you noticed local to the function, and cannot be used in subsequent calls to ExecuteString(). It can however access global variables declared by a previously built script, or registered by the application.

What abrken said would allow a user to write scripts with multiple lines and execute them with ExecuteString(), which is a good thing in my opinion.

If you want the user to be able to create new variables on the fly, you will have to find some way of storing the declaration for later use. I suggest you register some object, that would work kind of like a dictionary, or a map. It could for example look like this in the console:

>> mem("test") = "Hello, World!\n";
>> print(mem("test"));

You could also do something like this:

>> declare string test
>> test = "Hello, World!\n";
>> print(test);

Where the declare instruction is a special instruction that registers a new global property with the script engine used for the console. AngelScript currently doesn't have any way of unregistering functions or properties again, so the user wouldn't have any way of undeclaring a variable like this.

Yet another solution would be to allow the user to alter the script compiled with the engine used by the console. This way it would be possible for a user to add new global variables and even functions. Each time the user alters the script, it is recompiled. If you do this it might be a good idea to store the value of each of the global variables before rebuilding the script, then after the build reload the values, otherwise the values will be reset with each build.



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