How to use double LSType??

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
blackwinter
GamingTools Subscriber
Posts: 74
Joined: Sun Jun 25, 2006 8:29 am

How to use double LSType??

Post by blackwinter » Tue Sep 15, 2009 7:22 am

addLStype?? don't know how to use it.

PLSTYPEMEMBER pMember,I need a double member.

thanks

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Tue Sep 15, 2009 10:42 am

I'm completely lost as to what you are asking, sorry.

eqjoe
GamingTools Subscriber
Posts: 221
Joined: Wed Oct 13, 2004 2:34 pm

Re: How to use double LSType??

Post by eqjoe » Tue Sep 15, 2009 2:31 pm

blackwinter wrote:addLStype?? don't know how to use it.

PLSTYPEMEMBER pMember,I need a double member.

thanks
ISInterface:AddLSType? Or are you looking at Command:LSType?

Help us out here and tell us what you are trying to do....

-j

blackwinter
GamingTools Subscriber
Posts: 74
Joined: Sun Jun 25, 2006 8:29 am

Post by blackwinter » Tue Sep 15, 2009 7:50 pm

It's not in LS, I am trying to write an extention.

The X,Y in memory is double, but I don't wanna convert them to float.

ISXFullTemplate

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Tue Sep 15, 2009 8:13 pm

Okay, this makes much more sense.

The way LavishScript objects work is by storing a 32-bit value, and a pointer to a type interface (aka how to read the value). Anything that can be stored in 32-bits can be kept right there in the LSOBJECT, and it'd effectively be a "value type". Anything larger MUST be stored by reference, i.e. a "reference type".

The 64-bit floating point type in LS is "float64ptr". You either want to allocate memory with GetTempBuffer, or use a pointer to the original value if it's a value that will not be disappearing. If you dont know, use GetTempBuffer.

Here's a quick code sample.

Code: Select all

LSOBJECT dest; // object being returned...
double myDouble = 12.345f; // value to use ...

Dest.Ptr = pISInterface->GetTempBuffer(sizeof(myDouble),&myDouble); // allocate enough memory to store a copy of myDouble, and copy it
Dest.Type = pFloat64PtrType;

blackwinter
GamingTools Subscriber
Posts: 74
Joined: Sun Jun 25, 2006 8:29 am

Post by blackwinter » Wed Sep 16, 2009 7:13 pm

Thanks, another noob's question.

If the offset is game.exe+842740,how can I use this in my extention dll??

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Wed Sep 16, 2009 7:21 pm

Code: Select all

unsigned int memory_address = ((unsigned int)GetModuleHandle("game.exe"))+842740; // calculate actual memory address

double *pTheirDouble = (double*)memory_address; // point to a double at that memory address
myDouble = *pTheirDouble; // copy the double at the memory address to our local variable

blackwinter
GamingTools Subscriber
Posts: 74
Joined: Sun Jun 25, 2006 8:29 am

Post by blackwinter » Thu Sep 17, 2009 2:17 am

Thank you very much.

Post Reply