Page 1 of 3

Help me script edition

Posted: Thu Aug 21, 2008 3:57 pm
by Betelgeuse
This thread is for you to ask and answer questions about small amounts of code. Please do not ask how to how to make your mod. Those kind of questions go in the extensions reference help me thread.
For example here is a question I have myself.

(setq vary (sysVectorPolarOffset center angle radius))
Is there a way to derive center and radius from vary?

Posted: Fri Aug 22, 2008 1:15 am
by Fatboy
I was wondering, what's this piece of code , and how do you edit it.

Code: Select all

(setq stationList (sysFindObject gSource "T:aresMajor;A"))

Posted: Fri Aug 22, 2008 1:37 am
by Periculi
Fatboy, I think I can handle that one:

First of all, it's creating a List. The (setq declares a variable called stationList and gives it the value that is being returned from (sysFindObject)

(setq string "Hello world") is a simple variable that is holding an obvious string.

(setq myList (list A B C)) is a variable holding a list.

(setq stationList (sysFindObject ...)) is also a variable holding a list.

Now to explain that function- (sysFindObject [spaceObject] "[criteria]") is a built in function to perform searches in a star system.

Please check the functions section on Xelerus for more information about (sysFindObject) (just clicky!)

[spaceObject] is the object that the list is from. Usually gSource for the calling object works, although is it is in an item the player is meant to use you can also use gPlayership.

"[criteria]" takes a preset list of search parameters and also modifiers, data types, and even attributes.

What (sysFindObject returns is always a list. In that usage, it is finding all the stations (T) in the system with the modifier "aresMajor" in them that are active (A). The modifiers are located in the station elements.

sysFindObject returns space objects, not items. Once you have a list of spaceObjects (stations, ships, planets) you can target specific objects on the list.

You can alter the modifiers to anything that is in the game or even to your own custom modifier, you can alter the key type (T,A) to anything you will find on the list describing the function over at xelerus.

Ignore that _changed on the function name on Xelerus- that is the way we show that something has been updated. :?

Posted: Fri Aug 22, 2008 2:36 am
by Fatboy
So this would find all the commonwealth Fleet stations?

Code: Select all

(setq stationlist (sysFindObject gSource "T:commonwealthFleet;"))

Posted: Fri Aug 22, 2008 3:02 am
by Periculi
CSCTaskForce is a ship. With these attributes:

Code: Select all

			attributes=			"commonwealth,commonFleet,commonMilitary,genericClass"
I think you would need to alter the criteria to find that, yes?
More like (sysFindObject gSource "s:commonFleet") for that I think.

Commonwealth Fortress is a station with these attributes:

Code: Select all

			attributes=			"commonwealth,commonMilitary,fleetDelivery,friendly,primary,populated"
You could change the search to look for the commonwealth attribute, or for commonMilitary or commonFleet depending on what you wanted. Just be sure to look up the attributes rather than guessing. You can also output the list to the debug console to see what you got (as UNID):
(dbgOutput (sysFindObject nil "T:commonFleet As"))

Posted: Fri Aug 22, 2008 3:19 am
by Fatboy
* Thinks about how many modding possibilities he can have *
:D

Posted: Fri Aug 22, 2008 3:24 am
by Periculi
:lol: Your welcome.

Posted: Fri Aug 22, 2008 12:30 pm
by digdug
just a little intrusion:
I'm updating the functions on xelerus
sysFindObject has been changed in 0.99, it can accept a couple of new attributes.

To reflect that on the xelerus function list, you will find sysFindObject_changed as the old version with attribute 0.98, and sysFindObject with attribute 0.99.
You can search by attribute so you can see all the new 0.99 functions or look at the deprecated and changed functions from 0.98
(that way we can retain old functions and add the new ones)

so
sysFindObject 0.98 http://xelerus.de/index.php?s=functions&function=259
sysFindObject 0.99 http://xelerus.de/index.php?s=functions&function=283

Posted: Fri Aug 22, 2008 2:40 pm
by digdug
what is plyGetGenome ? :shock:

Posted: Fri Aug 22, 2008 5:02 pm
by Fatboy
It gets whether the player is male or female, I think.

Posted: Sat Aug 23, 2008 1:30 pm
by Betelgeuse
I would like to see a couple functions but can't think of a nice way to do them.

objHasItemByUNID
and
objRemoveItemByUNID

checks if they have or removes an optional count of items that match an id

I would like them to go damaged normal enhanced (I don't care the order of what enhancements are removed, also no removing installed devices)

any takers? (no hurry I don't need them for a mod but it would have made the mod I am making easier)

Posted: Sun Aug 24, 2008 5:10 am
by Betelgeuse
anyone know a way to get an items description?
I know I can stuff it in static data but would like to do it without overwriting all the items.

Posted: Fri Aug 29, 2008 7:41 pm
by Betelgeuse
is there a nice way of telling if a space object has a certain item equipped?

Posted: Sat Aug 30, 2008 7:07 pm
by Mutos
Hi all,


Back to the old sysFindObject point. In the Xelerus page about it, it's said to be "T:xyz" to get an attribute for stations. This is rather "t:xyz". I tried this for planets, "T:planet" didn't work but "t:planet" did.

Posted: Sat Aug 30, 2008 7:26 pm
by Periculi
That's correct- if you check the search filters description you will find:
xelerus wrote: * G -> Stargates only
* s -> Include ships
* t -> Include stations (including planets)
* T -> Include structure-scale stations
* T:xyz -> Include stations with attribute \'xyz\'
* A -> Active objects only (i.e., objects that can attack)
* B:xyz -> Only objects with attribute \'xyz\'
* D:xyz -> Only objects with data \'xyz\'
* E -> Enemy objects only
* F -> Friendly objects only
* M -> Manufactured objects only (i.e., no planets or asteroids)
* N -> Return only the nearest object to the source
* N:nn -> Return only objects within nn light-seconds
* O:escort -> Ships ordered to escort source
* O:docked-> Ships ordered to dock with source
* O:guard-> Ships ordered to guard source
* R:nn -> Return only objects greater than nn light-seconds away
Big T = structure scale stations (space stations only)
Little t = stations including planets

The game considers any spaceObject like a colony, CW fortress or a planet as a station. Even the star is a station. Stations typically don't move, and have features that the other spaceObject type, ships, don't have.

Stations are further divided by a scale="" attribute, which determines "star" scale or "world" scale to distinguish those types from a default station scale.