Hi,
but please remember they are write and read as strings, not numbers.
That is not correct. Try experimenting.
There are three APIs to set the value of a register:
mcRegSetValue() stores a numeric value, I suspect a 32bit floating point IEEE 754
mcRegSetValueLong() stores an integer value, I suspect 32 bit signed
mcRegSetValueString() which as the name suggests stores a variable length string.
As an example I tried this piece of code:
local regHandle=mc.mcRegGetHandle(inst,"iRegs0/MyString")
local string=mc.mcRegGetValueString(regHandle)
local string=string/2.07
where I stored '6789' as the value of the string. One some occasions the division failed, dividing a string by a numeric value does not really make sense, but on
other occasions the string was re-cast and the division proceeds with a real result, ie a fractional portion. I have yet to discover why Lua sometimes re-casts and sometimes
not.
Another example:
local regHandle=mc.mcRegGetHandle(inst,"iRegs0/MyInteger")
local integer=mc.mcRegGetValueLong(regHandle)
local integer=integer/2.07
This time I stored the same number (6789) but as an integer by using SetValueLong(). Note that I tried storing the value 6789.1234 using the same API
but the actual stored value is 6789, ie the fractional portion is lost, ie stored as an integer. Interestingly the division works but returns a real value, ie with
a fractional component. It suggests that the integer value was re-cast as a real number and then the division is completed.
This is a common feature of Lua, being essentially type free, is that re-casts happen behind the scenes often transparently to the user. None the less there are at least three
distinct data types that can be stored in a register. You have to be aware of when Lua re-casts......and that has caused me a little grief from time to time.
Craig