itmSetData

Post ideas & suggestions you have pertaining to the game here.
Post Reply
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

I've been trying to use itmSetData to modify the expire time set on the fresh fruit that is sold in St. Katharines but have been unable to use itmSetData and have a few questions.

FncHelp says:
(itmSetData item attrib data [count]) -> item

and when I use:
(itmSetData (itmCreate &itWaterIce; 1) "data" 42)

I get as the return:
(16422 -16777215 48 0 0 "\0\0\0\0\xff\xff\xff\xff\0\0\0\0\xff\xff\xff\xff" "|\0\0\0AOLA\x01\0\0\0\x01\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x09\0\0\0\0\0\0\0\x01\0\0\0\xff\xff\ xff\xff\0\0\0\0\0\0\0\0\x09\0\0\0\x01\0\0\0\0\0\0\0\xff\xff\xff\xff\x01\0\0 \0\x01\0\0\0\x01\0\0\0\x04\0\0\0data\x02\0\0\0\x01\0\0\0\x02\0\0\042\x02\0\0\0\0\0")

which I can only assume is the entire item and it's data in hex.

The real problem is, when data is set already on the fruit I am unable to overwrite that data.

So, is this working as intended?
If so, what is the proper way to use itmSetData to change data that is already set?

For reference, this is the code that sets the data on fruit initially and the code I'm using to try and change it:

From StKatharines.xml line 356

Code: Select all

(objAddItem gSource 
	(itmSetData 
		(itmCreate theItemUNID produceCount)
		"expireTime"
		(add (unvGetTick) (random expireTime (add expireTime 1800)))
		produceCount
		)
	)

My attempt to alter the data:

Code: Select all

(objEnumItems gSource "* +FreshFood;" theItem
(block (expiry fruitCount)
	(setq expiry (itmGetData theItem "expireTime"))
	(setq fruitCount (itmGetCount theItem))
	(if (ls (unvGetTick) expiry)
		(block (rand)
			(setq rand (random 5 15))
			(itmSetData theItem "expireTime"
				(add rand expiry)
				(itmGetCount theItem)
				)

			)
		)
	)
)

Any help would be appreciated, Thanks!

EDIT:
Thanks to Betelgeuse/Taben for explaining the use of ObjSetItemData, the mod is now working as intended.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
Post Reply