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

Help compiling code

11 posts in this topic

Argg, I'm already having trouble. I read on the overview how to write a program that compiles anglescript code, and I wrote a program. The problem is, it crashes when it runs (no compiler or linker errors)!
#include <angelscript.h>

int main(int argc, char *argv[])
{
  asIScriptEngine *engine;
  
  // Load the script
  const char *script = "script.ang";

  // Compile the script
  engine->AddScriptSection("module", "section", script, strlen(script), 0);
  engine->Build("module", 0);
  
  return 0;
}  

That's my C++ code
float global_var = 0;

void DoSomething()
{
  ++global_var;

  if( global_var > 10 )
    global_var = 0;
}

That's the angel script code. I used the library that I created with the Dev-C++ project file. I think it may be a problem with the library I made, but I'm not sure. On a similar note, PLEASE make a downloadable static library!
0

Share this post


Link to post
Share on other sites
OK, first of all, engine is just pointing to a random bit of memory, you need to call asCreateScriptEngine. You should then release this at the end of your program.
Secondly, AddScriptSection doesn't load the file for you. You need to load the file and get all of it's data and place it in a char array.
So, you should have somehting similar to this:

void RunScript()
{
asIScriptEngine * engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
const char * script = LoadScript("c:\\scriptfil.as"); //Get all the information from the file
engine->AddScriptSection(0, "section", script, strlen(script));
engine->Build(0, NULL);
ret = ExecuteScript();

asIScriptContext * ctx;
engine->CreateContext(&ctx);

//Prepare context

ctx->Execute();

ctx->Release();
engine->Release();
}




You will need to do error checking and I've probably missed a whole lot of stuff out, but you should get a feel for it.

The best examples (and the way I'm learning about angel script) are found in the test framework, you should download it and go through the code.

Hope this is enough to get you started.

EDIT: Changed some of the source code (forgot to add script section!)
0

Share this post


Link to post
Share on other sites
Thanks for your help and test framework recommendation! Still, I find it very difficult sorting through all that code. Is there a tutorial anywhere? The dox don't include any examples.
0

Share this post


Link to post
Share on other sites
I guess I won't be using angle script then.
[code]
../../../Documents and Settings/Grant Williams/Desktop/angelscript/lib/libangelscript.a(as_scriptengine.o)(.text+0x395):as_scriptengine.cpp: undefined reference to `asCModule::~asCModule()'
../../../Documents and Settings/Grant Williams/Desktop/angelscript/lib/libangelscript.a(as_scriptengine.o)(.text+0x427):as_scriptengine.cpp: undefined reference to `asCString::~asCString()'
../../../Documents and Settings/Grant Williams/Desktop/angelscript/lib/libangelscript.a(as_scriptengine.o)(.text+0x5e2):as_scriptengine.cpp: undefined reference to `asCString::~asCString()'
../../../Documents and Settings/Grant Williams/Desktop/angelscript/lib/libangelscript.a(as_scriptengine.o)(.text+0x5f9):as_scriptengine.cpp: undefined reference to `asCString::~asCString()'
etc. (removed the rest of the 300 errors because it was slowing the page loads)

[/source]
That's what happens when I use that engine create function. It's probably a static library problem. Sigh, back to python.

[Edited by - Drakkcon on September 8, 2004 7:29:29 PM]
0

Share this post


Link to post
Share on other sites
Please, don't be so hasty to give up on AngelScript. The linker errors you are getting is because the Dev-C++ project file you're using isn't up to date. You'll need to include the files as_string.cpp, as_string_util.cpp, and as_module.cpp for compilation. If you do add the files, could you send me the new project file so that I can update the site?

I'm sorry that I don't have a complete tutorial that tells how to get things working. The overview article, and the test_framework.cpp are the closest thing to a tutorial that I have at the moment. Each test case in the test_framework are working examples on using the library.

If you just have a little patience I will do my best to help you getting everything up and running.

Regards,
Andreas
0

Share this post


Link to post
Share on other sites
I realize that he is already past this problem, but how about making a simple function (or class) to automatically load in a script file into an array. Beginners usually don't like to sit there and code this by hand, so I figure it will be helpful. I took 5 minutes and came up with a simple one here. You can do whatever you want with it.

http://www.xl3d.com/angelscript/asLoadFile.h

All they would have to do is include that file above, and the above example would turn into :


asLoadFile file("test.cpp");
engine->AddScriptSection("module", "section", file, file.Size(), 0); /* Note you can test file to see if its NULL. If so, then the file wasn't loaded or empty. */
0

Share this post


Link to post
Share on other sites
There is a file loader code in the testframework testexecutestring.cpp or something , and if simply need to get the feeling of this library or see how it behaves under different conditions, its simply to paste that code in your project or modify it there.

Sorry to sound a little rude, but a you probably need to get a few tutorials or books on c++ programming first, how you will use c++ and bind c++ code on scripts when you dont know what a pointer is ?
0

Share this post


Link to post
Share on other sites
Completely understood, but for people just starting off who want to play with scripts, it would be nice to not have to go through and look for it. I wasn't aware this was already in there. Its a pretty simple task like I said, but it should just be made more visible for beginners.
0

Share this post


Link to post
Share on other sites
Thanks for the recommendation. I'll update the overview article with a quick implementation for loading a script file.
0

Share this post


Link to post
Share on other sites
Thank you very much for all of your help people. It's also very nice to see how involved WitchLord is with his scripting engine. I'll work on getting the correct version of the files linked into a new project file, and send it to witchlord (it may not be today, tons of homework). Thanks again!

Quote:

Sorry to sound a little rude, but a you probably need to get a few tutorials or books on c++ programming first, how you will use c++ and bind c++ code on scripts when you dont know what a pointer is ?

No, you're right. However I DO know C++, it was just a stupid error on my part (declaring a pointer with out giving it something to point to). Sorry, I'm being defensive, it was a pretty dumb mistake.


[Edited by - Drakkcon on September 8, 2004 7:56:36 PM]
0

Share this post


Link to post
Share on other sites
YES! I got a working static library! I will be sending the project file and source, and the static library. Thanks for the help everyone.
0

Share this post


Link to post
Share on other sites
It's great to hear that you didn't give up on the library.

AngelScript is still very new. It has only been available to the public for about 15 months, and new code is added to it every month. You'll most likely come upon a bug or two during your use of the library, but I ask you to have patience. I'll do my best to fix them as quickly as possible.
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