waheyluggage

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

122 Neutral

About waheyluggage

  • Rank
    Newbie
  1. calling functions with arrays arguments

    Hi DesertCube I'm not worried about building the strings up, I would just use sprintf for it. My method for passing parameters to AngelScript is what I was on about. I use something similar to printf as in you give it a string to declare what type of variables are coming on the va_start parameters. I just wanted to know if what I'm doing is 'correct'. ie. I'm not misunderstanding about the way it works. Scott
  2. calling functions with arrays arguments

    While we're talking about passing arguments to functions I've come up with... BOOL Script_SetArguments( char *args, ... ) { asIScriptContext* ctx; va_list marker; U32 count; U32 dwordCount; U32 stackPos = 0; va_start( marker, args ); for (variableCount = 0 ; variableCount < strlen(args) ; variableCount++) { U32 i; FP f; VOID *p; double d; asDWORD *data; switch (args[variableCount]) { case 'i': i = va_arg( marker, U32 ); dwordCount = sizeof( i ) / 4; data = (asDWORD*) &i; break; case 'f': f = va_arg( marker, FP ); dwordCount = sizeof( f ) / 4; data = (asDWORD*) &f; break; case 'd': d = va_arg( marker, double ); dwordCount = sizeof( d ) / 4; data = (asDWORD*) &d; break; case 'p': p = va_arg( marker, VOID * ); dwordCount = sizeof( p ) / 4; data = (asDWORD*) &p; break; default: // should handle unknown argument type here break; } ctx->SetArguments( stackPos, data, dwordCount ); stackPos+=dwordCount; } va_end( marker ); } You call it with something like Script_SetArguments( "ifp", myU32, myFloat, myPointer ); It's (supposed) to do something similar to printf, in that the string supplied just identifies what variables to set. p is just a generic pointer. Does this look like it will work? I was a bit unclear on the dwordCount and stackPos situations. So far I've had no problems with it but I'm a little scared I'm not cacking the stack up in some way. Thanks -- edit: that took ages to tab with space and the forum has just got rid of it all. ack! -- -- edit: thanks desertcube. Fixed the formatting! -- Scott [Edited by - waheyluggage on November 25, 2004 2:21:50 PM]
  3. ExecuteNext

    Hi I switched to the way you recommended. It let me put a timer in so I can now have it execute a line and then wait for a script defined amount of time. Works great. Thanks Scott
  4. ExecuteNext

    Hi Again! I'm implementing a system with the scripts so I can have a script like... void Go( ) { while (true) { Game_PlayAnim( 3 ); Game_PlaySection( 1 ); Game_PlayAnim( 2 ); } } I use ExecuteStep(asEXEC_STEP_INTO) but it doesn't seem to execute one step of the script, instead it does all of it. Any ideas? My plan is to call my Script_Update function to update a single line of a script. I'll have a script function like BeginSection() and that'll force the script to run until it reaches an EndSection() call. Say I have 3 or 4 scripts doing this - will I need to call Prepare before reusing the context? thanks Scott
  5. possible bug in parameter reading?

    Hello My full name is Scott Newby, glad I could help. Good work on the speedy fix - brilliant job. You can also add us to the list of people using AngelScript. Our website is www.bigfizz.com. We develop games for selling through the web and also games for the pub\bar industry in the UK. The machines are pc's in standalone cabinets, customer walks up, puts 50p in and chooses a game. Most of them give you a chance of winning up to £20. We'll be implementing angelscript into our new projects. Good work! scott
  6. possible bug in parameter reading?

    Hi! Back again. Things are going smoothly but I spotted an odity with the paramter parsing. My script line looks like... CreateButton( s, "language\\startgame\\", 320.0f, 200.0f, "Title_StartClicked" ); And I get an error saying it expects a , or ) after column 59 (or something). It was the end of 200.0f and there definately is a comma after it. Removing the trailing \\'s from the second parameter fixed it. I'm using the asBSTR class for strings. This is how it looked for the error to go away and everything to work again... CreateButton( s, "language\\startgame", 320.0f, 200.0f, "Title_StartClicked" ); Just thought I'd let you know. Thanks Scott
  7. a few questions...

    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
  8. a few questions...

    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).