[Ohrrpgce] arguments vs locals

TeeEmCee teeemcee at gmail.com
Tue Jun 7 07:04:51 PDT 2005


Hmmm? Runscript does initialise all arguments and locals to zero:

FOR i = 1 TO scrat(index, scrargs)
 heap(scrat(index, scrheap) + (i - 1)) = 0
NEXT i

However, when arguments are passed to a script, this happens after
runscript has loaded and cleared its locals, then arugments might
overflow into variables.

Anyway, yes scrap the argument to newgame script. A demo script it is. 

But what about the newgame/quit options on the load game screen? 

On 6/7/05, Bob the Hamster <Bob at hamsterrepublic.com> wrote:
> On Sun, Jun 05, 2005 at 02:04:47AM +1200, TeeEmCee wrote:
> > Also, some script calls (as in, npc triggered, autoload map scripts,
> > etc) allow you to pass arguments to the scripts. Looking at the
> > source, I realise that I was mistaken the whole time that if you don't
> > want them, you don't have to declare arguments on the script? It seems
> > that if you do this, they will get placed in local variables. I wanted
> > to have true or false passed to the newgame script depending on
> > whether the player pressed a key at the title (above), this might
> > interfer with newgame scripts with locals, would this be a problem?
> 
> Yeah. plotscripting does not really distinguish between arguments and
> locals. This may have been a bad design decision, but that is the way
> it works. If you want to add an auto-argument to the new game script,
> that is okay, since script authors should really be initializing their
> locals.... (mmmm... not that anybody knows that)
> 
> Although, as I wrote in another post, I prefer having a separate "demo"
> plotscript to be run instead of the new-game script, rather than adding
> an true/false auto-argument to the new game script.
> 
> You know, enforcing the separation of arguments and local variables
> would not really be hard. The script-triggering code in the "runscript"
> function in moresubs.bas needs some clean-up anyway. It could make sure
> that locals will always be pre-inited to zero's. This would break the
> scripts of anyone who is already depending on the current undocumented
> "undeclared arguments overflow into locals" behaviour, but hopefully
> nobody is doing that.
> 
> ---
> Bob the Hamster
> _______________________________________________
> Ohrrpgce-motherhamster.org mailing list
> ohrrpgce at lists.motherhamster.org
> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>



More information about the Ohrrpgce mailing list