itmSetData isn't setting the data

Post ideas & suggestions you have pertaining to the game here.
Post Reply
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

when I put this in my shield it never sets the downTime data but it does get there (I know because (dbgOutPut "going down up at" (itmGetData gItem "downTime")) keeps on outputting "going down up atNil"

Code: Select all

<OnUpdate>
				(block nil
					(if (itmIsInstalled gItem)
						(block nil
						(dbgOutPut (unvGetTick) (itmGetData gItem "downTime"))
						(switch 
							(eq (shpGetShieldDamage gSource) 100)
								(switch 
									(not (itmGetData gItem "downTime"))
										(block nil
											(itmSetData gItem "downTime" (add (unvGetTick) 60))
											(dbgOutPut "going down up at" (itmGetData gItem "downTime"))	
										)
									(ls (itmGetData gItem "downTime") (unvGetTick))
										(block nil
											(shpRechargeShield gSource 1)	
											(itmSetData gItem "downTime" nil)
										)
									
								)
							(gr (shpGetShieldDamage gSource) 90)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 80)
								(shpRechargeShield gSource 1)	
							(gr (shpGetShieldDamage gSource) 70)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 60)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 50)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 40)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 30)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 20)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 10)
								(shpRechargeShield gSource 1)
							(gr (shpGetShieldDamage gSource) 0)
								(shpRechargeShield gSource 1)
					
						)
						)
					)
				)
			</OnUpdate>
any ideas what is wrong?
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

found that itmSetGlobalData itmGetGlobalData is working fine so I am going to use those
Crying is not a proper retort!
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Items are tricky.

Any call of the form (itmSet...) returns a new item structure that has been changed by the function.

Thus you need to do something like:

Code: Select all

(setq gItem (itmSetData gItem "Test" "This is a test"))
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

but how would that work when the event is called again?
I would assume that OnUpdate sets the gItem when called (or you wouldn't be able to use it)
am I mistaken in that?

edit:
I just tested it and it only works for that time the event is called it never remembers the data after the event is over.
Crying is not a proper retort!
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Betelgeuse wrote:but how would that work when the event is called again?
I would assume that OnUpdate sets the gItem when called (or you wouldn't be able to use it)
am I mistaken in that?

edit:
I just tested it and it only works for that time the event is called it never remembers the data after the event is over.
You're right--it's hard to set item data from inside of the OnUpdate. The problem is that items are not real objects. The only way to change an item is to delete it and re-add it. [And that's probably dangerous inside of OnUpdate.]

I'll have to come up with a better fix.

For now, your workaround of using itmSetGlobalData will work, but make sure that you set a variable that includes the ObjID of the ship.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

hmm question when you set data on an installed item does the item you get back installed too?

If not are there any other parts that are different than the original item?
Crying is not a proper retort!
Post Reply