View Single Post
  #5  
Old 10-17-2005, 07:49 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
NPC Code:

//ex.
function onCreated() {
dx = 2;
dy = 5;
setTimer(5);
}

function onTimeout() {
distance = inaccurateDistance(9,20);
}

function inaccurateDistance(dx,dy) {
dx-=2
dy-=2
return (dx^2+dy^2) ^0.5;
}



Would the values of dx and dy set in onCreated change in that script because they are set by receiving parameters? Would they change within the function inaccurateDistance?

What would be really nice to hear is that the variable scope of function params remained local to the function.

Last edited by jake13jake; 10-17-2005 at 08:02 PM..
Reply With Quote