Scripting Standards and Expectations

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
torleif
Posts: 188
Joined: Mon Jun 30, 2008 4:53 am

Scripting Standards and Expectations

Post by torleif »

I'm designing an XML-Lua-Irrlicht front end, it's turning out to be a rewarding project. Its development name is XGL, and if people like it I'll likely make it open source.

My (distant) goal is to make a RAD language that novice html writers are comfortable with, enabling them to create small games and perhaps applications. At the moment it can create gui elements, frame independent animation and has an easy to understand tiling system. I have a few working demos written in it, including a tile editor and a 2d platform game.


As users, How would you expect an objects scope to behave in the <code> block examples:

Example 1

All objects with IDs are laid out in their native tree structure in Lua* (Flash AS 1.0 style):

Code: Select all

<!-- index.xml -->
<sprite art="character.png" id="sprite1" />
<code>
_root:drawFrame()
_root:sprite1:setPosition(20,20)
_root:frame2:drawFrame()
_root:frame2:sprite2:setPosition(50,20)
</code>
<frame id="frame2">
 <sprite art="character2.png" id="sprite2" />
</frame>

Example 2

Only local objects are in scope, and you have to search for other objects you want:

Code: Select all

<!-- index.xml -->
<sprite id="hello" art="hello.jpg" position="20,30" />
<code>
-- will work
hello:setvisible(false)
-- I made this function up, to demonstrate to get an object in scope
-- At the moment, I use a global function called getSpriteById() or getFrameByID()
test = getFrame("test")
blankSprite = test:getSprite("test")
</code>
<frame id="test">
<sprite id="blank"/>
</frame>
Do you prefer example1 or example2? Or another way of accessing objects (javaScript style, etc)

Bonus question, how would you expect the following code to function:

Code: Select all

<code>
print("hello ")
</code>

<frame id="test">
 <code>
  print("world!")
 </code>
</frame>
Would you expect the code in the frame "test" to execute upon initiation or would you expect the code in test to print "world!" when the user loads** the frame test?

* Don't worry if I get a stupid user who calls his sprite a function name, I'll write a filter, or perhaps put an underscore before all ids

**At the moment I use a function called onLoadFrame() to do this
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Interesting, have you looked at MXML?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Post by aanderse »

this looks awesome. i had the same idea... i got it from adobe's mxml (as BlindSide mentioned).

i suggest putting code into <![CDATA[ ]]> tags, though (as mxml does) like this:

<!-- while valid xml isn't required, it's nice to have -->
<code>
<![CDATA[
print("hello")
]]>
</code>

mxml also offers the option to not just directly embed code, but include a source file:
<code source="test.lua"/>

also, i would suggest all code to be event based instead of just putting it inside an entity with no defined trigger. the way mxml does this is as follows:
<mx:Script>
<![CDATA[
function myTestFunction() : void {
Alert.show(" Clicked" );
}
]]>
</mx:Script>
<button id="test" onClick="myTestFunction();" />

or you can even go so far as embedding actionscript right into the onClick:
<button id="test" onClick="{Alert.show( 'Clicked' ); } />
the { and } within the onClick string tell mxml to actually treat the code within the { and } as actionscript.


anyways, i was actually thinking about making something like this (but not for irrlicht) in the past couple months! it would be great if you did open source your code, would give me a huge heads up.

keep up the good work, this project will be awesome :D
torleif
Posts: 188
Joined: Mon Jun 30, 2008 4:53 am

Post by torleif »

aanderse: I wanted to use CDATA tags as well. CDATA basically tells the XML interpreter to ignore the text inside it, so you can use >, < and & symbols. The current hack I simply use <, > and & to get around this. I'll likely use both in the future

I really like your idea of having triggers in the tags. I never thought of that, just like HTML. Also, if you're keen to look at the code I'll create sourceforge project (or just upload it somewhere)

Flex & MXML tried to incorporate OO into XML, it makes it look ugly. My own standard will try to be as simple as possible (I wont bother with DTDs etc, not at this stage)

As a result the code will be more user friendly, ie, a <button/> tag will make a button. If I keep it as simple as possible, I'll get more stuff done.

I'm using the _root.frame.sprite structure now. It's making coding a lot easier in the project
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Post by aanderse »

torleif wrote:Also, if you're keen to look at the code I'll create sourceforge project (or just upload it somewhere)
Yes, please do - I'm quite keen to take a look at how things are going.

At work I've been doing a bit of mxml development so I've thought about what I like and dislike, and then how they might apply to a language like you're creating.

Looking forward to it!
torleif
Posts: 188
Joined: Mon Jun 30, 2008 4:53 am

Post by torleif »

The sourceforge project is pending. It will give me time to iron out some bugs, bringing it to version .4. Its name is now XGAL (XML Game and Application Language)), because XGL was taken

I want to hear what you want in the project so I can apply it, aanderse. It would be great to get some outside opinion, because you might know, programmers get their head buried in the sand

If you want to compile it yourself you need MSVC 8.0 or greater, I haven't had time to port it to gcc yet. The'll be exe in there if you don't want to compile it yourself. I've written (a sloppy) API that you can use to get started.

I'll reply here when the sourceforge project is working with the code and examples
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Heh, you could check out my XMLScript project at Sourceforge too ^^
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Post by aanderse »

I'll take a look tomorrow hopefully, see if I can get it compiling on gcc (I use gnu/linux only).
Post Reply