Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-29-2011, 04:35 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Loading the class folder

I've been trying all sorts of ways trying to load and list the classes folder, but I just can't get it. It won't even load the contents of the folder.

I've made a constant variabe CLASS_FOLDER, with the class folder specified as classes/*.txt, but it won't load them.
I know there is nothing wrong with the rest of my script, as everything else is functioning apart from this line.

PHP Code:
temp.cls.loadfolder(CLASS_FOLDER,false); 
Can anyone tell me why? Is there something different about the class folder than all the other folders that I should be aware of?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #2  
Old 05-29-2011, 04:40 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Does the NPC-Server have read rights to that folder?
__________________
Skyld
Reply With Quote
  #3  
Old 05-29-2011, 04:40 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
It's scripts/* not classes.

DB-NPCS: npcs/*
Weapons: weapons/*

Folder Rights Example (NPC-Server will need at least r rights):

rw weapons/*.txt
rw scripts/*.txt
rw npcs/*.txt
-rw npcs/npclocalnpc*.txt (Hides putnpc2 npcs)

These are strictly NC Folders:

CLASSES/*
WEAPONS/*
NPCS/*
__________________
Quote:
Reply With Quote
  #4  
Old 05-29-2011, 04:44 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Thanks fowlplay.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #5  
Old 05-29-2011, 04:47 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Now that I've asked that question, I may as well ask this one..
How would you go about loading the contents of one of those script files?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #6  
Old 05-29-2011, 05:03 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by iBeatz View Post
Now that I've asked that question, I may as well ask this one..
How would you go about loading the contents of one of those script files?
This can apply to nearly every kind of file on your server not just the text files in the scripts folder.

As Array of Lines:

PHP Code:
temp.folder "scripts/";
temp.filename "your_class.txt";
temp.lines.loadlines(temp.folder temp.filename);
for (
temp.linetemp.lines) {
  
// processes line by line

As String:

PHP Code:
temp.folder "scripts/";
temp.filename "your_class.txt";
temp.data.loadstring(temp.folder temp.filename);
for (
temp.0temp.temp.data.length(); temp.i++) {
  
// process each character
  
temp.temp.data[temp.i];

__________________
Quote:
Reply With Quote
  #7  
Old 05-29-2011, 05:49 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Everytime I use loadlines() or loadstring(), it just returns 0.

I'm triggering the server from the clientside, with the name of the script file being carried over from the serverside as the second parameter.
The first parameter defines if it's a weapon or a script.

PHP Code:
 if(params[0] == "LoadScript"){
  if(
params[1] == "weapon"){
   
temp.filename params[2];
   
temp.scr.loadlines("weapons/"@temp.filename@".txt");
   
findPlayer("Graal749838").chat temp.scr;
  }
 } 
This always returns 0 to my chat. I've even tried it with a full string, but still noting works.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #8  
Old 05-29-2011, 05:59 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
What filename are you using? Keep in mind you need to escape it if it has special characters, and weapons are named weaponWeaponName.txt.
__________________
Reply With Quote
  #9  
Old 05-29-2011, 11:40 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Ah. I forgot the weapon prefix for weapon scripts. I was using a substring. Thanks cbk.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #10  
Old 05-30-2011, 12:12 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Okay, now I really am at my wit's end with this...
Okay, I have a GuiTextList with all the weapon names listed without the weapon prefix, without the .txt and the special characters escaped.
So, I press a GuiButton to send the selected text to the serverside using triggerserver(), which is fine.
Say, for example, I selected "Personal/iBeatz/Test" in the GuiTextList:

PHP Code:
triggerserver("gui",name,"LoadScript","weapon",Category_List.getSelectedText()); 
Then it is called on the serverside like so:

PHP Code:
function onActionServerSide(){
 if(
params[0] == "LoadScript"){
  if(
params[1] == "weapon"){
   
temp.sname params[2];
   
temp.scr.loadlines("weapons/weapon"@temp.sname@".txt");
   
findPlayer("Graal749838").chat "weapons/weapon"@temp.sname@".txt";
  }
 }

I'm frustrated because temp.scr always ends up as 0, but my chat is always the string I want.
I have also tried this with a script file as well, and still nothing works.
This is so annoying...
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #11  
Old 05-30-2011, 03:45 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
It's because the forward slashes (and other special/unsafe characters) get encoded.

Personal/iBeatz/Test is actually stored as weaponPersonal%047iBeatz%047Test.txt in the weapons folder.

Testbed might not have the folder rights necessary to read the raw script files either.
__________________
Quote:
Reply With Quote
  #12  
Old 05-30-2011, 03:50 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Wow. Why does everything have to be so complicated...?
Thanks once again.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
Reply


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 05:19 PM.


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