help with functions

Freeform discussion about anything related to modding Transcendence.
Post Reply
andrewpen
Commonwealth Pilot
Commonwealth Pilot
Posts: 97
Joined: Thu May 31, 2012 12:35 pm
Location: In my lab

Can someone teach me how to use functions. Especially the objAddItem and shpInstallDevice functions objSetDevicePos and objSetDeviceFireArc. objSetDeviceLinkedFireOptions it would realy help me with my cruiser
when life throws you a curve ball catch it and throw it back.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

objAddItem is a straightforward function to use, it adds an item to a spaceobject.

Code: Select all

(objAddItem obj item [count]) -> True/Nil
the item must be an itemStruct, so you have to create it using itmCreate function.

Code: Select all

(objAddItem gPlayership (itmCreate 0x001B4001 1))
This will create a lightining cannon and add it to the cargo of the playership.

---
shpInstallDevice installs devices onto a ship.

Code: Select all

(shpInstallDevice ship item) --> item
Note, the item returned by shpInstallDevice is not the same itemStruct that is picked from the cargo (removed from the cargo and installed). So, for example, if you are interested to set a firearc to a weapon, you have to do something like this:

Code: Select all

(setq tempItem (shpInstallDevice ship item))
so that you can then manipulate tempItem to your likings.

Note2: shpInstallDevice only works on ships and not on stations ! Well this could actually be a nice ticket. Installing or changing weapons on stations could be interesting.

---


objSetDevicePos can accept 2 different syntaxes: from Xelerus:

Code: Select all

(objSetDevicePos obj deviceItem number number) -> True/Nil
Argument List
obj: the spaceobject that has the device
deviceItem: the device to set the object of
number: angle of the new item's position
number: radius of the new item's position (in pixels)

the 2 numbers are polar coordinates of the position of the weapon, where 0,0 is the center of the ship.

OR

Code: Select all

(objSetDevicePos obj deviceItem list) -> True/Nil
where list is a list made up of 3 numbers '(a b c) where '(0 0 0) is the center of the ship and where most weapons are fired from in Transcendence. This is handy since objGetDevicePos returns a list ! Unfortunately the returned list has only 2 numbers like this '(0 0) so what I do is to append an additional 0 to the list when I have to reinstall a weapon in the same slot of one I just uninstalled.

Example:

Code: Select all

(setq devicePos (objGetDevicePos ship weapon))
then when I have to use it

Code: Select all

(objSetDevicePos ship tempItm (append devicePos '(0)))
---
andrewpen
Commonwealth Pilot
Commonwealth Pilot
Posts: 97
Joined: Thu May 31, 2012 12:35 pm
Location: In my lab

Thanks didgug I will try to get this right
Ps I have no knowledge of functions prier to this I would really like it if some one could write a tutorial on them.
when life throws you a curve ball catch it and throw it back.
andrewpen
Commonwealth Pilot
Commonwealth Pilot
Posts: 97
Joined: Thu May 31, 2012 12:35 pm
Location: In my lab

Would it be possible to use these functions to enable a station to remove a standard weapon and replace it with a link fire weapon. Similar to PM's player ship drones.
when life throws you a curve ball catch it and throw it back.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Would it be possible to use these functions to enable a station to remove a standard weapon and replace it with a link fire weapon
as I said before in my previous post, there are no functions (to the best of my knowledge) that can install/uninstall weapons into stations.
andrewpen
Commonwealth Pilot
Commonwealth Pilot
Posts: 97
Joined: Thu May 31, 2012 12:35 pm
Location: In my lab

I meant onto ships docked at stations. Putting weapons in linked fire slots on ships docked
when life throws you a curve ball catch it and throw it back.
Post Reply