View unanswered posts | View active topics It is currently Thu Mar 28, 2024 7:44 pm



Reply to topic  [ 1 post ] 
 A function to transmit several values with Sharpness. 
Author Message
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post 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


Sun Feb 17, 2013 7:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.068s | 17 Queries | GZIP : Off ]