Arrays as Object Properties (SCI): Difference between revisions
From Sierra WikiNew
Jump to navigationJump to search
m (1 revision imported) |
|||
Line 63: | Line 63: | ||
[[Category:Development]] | [[Category:Development]] | ||
[[Category:SCI Development]] | [[Category:SCI Development]] | ||
[[Category:How To]] | [[Category:How To]] | ||
[[Category:SCI How To]] | [[Category:SCI How To]] |
Latest revision as of 20:17, 5 December 2024
Arrays as Object Properties
Introduction
With SCI0 you cannot set properties within an object with arrays.
Lars Skovlund[1] wrote:
There is no way to do what you ask. That's part of the reason why they had to introduce the Memory call in SCI01 (but that's an ugly solution to the problem.
There is a hack that you can use, however. Declare a single local variable followed by the arrays you need. Then you can (at least from the point of view of the PMachine, not sure about Brian's compiler) index into the large arrays by addressing the lone local variable and using a bit of arithmetic.
SCI Code:(local baseVar array1[10] array2[10] ) (instance Blah of Obj (properties arrayPos 1 ) ) (instance Blarg of Obj (properties arrayPos 11 ) )
To access the array, you use a reference like:
SCI Code:baseVar[(Blah:arrayPos)] // Gets the 1st value from array1 baseVar[(Blarg:arrayPos)] // Get the 1st value from array2 baseVar[+ (Blah:arrayPos) 1] // Gets the 2nd value from array1 baseVar[+ (Blarg:arrayPos) 1] // Get the 2nd value from array2
References
Also See