Data Realms Fan Forums http://45.55.195.193/ |
|
A function to transmit several values with Sharpness. http://45.55.195.193/viewtopic.php?f=73&t=45137 |
Page 1 of 1 |
Author: | Mehman [ Sun Feb 17, 2013 7:38 pm ] |
Post subject: | A function to transmit several values with Sharpness. |
Hi, So let me explain this more clearly: The sharpness variable is sometimes used in scripts to transmit information from one object to another without having to use global variables. Yet it is just one variable, and you may want to send deveral values each time the game updates, so here is a solution to this problem: With these functions you can modify and check each digit of any variable independantly: Code: function ExtNum(n,n2) --Extracts the n2th digit from a number starting from the right, what comes after the . is ignored, e.g: ExtNum(12345,2) = 4; local nn = math.floor(n)%math.pow(10,n2); nn = nn/math.pow(10,n2-1); return math.floor(nn); end function IntNum(n,n2,v) --Changes the n2th digit from a number to v, e.g: IntNum(12345,2,3) = 12335; Used to store multiple one digit values in the Sharpness of an object. return n-ExtNum(n,n2)*math.pow(10,n2-1)+v*math.pow(10,n2-1); end These functions must be declared outside of any create/update/destroy functions. Anyone is free to use them, if you modify them then please rename them so that compatibiwith my mods is preserved. Also here are some other functions of general use(these included, this is the complete file out of which they come) you might want to have a look at: Anyone is free to use this |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |