VoidExpanse/Device scripts

From AtomicTorchWiki


This article is a draft and may contain incomplete or even incorrect information. You can help by expanding it.

Device Scripts

Devices are items, which can be applied to some object, area, coordinate, or self. There are 3 types of devices: target, coordinate and self. There are no hardcoded effects of devices, all devices behavior is controlled by a special script - device script.

Every device can depend on ship's final cache or values. That's why in every device script there is a mandatory function - OnUpdateCache. It is called every time ship's final cache is updated. This function's arguments are parameters of device, which can be modified:

function OnUpdateCache( args )
{
	var mining_range_modifier = ship.GetFinalCacheValue( args.ship_id, "mining_range");
	args.range *= mining_range_modifier;
	
	var mining_amount_modifier = ship.GetFinalCacheValue( args.ship_id, "mining_amount");
	args.custom_parameters.amount *= mining_amount_modifier;
	
	var mining_speed_modifier = ship.GetFinalCacheValue( args.ship_id, "mining_speed");
	args.custom_parameters.speed *= mining_speed_modifier;
}

In this sample we changed device's range and a couple of custom parameters according to ship's new cache.

Device can produce effect immediately, or can work for some time. There are 3 functions, which are providing opportunity to implement such functional: OnStart, OnFrame and OnFinished. OnStart is called when device is applied to it's target, OnFrame is called every frame device is being used, and OnFinished is called when device is finished. In immediate devices sequence of functions "OnStart" - "OnFinished" is called immediately, without "OnFrame". There's a last mandatory function in device scripts - OnCancel, which is called when device activity was cancelled.

Here are a couple of samples, how to create devices. To create a gradually healing device, all we need is to put healing function ship.SetShipValueDelta into OnFrame function on device. To create mining device, we put mining functional into OnFinished function. As you can see, it's quite easy, and, with proper adjustments, devices can do almost anything, can be used as healing, battle and transporting devices.


VoidExpanse Modding (Edit template)

Using mods: Installing and using mods

Overview articles: Modding (main article), Package files structure

Topic specific articles: Assets modding, Content Modding, Scripting overview, Scripting API, Scripting Events system, Localization

Detailed scripting articles: Internal scripts, Global scripts, object scripts, Device scripts, Consumable scripting

Tools: VE Physics Adjuster, VE Mod Uploader (Steam), AT Localization Utility