Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Level Loader (https://forums.graalonline.com/forums/showthread.php?t=82855)

DustyPorViva 11-21-2008 10:04 PM

Level Loader
 
1 Attachment(s)
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.

Codein 11-21-2008 10:06 PM

Nice work man :)

Tigairius 11-21-2008 10:14 PM

Great job :)

Soala 11-21-2008 10:18 PM

Very nice !

cbk1994 11-21-2008 11:06 PM

Very nice!

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


All times are GMT +2. The time now is 12:15 AM.

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