Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2009, 07:56 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
player.loadvars

Lets say, I wrote in my "notepad":

This is a test.
To show how it fails.

and let this script part work:
PHP Code:
function Notes_list.onSelect(id,text,indx){
  
player.notes.loadvars("Notes/"@player.account@".txt");
  
Notes_title.text player.notes.list[id];
  
this.txt player.notes.(@Notes_title.text);

  
Notes_note.text this.txt;


the text in the GUI looks:
"This is a test.\r\nTo show how it fails.",

someone can tell me how to fix this?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #2  
Old 04-14-2009, 08:14 PM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
Try using MLText.
Reply With Quote
  #3  
Old 04-14-2009, 08:16 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Loadvars is trying to do exactly what it states -- loading variables.
Quote:
Script help for 'loadvars':
TGraalVar.loadvars(str) - loads the variables from a file where each line has the format varname=value
for example, in the textfile you may have:
test=foo
test2=bar

then,

PHP Code:
temp.notes.loadvars("Notes/"@player.account@".txt");
Notes_note.text temp.notes.test
this would display "foo" in the GUI.


for what you're trying to do you might want to check out loadlines().
It will return the lines of the text file as an array, so in your case, it would return the array {"This is a test.", "To show how it fails."}
Reply With Quote
  #4  
Old 04-15-2009, 03:10 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
isnt there a way, to get the same text, as I wrote down? without any "" or such?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #5  
Old 04-15-2009, 06:20 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Schetti View Post
isnt there a way, to get the same text, as I wrote down? without any "" or such?
I haven't used loadLines() much, but I'm assuming you could just loop through the array of lines and add them to the GUI control one at a time...

Something like this:
PHP Code:
temp.paragraph.loadlines("somefolder/textfile.txt");
for( 
temp.lineparagraph ) {
  
MyGuiControl.text MyGuiControl.text "\n" line;

Anyways, I'm heading to class, so I'm not sure if this makes sense or not
Reply With Quote
  #6  
Old 04-15-2009, 06:38 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
I dont think this works, and also, because I hardly guess i didnt use correct.
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #7  
Old 04-15-2009, 08:36 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Schetti View Post
I dont think this works, and also, because I hardly guess i didnt use correct.
It should work. You would need to use savelines() to save the file, though.

PHP Code:
function mySaveFunction() {
  
temp.notes MyMLTextGui.text;
  
temp.notes.savelines("myfolder/myfile.txt"1);

__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #8  
Old 04-15-2009, 11:37 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by fragman85 View Post
Try using MLText.
Using a GuiMLTextCtrl should work in this case. Did you try that yet?
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #9  
Old 04-16-2009, 12:27 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Would be interesting to see the content of the notes files, and also what kind of GUI control Notes_Note is.
Reply With Quote
  #10  
Old 04-16-2009, 01:10 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
HMM... better posting full script

Sry, I couldnt folow the part with GuiMLTextCtrl, how newb I am. Also tell me if you think thats above my ability level, but I dont think so.
I know there will be lot of nobish stuff, and ignore the boxes, I dont think I will/can use them.
PHP Code:
//#CLIENTSIDE
function onCreated() { 
 }
function 
onPlayerChats()
{  
 if (
player.chat == "/notes")
  {
    
onOpenNotes();
  }
}

function 
onOpenNotes(){
  new 
GuiWindowCtrl("notes_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "508,330";
    
canclose=canminimize=canmaximize=canresize=false;
    
canmove=destroyonhide=true;
    
text = @ player.account @"'s Notes";
    
position = { 665340};

    
//Writing board
    
new GuiScrollCtrl("Notes_note_Scroll") {
      
profile GuiBlueScrollProfile;
      
hscrollbar "alwaysOff";
      
vscrollbar "dynamic";
      
extent = { 329252};
      
position = { 048};

     new 
GuiMLTextEditCtrl("Notes_note") {
        
profile GuiBlueMLTextProfile;
        
horizsizing "width";
        
text "What you want to write down?";
        
position = { 00};
        
extent = { 30016};
      }
    }
    
    
//Title
    
new GuiScrollCtrl("Notes_title_Scroll") {
      
profile GuiBlueScrollProfile;
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOff";
      
position = { 83305};
      
extent = { 16118};
      
   new 
GuiMLTextEditCtrl("Notes_title") {
      
profile GuiBlueMLTextProfile;
      
horizsizing "width";
      
text "Title";
      
position = { 50};
      
extent = { 30016};
     }
   }
   
    
//Boxes
    
new GuiCheckBoxCtrl("Notes_boxTodo") {
      
profile GuiBlueCheckBoxProfile;
      
checked true;
      
text "To do";
      
extent = { 10020};
      
position = { 00};
    }
    new 
GuiCheckBoxCtrl("Notes_boxImp") {
      
profile GuiBlueCheckBoxProfile;
      
text "Importand";
      
extent = { 10020};
      
position = { 015};
    }
    new 
GuiCheckBoxCtrl("Notes_boxDone") {
      
profile GuiBlueCheckBoxProfile;
      
text "Done";
      
extent = { 10020};
      
position = { 030};
    }
    
    
//Buttons
    
new GuiButtonCtrl("Notes_bsave") {
      
profile GuiBlueButtonProfile;
      
alpha 0.879999995;
      
text "Apply";
      
position = { 0300};
      
extent = { 8030};
    }
    new 
GuiButtonCtrl("Notes_bclose") {
      
profile GuiBlueButtonProfile;
      
alpha 0.879999995;
      
text "Close";
      
position = { 428300};
      
extent = { 8030};
    }
    new 
GuiButtonCtrl("Notes_bdelete") {
      
profile GuiBlueButtonProfile;
      
alpha 1;
      
text "Delete";
      
position = { 248300};
      
extent = { 8030};

    }
    
    
//List
   
new GuiScrollCtrl("Notes_listscroll") {
      
profile GuiBlueScrollProfile;
      
position = { 3300};
      
extent = { 180300};
      
hScrollBar "dynamic";
      
vScrollBar "dynamic";
      
      new 
GuiTextListCtrl("Notes_list") {
        
profile GuiBlueTextListProfile;
        
0;
        
width 140;
        
fitparentwidth true;

        
clearrows();
        
player.notes.loadvars("Notes/"@player.account@".txt");
        for(
i=0;i<player.notes.list.size();i++)
        {
          
addrow(i,player.notes.list[i]);
        }
      }
    }
  
 }

}
  
  
function 
Notes_bclose.onAction() {
notes_Window1.destroy();
}

function 
Notes_bsave.onAction(){
  if (
Notes_title.text != "")
  {
    
player.notes.loadvars("Notes/"@player.account@".txt");
    if (
Notes_title.text in player.notes.list)
    {
      
player.notes.(@Notes_title.text).add(Notes_note.text);
    }
    else
    {
      
player.notes.list.add(Notes_title.text);
      
player.notes.(@Notes_title.text).add(Notes_note.text);
    }
    
player.notes.savevars("Notes/"@player.account@".txt"false);

    
with("Notes_list"){
      
clearrows();
      
player.notes.loadvars("Notes/"@player.account@".txt");
      for(
i=0;i<player.notes.list.size();i++)
      {
        
addrow(i,player.notes.list[i]);
      }
    }
    
Notes_title.text "";
    
Notes_note.text "";

  }
}

function 
Notes_bdelete.onAction(){
  if (
Notes_title.text != "")
  {
    
player.notes.list.remove(Notes_title.text);
    
player.notes.(@Notes_title.text) = "";
    
player.notes.savevars("Notes/"@player.account@".txt"false);
    
with("Notes_list"){
      
clearrows();
      
player.notes.loadvars("Notes/"@player.account@".txt");
      for(
i=0;i<player.notes.list.size();i++)
      {
        
addrow(i,player.notes.list[i]);
      }
    }
    
Notes_title.text "";
    
Notes_note.text "";
  }
}

function 
Notes_list.onSelect(id,text,indx){ 
  
player.notes.loadvars("Notes/"@player.account@".txt"); 
  
Notes_title.text player.notes.list[id]; 
  
this.txt player.notes.(@Notes_title.text); 

  
Notes_note.text this.txt;

Attached Thumbnails
Click image for larger version

Name:	gui.png
Views:	196
Size:	11.4 KB
ID:	48142  
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #11  
Old 04-16-2009, 09:20 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Schetti View Post
<snip>
Why are you still using loadvars()? I'm also not sure why you are using player.notes, anyways. Why not use a temporary variable?
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:51 PM.


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