pingus-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pingus Scripting Language


From: Jonas Bähr
Subject: Re: Pingus Scripting Language
Date: Wed, 7 Apr 2004 23:21:56 +0200
User-agent: KMail/1.6

Am Dienstag, 6. April 2004 05:25 schrieb Ingo Ruhnke:
> Hiho,
>
> have hacked together a little very simple XML based scripting
> language, not the most beatifull one, but might be enough for our
> needs. Some example scripts are below, interpreter for them is in the
> svn repo, named xml_eval. Not sure if we really need scripting, but in
> case we do it might be usefull :)

Scripting would be great for some pingus-levels (and even greater for an 
potential worms-mode later). With this it would become possible to get some 
extra pingus, getting an alternative exit, en-/disabling traps, own traps, 
manipulating the level during the action (like letting the water rise), 
etc...
It could also tell which level to load next dynamicly....

It might be useful to give the codeblocks names (and omit in opposition the 
<function>-tag) and to enclose all this in <script version="..">...</script> 
as a child of <pingus-level>. Some of the names could be reserved for a kind 
of event-system, like "_init" to be executed just befor the level is 
displayed or "_emitNewPingu" with the id as a parameter each time a new pingu 
is droped into the world, etc. The parameters could be simple accesable vie 
variables like "arg1", "arg2", "arg3", etc. just like the Parameter in a 
bash-script.
The user could call his own function-blocks with
<call name="nameOfBlock" arg1=".." arg2=".." .... return="var" />
and if there is a return it is stored in  "var". I know that this is a bit 
more complex then your currend approach but I think that a seperate namespace 
for each function-block is nessesary to write a bit more complex scripts. In 
addition it allows you to pass arguments to build-in functions with the same 
statement (ex: <call name="_kill-pingu" arg1="id" />)

If global variables are needed, I propose not to declare them outside the 
blocks (like you do in C) but to import them in the particular block (like 
php does). Therefore you need a new tag but you can be sure that <script> 
only got <block>'s as childs:
<global local-name="localVar" global-name="externalVar" />
You could also add some predefined externals like "MaxPingusToSave" etc...

In the editor you could place some signal-spots which call named 
function-blocks (with the pingu-id as argument) whenever a pingu walks over 
it...

Also useful could a timer be:
<timer time="1000" displaytime="false" loop="fase">
  <call name="nameOfBlock1" arg1=".." arg2=".." .... return="var" />
  <call name="nameOfBlock2" ... />
  ...
  do some stuff...
  ...
</timer>
which executes some stuff after the time is up. It may be usefull to display 
the countdown-timer state for the player (in this case an other attribute 
title="Time left: " or so can be used) or restart the timer automaticly 
(loop)...

An other idea is a method to get some infos about a sertain pingu. This should 
be usable in loops too. perhaps like this:
<get-pingu-info id="ID" positionx="varPositionX" action="varAction" ... />
This fills the variable varPositionX with X-coodrinate of the pingu with the 
id ID etc...

It is also nessesary that you could manipulate the level-geometry with the 
script but I've no idea how to do this best (but as I haven't thought too 
much about that). This becomes even more interesting for a worms-mode. It 
could be possible to generate whole levels with the script's "_init". You 
could have a directory with some of these random-levels like "small islands" 
or "cave" which get only a parameter for the theme and a random number (the 
player can but haven't to set these)

As I've understand you, your script-approach is only a first draft and nothing 
too concrete and you may find some of my ideas usefull :)

Jonas

PS: I often refered to an potential worms-mode. I'll post some concepts during 
the next time and maybe it will find someone to work on such a mode...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]