Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 06-16-2006, 03:51 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by MegaMasterX90875
This example uses the file test.txt in the levels folder.
Can't I use
NPC Code:
function onCreated&&Fileexists(levels/test.txt)
{
selectfilefordownload(levels/test.txt);
}

The problem is that the "new event blocks" are not simply conditional clauses, with if-condition-action stuff, but actually functions that are automatically called when an event happens. onCreated is the name of the function that the engine will call, and not the name of the flag that will be set to true while the engine is calling the script. You are declaring a function and not doing flow-control.

You will need to (and should have in GS1, see KSI-GS) nest the conditional check within the event block. A simple example is, without redundant functions, a direct translation of your code:

NPC Code:

function onCreated() {
if (fileExists("levels/test.txt"))
selectFileForDownload("levels/test.txt");
}



Quote:
Also, should I put this Clientside?
Yes. The server cannot snoop around the client's files easily.

Edit: Oh, yeah. You should surround strings with quotation marks.
Reply With Quote
 


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 04:06 AM.


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