[Tutor] My first script within a game program

Glen Wheeler wheelege@tsn.cc
Sat, 13 Oct 2001 23:04:16 +1000

> Hi Glen.
> Sorry for the text; I am learning.

  :)  Also, next time you reply try using 'Reply All' - then it will be
posted to the list and me, *insert witty quote about more people being
better than one here*.

> To be more specific about my dilemma.....
> 1. Is a function like EndSituation() complete, or do I need to place
> anything after calling it, that is, to make sure that it works. If it can
> stand by itself, I think I know how to use it.

  I'm not sure, it would really depend on what EndSituation exactly does.
Perhaps a few test runs could help you figure it out?  Things like the
position of your plane, the landscape, things regarding the default values
for the situation would need to be preserved somewhere - but that should all
be within the function.  I'd try it out.

> 2. the lack of docs referred to those that come with the game.

  Ah.  Probably a silly question but have you tried 'print
EndSituation.__doc__'?  That could help :)  If all the functions have
docstrings (.__doc__ attributes) then you can cook up a little loop that
will print out all the documentation for you.  The way to do this is using
the built-in dir function which when called returns a list of all the
current object in the namespace.  If that's just a whole bunch of gibberish,
then we can help you out :)

> 3. It seems that once the function LoadMetar() is called, it stays in the
> program. My dilemma is that the script in which this fuction resides is
> once within the program. So, it seems, that when a  brand new situation is
> loaded from the program, the same script is loaded, but this time it has
> check for some flag that resets the LoadMetar().

  I think I'm starting to understand what you mean.  The problem is that the
script cannot really call itself from within itself?  I don't think that
would be the behaviour of EndSituation - more likely the function halts the
current situation and restarts with a new one (perhaps a clone of the old)
but it wouldn't call the script from the beginning again.
  Is there a way to ask for user input once within the program?  If you can,
then a simple command from the user could invoke EndSituation and the
results could be observed directly.  If not, try altering your script to
something like...

def Main(dt):
  global metarFlag
  if (metarFlag == 0):
    NoticeToUser(" loading InfoMetar Weather v1.0", 10.0)
    metarFlag = 1
    NoticeToUser(" Ending the situation, look out!", 10.0) ## what does this
number do?
    EndSituation() ## does EndSituation take any arguments?

> The good thing about trying to explain this is that it's helping me figure
> out the problem more clearly.

  :)  Good luck!