Grapple Beam OXP v0.2 - HELP!

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Grapple Beam OXP v0.2 - HELP!

Post 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.
Got all turned around, lost my nav connection... Where am I now?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2281
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Grapple Beam OXP v0.2 - HELP!

Post 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...
	}
Post Reply