Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 11-21-2008, 10:06 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Nice work man
Reply With Quote
  #3  
Old 11-21-2008, 10:14 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Great job
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #4  
Old 11-21-2008, 10:18 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Very nice !
Reply With Quote
  #5  
Old 11-21-2008, 11:06 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Very nice!

Baddies aren't needed, in my opinion, but your other planned things look nice.
__________________
Reply With Quote
Reply


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 08:56 AM.


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