Page 1 of 1

Grapple Beam OXP v0.2 - HELP!

Posted: Fri Aug 10, 2012 8:39 am
by Rese249er
Grapple Beam v0.2 is available for download, with hardly any functionality to it at all. Any help getting a continuous effect would be greatly appreciated. grappleBeamcont.js is a blank place-holder file where (hopefully) whatever additional scripting is necessary will go.

Re: Grapple Beam OXP v0.2 - HELP!

Posted: Wed Aug 15, 2012 10:41 am
by Wildeblood
You want a thing called a frame callback; once started, it will continuously call your function until you stop it. You'll find examples in many OXP scripts, e.g. there is one in Escort Contracts that starts when you're within a certain range of the mothership, there is one in Sniper Sight that starts when you change the compass to a certain mode, there is one in Trading Assistant that starts when you change to the market screen, there is one in Explorers' Club but it's not for the animation on the chart screen. :)

Below is the correct syntax for starting and stopping a frame callback, you need to add three things: the conditions to start it, the conditions to stop it, and the repeating function (in your case the player ship re-positioning).

Code: Select all

(Some starting conditions go here...)
	{
	this.$myFrameCallback = addFrameCallback(this.$myFunction.bind(this));
	}

this.$myFunction = function(delta)
	{
	if (...some stopping conditions go here...)
		{
		removeFrameCallback(this.$myFrameCallback);
		delete this.$myFrameCallback;
		return;
		}
	// Your code here...
	}