Linked Fire Slot (LFS) Library

Planning, discussion, release and support of registered extensions, libraries, adventures and other content is here.
Post Reply
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5510
Joined: Tue Feb 05, 2008 1:10 am
Location: At the VSS Shipyards in the frontier, designing new ships.

This library enables mod makers to use the linked fire slot system from TSB.

Instructions & code-examples on how to use this library are available on its ministry page, but due to formatting issues on ministry, I will provide the documentation here as well:

https://multiverse.kronosaur.com/transE ... &release=1#



How to use LFS:
You need to add this entity:

Code: Select all

    <!ENTITY LFS_unidLFSLib                            "0xA0030013">
in order to use this library:

Code: Select all

    <Library unid="&LFS_unidLFSLib;"/>
Next, in your playership, you add an <Events> block like so:

Code: Select all

		<Events>
			<onCreate>
				;;;Set LFS Slots
				(block (itmList MyMod_shipNameSlotCriteria)
					;;;;My ship slot criteria

					(setq MyMod_shipNameSlotCriteria (lambda (object item)
						(and (eq (itmGetProperty item 'deviceSlots) 1) (leq (itmGetMass item) 2000))
					));;setq and lambda
					;;set device slot locations and criteria
					(LFS_shpAddDefaultSlot gSource)
					;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
					;;=============================================================
					;;define a device slot
					;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					;;parameters for each value are:
					;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					;;name -		string,		unique name identifier for this slot
					;;
					;;posAngle - 		int, 		polar angle coordinate of slot
					;;posRadius - 		int, 		radius coordinate of slot
					;;posZ - 		int, 		euclidian vertical offset of slot
					;;omniTF - 		boolean, 	if is omni (overrides pivot selection)
					;;pivotTF - 		boolean, 	if has a pivot (requires non-nil arcs if true)
					;;fireArcMin - 		int, 		min arc angle of pivoting slot
					;;fireArcMax - 		int, 		max arc angle of pivoting slot
					;;LinkedFirOption - 	string, 	one of the following:
					;;	'always - 			always shoots when player shoots (use for fixed weapons)
					;;	'whenInFireArc - 		only shoots when a target is in the firearc
					;;	'targetInRange - 		only shoots when a target is in the radius of fire (use for homing and omni weapons)
					;;secondaryTF - 	boolean,	if this slot is a secondary slot (used for NPCs)
					;;
					;;critereonList -	list,		list of options (see below) the restrict what can be added. Nil is assumed to be "*"
					;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					;;options for the critereon list:
					;;() or Nil -		Assumed to be "*" (any item)
					;;('string) -		An item criteria string (like "w^I")
					;;('string lambda) - 	An item criteria string (if Nil assumed to be "*") with an additional lambda that takes an object and an item as its argument and returns a boolean value (True means ok to install, Nil means not ok)
					;;(Nil Nil) - 		Default slot (acts as "*" but allows any item to be dumped there if its slot gets taken)
					;;
					;;default slot
					(LFS_shpDefineDeviceSlot
						gSource
						'Fore
						30 ;radius
						0 ;angle
						6 ;posZ
						Nil ;omniTF
						True ;pivotTF
						300 ;minArc
						60 ;maxArc
						Nil ;LFS
						Nil ;secondaryTF
						(list "w^I -Howitzer" MyMod_shipNameSlotCriteria) ;critereonList
					)
					;;Preinstall recoillessCannon or whatever item is supposed to go here
					(setq itmList (objGetItems gSource "w^I +unid:&itRecoillessCannon;"))
					(LFS_shpInstallItemToSlot gSource (item itmList 0) 'Fore)
				)
			</onCreate>
			<onGlobalPaneInit>
				; aScreenUNID is the UNID of the screen being shown
				; aScreen is the screen name (if this is a local screen)
				; aPane is the pane being shown
				; shipStatusScreen is the current playership's dockscreen
				(if 
					(and
						(eq aScreenUNID &dsShipInterior;)
						(eq aPane "Default")
						(eq (objGetType gPlayership) &MyMod_scMyPlayerShip;)
					)
					(scrAddAction
						gScreen
						'accessMyPlayerShipSystems
						0
						"Access My Player Ship Class Name Systems"
						"a"
						'default
						(scrShowScreen gScreen &LFS_dsEquip;)
					)
				)
			</onGlobalPaneInit>
		</Events>
Version history:

Code: Select all

1.0.0.0 - 2014 09 16
	Initial release, requires TSB Function Library
1.1.0.0 - 2024 09 16
	Nolonger requires TSB Function Library
2.0.0.0 - [TBD]
	Improved UI for players selecting slots
(shpOrder gPlayership 'barrelRoll)

<New tutorials, modding resources, and official extension stuff coming to this space soon!>
Post Reply