Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-21-2008, 10:04 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Level Loader

Made this little function that loads a level into an object so everything can be accessible. I hope this will encourage people to get into level editors more, perhaps, or just make it easier for those that are. I've attached the class folder(which is named as it should be named a class).

It works like this:
PHP Code:
temp.loadlvl "new4.nw";
this.lvl = new TStaticVar();
this.lvl.join("loadlevel");
this.lvl.LoadLevel(loadlvl); 
The level must be in the direction of Graal/levels(if clientside, I haven't tested it on the serverside so I'm not entirely sure what director it uses... probably levels/), or sub directories if you do so via...
PHP Code:
temp.loadlvl "myworld/new4.nw" 
which will find the level in Graal/levels/myworld/new4.nw.

Then you can simply echo the information like so...
PHP Code:
echo(this.lvl.tiles[0]); 
to echo the tiles of layer 0, or...
PHP Code:
echo(this.lvl.npcs[0].text); 
to echo the text(script) of NPC 0, or...
PHP Code:
echo(this.lvl.npcs.size()); 
to get the count of NPCs in the level.

Here are a list of accessible variables...
PHP Code:
tiles[A]                will return the tiles of layer A

links
[A].destlevel      gives the destination level of link A
links
[A].x              gives the x position of link A
links
[A].y              gives the y position of link A
links
[A].width          gives the width of link A
links
[A].height         gives the height of link A
links
[A].destx          gives the destination x of link A
links
[A].desty          gives the destination y of link A

signs
[A].x              returns x of sign A
signs
[A].y              returns y of sign A
signs
[A].text           returns text of sign A

npcs
[A].x               returns x of npc A
npcs
[A].y               returns y of npc A
npcs
[A].text            returns text of npc/script A
npcs
[A].image           returns image of npc A

chests
[A].x             returns x of chest A
chests
[A].y             returns y of chest A
chests
[A].content       gives the content of chest A
chests
[A].sign          returns the index of the sign for chest A

A
.size()                will return the amount objects in A(layers/links/signs/npcs/chests
Planned additions:
> a savelevel function, for saving a level to NW format.
> a tiles(x,y,z) which will return the tile from coordinates x,y in layer z, from the tiles returned in my function.
> loading baddies? I don't quite know if I want to do this, but if people demand it I will add it.

Please let me know if you encounter any bugs.
Attached Files
File Type: txt loadlevel.txt (4.4 KB, 273 views)

Last edited by DustyPorViva; 11-21-2008 at 10:44 PM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:44 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.