I am getting the hang of gs2, but there are a couple of situations that I have not been able to find a way around.
(all examples //#CLIENTSIDEd)
Old gscript : you can check for created and playerenters in one line
NPC Code:
if (created || playerenters)
{
loadmap mymap; // or whatever;
}
but how do you check for multiple events with gs2 other than this cumbersome repetition?
NPC Code:
function onCreated()
{
loadmap mymap;
}
function onPlayerenters()
{
loadmap mymap;
}
Also, how do you have two separate timeout loops in one npc that operate intependently depending on a boolean flag (variable that is 1 or 0)
Old gscript example
NPC Code:
if (created)
{
this.on=0;
timeout=.05;
}
if (timeout && this.on==0)
{
if (event happens like a keydown to switch flag to the other loop)
{
this.on=1;
}
timeout=.05;
}
if (timeout && this.on==1)
{
if (event like a different keydown to switch to the initial loop)
{
this.on=0;
}
timeout=.05;
}
This script woked fine, and then it was unchanged when my server was switched to gscript2, then it did not function in switching to the second timeout loop.
I tried switching it to gscript2, even changing the flag to a client.string and breaking the timeout loops into two separate npcs and it still did not work.
Why not???
example of gs2
NPC Code:
function onCreated()
{
this.on=0;
timeout=.05;
}
function onTimeout()
{
if (this.on==0)
{
if (keydown event triggered)
{
this.on=1;
}
}
if (this.on==1)
{
if (keydown event triggered)
{
this.on=0;
}
}
timeout=.05;
}
I also tried it with 2 separate timeout loops
NPC Code:
function onCreated()
{
this.on=0;
timeout=.05;
}
function onTimeout()
{
if (this.on==0)
{
if (keydown event triggered)
{
this.on=1;
}
}
timeout=.05;
}
function onTimeout()
{
if (this.on==1)
{
if (keydown event triggered)
{
this.on=0;
}
}
timeout=.05;
}
and neither one of those worked ... what am I doing wrong???
the first timeout is to see if an "on" key is pressed and to hide images,
The second timeout is to show the images and allow the image positions to be changed through a function if other keys are pressed, and to see if the "off" key is pressed.
Any help would be appreciated