Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - RickJ

#581
I just found this and thought it could be useful tool in keeping track of game projects, especially for group projects.  The screen cast was very impressive -- it looks easy to use and would be a good way to organize a game projects work flow.  Anyway you can check it out here:

http://www.pivotaltracker.com/help/gettingstarted
#582
No! it's not in a struct.  The error ocured with the declaration

String String::Token(..)

If it's working for you then and not for me then I must have mistyped something somewhere or had gotten something out of order?
#583
You may want to have a look at this thread and converse with it's author.  He making an Xbox runtime that can execute AGS games.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39050.0
#584
Return
The return statement works the way you describe.  However, it is usually considered good programming practice for function to have one entry point and one exit point.  The only time I consider using conditional return statements is for trivial functions containing 2 or 3 lines of code like this:   
Code: ags

function is_number(char c) {
     if ((c>='0')&&(c<='9')) return true;
     else return false;
}


Your example doesn't show what what happens when the "if" condition is false.  If that's all the code in your function then it is returning whatever junk happens to be in memory.

Recursion
You probably don't need top be doing this.   Recursive algorithms are typically used to walk hierarchical structures etc.
#585
Quote
This also works even if the function isn't global. You can define a localized extender with the same name as a local variable like this:
Ah!  Yes, I am using local extenders within a module script that are not to be exposed outside the module.   Thanks for the info; it's very useful.   

[edit]
Tried your second example and got the following error ... I'll just use fdifferent names.
Quote
Modoc.asc(241): Error (line 241): extender functions cannot be part of a struct
#586
It appears that extender functions share the global namespace rather than the Object's namespace.  In the example below I had expected that the name of extender function would be seen by the compiler as "String.Token" rather than "Token".   Not sure if this is a bug or a feature ;) so I thought I'd mention it.   It's easy enough to avoid by just using another  name.

Code: ags

*** Global Script ***

String IndexOf;   // Does not conflict with String.IndexOf(..)

String Token;       // Name conflict with extender function String.Token(..)

// String extender function
String Token(this String*);  // Causes an error "Token is already defined"
#587
Let's assume we are documenting several classes and that each class contains both class and object methods.  Let's also assume that each method will be documented with a title or headline and some descriptive text.  Also let's ignore the other elements such as the declaration, examples, etc.

Note: in the Ags script language "class method" is equivalent to "static function" within the bounds of a struct declaration.

What I would like to know what format the headline ought to be in and specifically what is the difference between the headline of a class method and the headline of an Object method?

For example the AGS documentation just uses ClassName.MethodName() for both class and object methods.  This seems to work out ok but there are very few (if any) class methods so there isn't much chance for confusion.   I realise that it all get's sorted out in the example code but still wonder if there shouldn't be a differentiation in the headline something like this:


6.2 ClassName.MethodName()   (class)   
The MethodName method does this that and the other thing.  ...


7.3 ClassName.MethodName()   (object)
The MethodName method does this that and the other thing.  ...


Any thoughts, observations, or opinions are welcome.   Thanks.
#588
Well, you will need to keep that data in an external file. Probably the easiest way to manage it is to have a struct array where each element corresponds to a save slot number.  Before doing a game restore you will have to write this data to  a file.  After the game restore is complete you will need to read the file back in to the struct using the eEventRestoreGame event illustrated ion my previous example.
#589
MsMn is misinformed or has noty correctly understood your question.   If you define a static variable (declaration is outside the bounds of any functions)  and export it can  be used in the Global script or any Room Script in which it has been imported.  The common practices is to put the import statement in the Script header so that it is imported in to every room.

You will be accessing the same variable so it will have the same value no matter where you access it from.
#590
My module saves/restores the game play time from a data file when GamePlayTime.Start() is executed, which is recommended to be done in the game_start() event handler in the global script.

Quote
How do you display the play time when loading a save from the title screen? Variables are restored after you've loaded a game, not before, no?
Yes a game restore will overwrite the current game play time to what it was when the game was last saved. I don't know that this is necessarily incorrect. I suppose it would depend upon the game and the game designers intent.  However,   this behaviour can be easily changed by stopping the timer before restoring the game and then restarting it again after it is restored, as illustrated in the code below.  This will cause the game play time to be written to the data file before the restore operation is executed and retrieved after it is completed.

Code: ags

*** Global Script ***
function MyCustomRestorGameSlot(int slot) {
   // This function save the current game play time before restoring the game.
   GamePlayTimer.Stop();
   RestoreGameSlot(slot);

   // Use on_event() handler to restart timer
   // GamePlayTimer.Start();
}

function on_event(EventType event, int data) {
   // Restart game play timer after a game restore
   if (event==eEventRestoreGame) GamePlayTimer.Start();
}

#591
But they are reset when you quit the game, right? Otherwise, why would you use an external data file to store the play time?

No they are not reset.  The play time is kept in a separate file because the game may have been played but not saved at the end of the session.
#592
I'm not sure I understand the question. 

1) Static variables (those declared outside the bounds of a function) are persistent between game saves. 

2) If I were going to save data to a file I would probably use WriteInt(..)/readInt(..), WriteString(..)/ReadStringback(..).
#593
Thanks guys.  I had looked at the example in the help but didn't see the difference... I feel so stupid.   :=
#594
Here is a module that does what you want.   Elapsed game time is stored in a data file whose name is of your choosing.  Documentation is in the source file.

GamePlayTimer Module
[edit]
fixed broken link
#595
tzachs: I think you made a good observation to point out a mistake that people often make, however, I don't agree with your proposed solution.  The editor allows you to turn off the message box, which I find deeply annoying.   Perhaps a better solution would be to display a message when a game is first open by the editor.

monkey: "There are a ton of more useful ideas (i.e., getting the size of a dynamic array, pointers to custom types, dynamic arrays within structs, etc.)." Yes, Yes Yes, and yes yes to your suggestions.  I would also add pointers to functions to your list.  I would love to be able to construct jump tables.
#596
In the latest V3.2RC it would appear that it's not permitted to define extender functions in a module.  Doing so produces an error as shown in the example below.
Code: ags

*** Module Header ***
import function FunctionName(this *Character);

*** Module Script ***
function FunctionName(this *Character) {
}

*** Compiler Message ***
Failed to save room room0.crm; details below
BluTemplate.ash(125): Error (line 125): 'this' must be followed by a struct name


I thought we used to be able to do this but I may be mis-remembering.  Could someone verify if this is the correct operation or if it's a bug.
#597
Quote from: Pumaman on Fri 06/11/2009 18:16:46
Quote from: RickJ on Fri 06/11/2009 07:58:57
Now here is the strange part, the 11th parameter was eliminated and I expected to get the same results as before - no errors with 10 parameters.  But to my surprise the same error persisted, this time supplying this text in the error message: 'BluBox::Init^10'.
I am also using previous AGS release (AGS Editor .NET (Build 3.1.2.82) v3.1.2 SP1, February 2009).
This was a bug in AGS 3.1.x but should already be fixed in the latest 3.2 RC 2. Could you try it out and confirm that this fixes the problem for you?
Verified.  Upgraded to  latest RC and error no longer appears..  Thanks!

#598
I can make an example available if you like.
#599
Quote
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
.. or that you are attempting to use more memory than has not been allocated.   It seems like you are working with dynamic sprites and the drawing commands?  If so I would check to see if you are deleting  any dynamic sprites  you create when they are no longer needed.  I would expect that if dynamic sprtes are continually created,. eventually an error complaining about memory would be eventually encountered.
#600
Matti that looks pretty cool.  How did you do it?  What techniques and/or modules did you use? 

I have been thinking about ways of improving DermoCycle.  Specifically I would like to make it so the roadway can meander from side to side and and so that roadside objects can be easily added to the course. 

Your little demo gives some inspiration and insight as to what/how things can be done.  It makes me think about star wars, jet cycles, and ewoks.  Any ideas about how to make your background also appear to move towards the screen/player?
SMF spam blocked by CleanTalk