fun with int

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

int is used to convert a string containing a number to an integer.

(int "1") returns 1
This might sound silly, but it's really useful.

For example, if you subset a string to extract a number, subset will return a string and you have to convert that.
(subset "answer is 7" 10 1) returns "7"
(int (subset "answer is 7" 10 1)) returns 7

also, in the past you needed to use int if you get/set numbers, as the stored number used to be a string.
this is an example of George's commonwealthfleet.xml

Code: Select all

(and (geq (int (objGetData gPlayerShip "commonCrimeSeverity")) 2)
Today ObjSetData will set the data as integers so there is no problem:
(objSetData gPlayership "testData" 1) returns True
(typeof (objGetData gPlayership "testData") returns int32


int can also truncate your real number to integers
(int 12.1231124) returns 12

int converts hex numbers to dec
(int 0xFF) returns 255
Post Reply