Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   getlines() not returning (https://forums.graalonline.com/forums/showthread.php?t=134270177)

Kirko 02-14-2016 12:57 PM

getlines() not returning
 
The functions getlines() and getlinecount() are returning nothing but when I do something else like gettext() it returns correctly.
This is all in a for loop when displaying messages
PHP Code:

echo(("Message_"@temp.i).getlines());
echo((
"Message_"@temp.i).getlinecount());
echo((
"Message_"@temp.i).gettext());//only one to work 

Another thing I tried to do
PHP Code:

this.trueSize thiso.catchevent(this"onReflow""onTest"); 

PHP Code:

function onTest(temp.objnewwidthnewheight){
  echo(
temp.obj.getlinecount()); //does echo correctly
  
return temp.obj.getlinecount();


but then back in the for loop this just doesnt echo anything
PHP Code:

echo((@"Message_"@temp.i).trueSize); 

What I'm trying to do is get the amount of lines there are in the text control so I can adjust the y position for the next message.

ffcmike 02-14-2016 02:04 PM

Might it be that the string isn't coercing in to an object?

You could try something on the lines of:

PHP Code:

temp.obj makevar("Message_" temp.i);
echo(
temp.obj.getLines()); 


Kirko 02-14-2016 02:25 PM

Still doesn't seem to work.

ffcmike 02-21-2016 04:26 PM

It seems this is just the behaviour when echo'ing an array rather than a string.

For example it outputs the line count if I do:

PHP Code:

echo(("Message_"@temp.i).getlines().size());
//13
//13
//13 

You can coerce the array to a string by doing:

PHP Code:

echo(@ ("Message_"@temp.i).getlines());
//ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH
//ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH
//ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH,ASDFGH 


Kirko 02-21-2016 07:22 PM

I tried doing what you did and got zeros like before. I seem to have bad luck with this, or I just screwed up somewhere in the script. :(

This is the part where it seems to be messing up, if anyone can see anything wrong.
PHP Code:

    for(temp.0temp.temp.messageSizetemp.i++){

        new 
GuiMLTextCtrl("Message_" temp.i){
          
useownprofile      true;
          
profile.modal      false;
          
profile.fonttype   "Arial";
          
profile.fontsize   20;
          
profile.fontcolor  temp.textFormat "black" "white";

          
profile.textshadow  true;
          
profile.shadowcolor "black";

          
allowedtags = (temp.fromstaff ? {"img""b""font""center"} : {"b""img"});
             
          
alpha temp.textFormat 0.3 1.0;
          
visible true;
          
resize(50temp.y33020);

          
//addtext(temp.message, true);
          
text temp.message;
          
//thiso.catchevent(this, "onReflow", "onTest");
        
}


        
temp.obj makevar("Message_" temp.i);
        
temp.lines = (@("Message_" temp.i).getLines());
        echo(
temp.lines); //echos nothing
            
            
        
temp.chat_height temp.lines <= 25 temp.lines 25;
        
temp.+= temp.chat_height;

      } 

Only other way I can think of fixing is getting the width of text and then getting the amount of lines by dividing the text width by Gui width.

ffcmike 02-21-2016 07:46 PM

The problem seems to be something else, lines are being echo'd fine for me when I do:

PHP Code:

temp.messageSize 3;
for(
temp.0temp.temp.messageSizetemp.i++){
  
  new 
GuiMLTextCtrl("Message_" temp.i){
    
useownprofile      true;
    
profile.modal      false;
    
profile.fonttype   "Arial";
    
profile.fontsize   20;
    
profile.fontcolor  temp.textFormat "black" "white";
    
    
profile.textshadow  true;
    
profile.shadowcolor "black";
    
    
allowedtags = (temp.fromstaff ? {"img""b""font""center"} : {"b""img"});
    
    
alpha temp.textFormat 0.3 1.0;
    
visible true;
    
resize(50temp.y10020);
    
    
text "asdf asdf asdf asdf asdf asdf asdf asdf ";
  }
  
  
  echo(@(
"Message_" temp.i).getlines());
  
  
  
temp.chat_height temp.lines <= 25 temp.lines 25;
  
temp.+= temp.chat_height;
  


Renders 2 "asdf" per line, echo's:

Quote:

"asdf asdf","asdf asdf","asdf asdf","asdf asdf"
"asdf asdf","asdf asdf","asdf asdf","asdf asdf"
"asdf asdf","asdf asdf","asdf asdf","asdf asdf"

xAndrewx 02-24-2016 12:41 PM

Looks like code from the iOS PM system...? Correct me if I'm wrong


Replace
HTML Code:

        temp.obj = makevar("Message_" @ temp.i);
        temp.lines = (@("Message_" @ temp.i).getLines());
        echo(temp.lines); //echos nothing

with
HTML Code:

        temp.lines = (@("Message_" @ temp.i)).getLines();
        echo(temp.lines);


MysticalDragon 02-24-2016 04:02 PM

It is, he works on Delteria IOS and is working on the PM Threading System. I added a temporary fix, because I could not get the lines to work either, So i did.

PHP Code:

  temp.lines wraptext2(200,12/24," -","@Arial@@" temp.rawmessage);        
  
temp.linecount temp.lines.size(); 

But I will try your method as it would be more accurate.


All times are GMT +2. The time now is 06:49 AM.

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