Hey, guys. I'm making a Metal Detecting minigame for my project, and I need some help making a script. I am a programmer, but I am not familiar with how ruby or RGSS works at all, so I am able to provide Algorithms. I just need some clever person to make it into working code for me.
H'okay. So there it is. Basically, I will have events that have a comment on the top of the page, which is necessary because the pages change, you cannot detect after you've dug it up. Then, a paralell process will be calling setDistance method every frame or so, which finds out the minimum distance between all those events and the player, basically setting minDistance to the distance of the closest event to the player.
Then, a method getDistance returns that minDistance value. It's in its own method so that I can call it from a conditional fork from an event. It's also the reason why minDistance has to outlast the lifespan of just the setDistance method.
If someone could make this script for me, I would be much obliged. Thanks very much n.n
Code:
Class MetalDetecting
static int minDistance
method setDistance()
//Get Events with Comment "Hole" and place in array length n.
int temp = 0
minDistance = 15
for loop (i..n)
int tX = Math.abs(event[i].x - player.x)
int tY = Math.abs(event[i].y - player.y)
temp = Math.sqrt((tX^2)+(tY^2))
if (temp < minDistance)
then minDistance = temp
end loop
end
method getDistance()
return minDistance;
end
end
H'okay. So there it is. Basically, I will have events that have a comment on the top of the page, which is necessary because the pages change, you cannot detect after you've dug it up. Then, a paralell process will be calling setDistance method every frame or so, which finds out the minimum distance between all those events and the player, basically setting minDistance to the distance of the closest event to the player.
Then, a method getDistance returns that minDistance value. It's in its own method so that I can call it from a conditional fork from an event. It's also the reason why minDistance has to outlast the lifespan of just the setDistance method.
If someone could make this script for me, I would be much obliged. Thanks very much n.n