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.