Help me script edition

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

I would like for someone to make a helper function that when passed a UNID of a weapon and ship would fire the weapon passed in. It needs to obey any velocity changes that the ship would cause to the shot due to the ship's movement.
This function also needs to return the shot.
Crying is not a proper retort!
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

You also need to provide the shot speed because there's no way to get that in script, but otherwise here you go:

Code: Select all

(setq shotmaker (lambda (unid missilespeed ship)
		(block (shot objVel unitvector shotvectorcomponent)

				; store the vector of the ship
				(setq objVel (objGetVel ship))
				; get unit vector
				(setq unitvector (sysvectordivide (sysvectorpolaroffset nil (shpgetdirection ship) 1) 299792))
				; set the vector the shot would receive from thegun
				(setq shotvectorcomponent (sysvectormultiply unitvector missilespeed))
                                ;fire a weapon and save the shot
                                (sysCreateWeaponFire unid ship (objGetPos ship) (sysvectorangle (sysvectoradd objvel shotvectorcomponent)) (sysvectorspeed 

(sysvectoradd shotvectorcomponent objvel))  nil)
                        

                        )
	))
User avatar
Fatboy
Militia Lieutenant
Militia Lieutenant
Posts: 247
Joined: Fri Feb 22, 2008 1:52 am
Location: California

I would like to know how the rin currency is implemented.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

The players current rin total is simply stored as a variable on the playership. Any time a transaction with rins is conducted, the appropriate amount is added to or subtracted from that total.

Using the same scheme it would be possible to add any number of currencies in transcendence.
sdw195
Militia Captain
Militia Captain
Posts: 779
Joined: Wed Nov 18, 2009 1:01 am
Location: Still looking for the csc Antarctica
Contact:

Code: Select all

(objgetdata gPlayership  "rins")  returns amount of rins player has  
(objincdata gPlayership "rins" ##) adds/removes rins (depends on number being positive or negative
Image
Image
Image
Image
"Dash_Merc - George is a genius, in that he created this game engine that is infinitely extendable"
"<@sheepluva>Good night everybody, may the source be with you." <-- FOSG dev
"You only need THREE tools in life - WD-40 to make things go, Duct Tape to make things stop And C-4 to make things go away"
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I would like someone to give me an example on how to handle 2 lists with different length.

I would like to iterate a list, and match every element with a second list, which is not the same length (can be longer or shorter). If the second list is shorter, then continue to iterate the elements of the first list from the beginning

example:
list1 '(1 2 3 4 5)
list2 '(a b c)

result

'((1 a) (2 b) (3 c) (4 a) (5 b))
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

This is normally called a 'zip', with a small variation (the looping). Here is some code

Code: Select all

(setq zip-repeat (lambda (first last)
  (block (len (cnt 0) (res (list)))
    (setq len (count last))
    (enum first el (block nil
      (if (geq cnt len) (setq cnt 0))
      (lnkAppend res (list el (item last cnt)))
      (setq cnt (add cnt 1))
    ))
    res
  )
))
Note, I talked to digdug on IRC about this, so the somewhat special case this works with was talked about there

Code: Select all

(zip-repeat '(a b c d) '(1 2)) -> ((a 1) (b 2) (c 1) (d 2))
(zip-repeat '(a b) '(1 2 3 4)) -> ((a 1) (b 2))
Shifter55
Anarchist
Anarchist
Posts: 14
Joined: Thu Aug 21, 2008 8:44 am

Is it possible to use item UNIDs instead of [gCost] in the tinkers Custom Work process?
JonRobinson
Anarchist
Anarchist
Posts: 8
Joined: Tue Jun 03, 2014 10:31 pm

Anyone know how to get the hex UNID (0xblahblahblah) of an item in your cargo hold ? Maybe with debug console or something?
JonRobinson
Anarchist
Anarchist
Posts: 8
Joined: Tue Jun 03, 2014 10:31 pm

Never mind. Got it from tech forum thx
Post Reply