Suggestion: GetFrameInfo() family functions

Started by Scorpiorus, Sat 19/04/2003 22:41:36

Previous topic - Next topic

Scorpiorus

I would like to suggest a number of AGS script functions: :)

GetFrameSpd(int view, int loop, int frame)
returns the speed value specified for this frame in the editor.

GetNumFrames(int view, int loop)
returns the number of frames for this loop.

GetNumLoops(int view)
returns the number of loops for this view.

IsRunNextLoopAfterThisChecked(int view, int loop)
returns the state of this option in the editor.

The reason I am asking it is I make a couple of functions which need to know that info. The first is MoveCharacterGlobal(CharId, x, y) (globalmove.txt) which moves the character at the any room. It's complete but when anti-glide mode is turned on I need to recalculate the speed of the character depending on that frame_spd value.
The second is AnimateCharacterGlobal(..) (globalanim.txt) doing the room-independent animation. I still need here GetFrameSpd() as well as GetNumFrames(), GetNumLoops() and IsRunNextLoopAfterThisChecked() functions.

btw I think it would be useful in general to get such info that was set in the editor at design time.

what do you think?

-Cheers

Pumaman

Over to you guys - would anyone else find these useful?

RickJ

I think this kind of thing could be very useful.   The only problem I can see is the future proliferation of such functions.  Perhaps an alternative would be to have one function and an item parameter something like this:

  GetFrameInfo(int item, int view, int loop, int frame)

   where item is SPEED, NUM_FRAMES, NUM_LOOPS,
   or NEXT_LOOP_CHECKED

I don't know?  One way is as good as the other I guess.  

The global move and animate functions Scorp describes sound really useful because it would allow NPC's to easily wander about the game world without regard to the player's location.  This, IMHO, would make for really interesting game play.    


Pumaman

Yeah, this is what I'm a bit concerned about too - it could lead to an onslaught of scripting functions.

What might be the best way is just to add a single function, something like  

GetGameParameter (int type, int data1, int data2, int data3, int data4);

So that it could be used for returning the values of various things that are only rarely wanted in the script.

RickJ

#4
Isn't most of this stuff just internal data that doesn't require any calculations or processing?   Is there a way to selectively expose these as global variables?  Maybe use an "import" statement of some sort in the header or global script?  

Hmm... how about having internal type defs.  Declare a variable with the type def and the internal data is exposed as if were a local variable.  I guess you could make it read only by just doing a behind the scenes copy to the local variable space before the script runs.  Err ... or something like that.

For example one would put somethin like this in a script file.

  #define NO_OF_VIEWS 10
  VIEW_DEF    myview[NO_OF_VIEWS];

Then it would be possible to acess internal data for the first 10 views as follows:

  myview[1].number_of_loops
  myview[1].loop[1].number_of_frames
  :

Well, I hope I haven't made things worse :) by getting all these ideas.  Maybe sleep on it for a couple days and see if something comes to mind.












Pumaman

The problem with exposing that sort of thing to the script is that if I change the way the views are stored in the engine, then old scripts would be referencing invalid memory locations. While yes it would be possible to copy all the data into the special script view struct before running all scripts, that would be quite time consuming.

BlackBaron

I like the GetGameParameter (int type, int data1, int data2, int data3, int data4); idea.

I'm just starting so I don't find it useful now but, who knows, you never seem to have enough information...   ;)
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

RickJ

QuoteWhile yes it would be possible to copy all the data into the special script view struct before running all scripts, that would be quite time consuming.
How dynamic is this data?  Doesn't most of it remain unchanged throughout the game?  In this case it would only need to get updated only once  or at most infrequently.  Perhaps a script request, much like the UpdateMouse() function could be used to initiate such updates?  

If you went this way with it, then you would have the option of changing the way internal data is stored, at some point in the future.  In which case a call to the update command would do nothing since the data  would always be current.


Pumaman

Well, I prefer the Get function style, because it ensures that the user doesn't try and change the data. (and in the case of a copy, wonder why changing it didn't do anything).

I think I'll go with this for now, but I do see your point though and I'll consider it for future additions.

SMF spam blocked by CleanTalk