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 01-17-2014, 03:56 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by i8bit View Post
Not saying you guys are wrong, but for me, Starfire's script is the only one I can really understand. Till new to scripting..

I'm still confused on what Return is doing in script..?
his one would just work at its best if you know/send the length of your numbers, while the one BlueMelon and me posted could be used as a function used by several scripts (like putting it into a class with custom functions)

Quote:
Originally Posted by BlueMelon View Post
From my tests, the method I posted is faster then using substring. But I'm going to assume for OP's case it doesn't really mater which is more efficient.
Interesting to know
__________________
MEEP!
Reply With Quote
  #2  
Old 01-18-2014, 07:59 PM
100Zero100 100Zero100 is offline
Registered User
Join Date: Jul 2006
Posts: 31
100Zero100 is on a distinguished road
Quote:
Originally Posted by callimuc View Post
his one would just work at its best if you know/send the length of your numbers, while the one BlueMelon and me posted could be used as a function used by several scripts (like putting it into a class with custom functions)



Interesting to know
Starfire's method works with substring() too, for multiple numbers, by using temp.num.length() looping.

I disagree with everybody. I would use .charat()

PHP Code:
function numberToArray(num) {
 for (
temp.0num.length(); i++) {
  
temp.array.add(num.charat(i)); // like num.substring(i, 1) but more efficient
 
}
 return(array);

So
temp.num = 426;
temp.test = numberToArray(num);

temp.test is {4, 2, 6}

You could also use charat() to most efficiently get the number at a single position, eg num.charat(1) would be 2.

EDIT: Someone beat me to charat. Darn. But looping backwards and using .insert is the same as using .add and looping forwards, Andrew.

EDIT2: I wonder if concatenation/tokenize would be more efficient than .add()? If so, temp.array = array SPC num.charat[i]; + tokenize it on the return.
__________________
Hi. I'm NaS!

Last edited by 100Zero100; 01-18-2014 at 08:30 PM..
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 03:52 PM.


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