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 02-14-2016, 12:57 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
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.
Reply With Quote
  #2  
Old 02-14-2016, 02:04 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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()); 
Reply With Quote
  #3  
Old 02-14-2016, 02:25 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Still doesn't seem to work.
Reply With Quote
  #4  
Old 02-21-2016, 04:26 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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 
Reply With Quote
  #5  
Old 02-21-2016, 07:22 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
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.
Reply With Quote
  #6  
Old 02-21-2016, 07:46 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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"
Reply With Quote
  #7  
Old 02-24-2016, 12:41 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
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); 
__________________
Reply With Quote
  #8  
Old 02-24-2016, 04:02 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
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.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]




Last edited by MysticalDragon; 02-24-2016 at 04:15 PM..
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 11:43 PM.


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