View Single Post
  #1  
Old 06-30-2007, 02:31 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Level Vars in the .nw file!

It would be very nice to be able to set level variables in .nw files without having to use NPCs.

Like here could be an example .nw file (omitted all but one of the BOARD lines to make it shorter):

NPC Code:
GLEVNW01
BOARD 0 0 64 0 J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4 J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4 J4J4J4J4J4J4J4J4J4J4J4J4J4J4
VAR noplayerkilling 1
VAR myentermessage Hi guys!
VAR testarray 6,1,Testing,"Hello Everyone"

NPC - 0 0
function onCreated() echo(level.testarray[3]);
//#CLIENTSIDE
function onPlayerEnters() {
say2(level.myentermessage);
player.chat = level.testarray[2] @ ": " @ level.testarray[0] + level.testarray[1];
}
NPCEND



I put the details that are important in bold.

I'm sure a lot of you could figure out what that all does.

Here is another way you could do it:
NPC Code:
GLEVNW01
BOARD 0 0 64 0 J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4 J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4J4 J4J4J4J4J4J4J4J4J4J4J4J4J4J4
VARS
noplayerkilling=1
myentermessage=Hi guys!
testarray=6,1,Testing,"Hello Everyone"
VARSEND

NPC - 0 0
function onCreated() echo(level.testarray[3]);
//#CLIENTSIDE
function onPlayerEnters() {
say2(level.myentermessage);
player.chat = level.testarray[2] @ ": " @ level.testarray[0] + level.testarray[1];
}
NPCEND



I put the details that are important in bold.

Anyways: These would both set clientside and serverside variables when the level is updated (uploaded, server restart or "update level" is done). Of course, once they are set they are still independent (changing the clientside var won't effect the serverside with the exception of already shared vars).

I guess if you want you could maybe use:
VARCLIENT
VARSERVER
VARSCLIENT
VARSCLIENTEND
VARSSERVER
VARSSERVEREND

What do you all think?

EDIT: I dunno why it put spaces in the BOARD but just ignore that as it isn't important.
__________________
Do it with a DON!
Reply With Quote