[Critical] Bug with lambdas!

Bug reports for the stable versions go here.
Post Reply
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5526
Joined: Tue Feb 05, 2008 1:10 am
Location: At the VSS Shipyards in the frontier, designing new ships.

Ran into this while working on TSB
Eventually this placeholder lambda is going to be replaced with something that works, and any game started with a placeholder version wont work correctly once it is updated


Image

Code: Select all

[09:05:06]	Avan	basically
[09:05:13]	Avan	the first two calls to gCriteriaLambda
[09:05:18]	Avan	should give insufficient argument errors
[09:05:23]	Avan	the third should return true
[09:05:35]	Avan	but isntead its acting as if i called something that was not a function as a function
[09:05:39]	Avan	(like where i call the list
[09:05:46]	Avan	yet it clearly stores the lambda in itself
(shpOrder gPlayership 'barrelRoll)

<New tutorials, modding resources, and official extension stuff coming to this space soon!>
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

I'd like to see the code that assigns the lambda. It looks like it is assigned to a literal list, not an expression. In particular, you shouldn't use the quote (') syntax when returning a list from TSB_shpGetDeviceSlot. I think the (list ...) expression will work better.

Either way, though, I'd like to see the code inside TSB_shpGetDeviceSlot that returns the list.
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5526
Joined: Tue Feb 05, 2008 1:10 am
Location: At the VSS Shipyards in the frontier, designing new ships.

I dont use '(a b c) to assign lists, i only use (list a b c)


Code: Select all

					;;left slot
					(TSB_shpDefineDeviceSlot
						gSource
						'Left
						7
						70
						0
						Nil
						True
						-20
						170
						'whenInFireArc
						Nil
						(list "w^I -Howitzer" TSB_raptorSecondarySlots)
					)

Setting the list

Code: Select all

		(setq TSB_shpDefineDeviceSlot (lambda (object slotName posRadius posAngle posZ omniTF pivotTF fireArcMin fireArcMax LinkedFireOption secondaryTF critereonList)
			(block (slotList)
				(setq slotList (objGetData object 'TSB_slotManagerDeviceSlotList))
				(if (eq Nil slotList) (setq slotList (list)))
				(lnkAppend slotList (list slotName posRadius posAngle posZ omniTF pivotTF fireArcMin fireArcMax LinkedFireOption secondaryTF critereonList Nil))
				(objSetData object 'TSB_slotManagerDeviceSlotList slotList)
			)
		));;setq and lambda
Retreiving the list

Code: Select all

		(setq TSB_shpGetDeviceSlot (lambda (object slotName)
			(block (slotList slot)
				(setq slot Nil)
				(setq slotList (objGetData object 'TSB_slotManagerDeviceSlotList))
				(if (eq Nil slotList)
					(block Nil (setq slotList (list)) (setq slot Nil))
					(enumWhile slotList (eq slot Nil) curSlot
						(if (eq (item curSlot 0) slotName) (setq slot curSlot))
					)
				)
				slot
			)
		));;setq and lambda
(shpOrder gPlayership 'barrelRoll)

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