Jump to content

Objecttable in Blitzmax


norbert
 Share

Recommended Posts

Hi,

in the lua Script file driver.lua there load the Model and read from the Objecttable:

 

chassis=LoadModel("abstract::vehicle_viperscout.gmf")
carobject=objecttable[chassis]
car=carobject.vehicle

 

Ok, but how can I use this in BlitzMax?

 

I load my car:

Global chassis:TModel
chassis = LoadModel ("abstract::vehicle_viperscout.gmf")

 

How can I use the objecttable[chassis] in Blitzmax ?

 

Norbert

Link to comment
Share on other sites

You're wanting to access a LUA object from you main program code?

 

 

Off the top of my head...

 

And in BMax before you load your scene, make an object and assign a name as a reference you can access in your script...

 


  Local tempObject:Object;
  SetGlobalObject("car_chassis", tempObject ) ;

  ' LOAD A SCENE '

  ' Cast tempObject to whatever you need '
  Local carmodel:TModel = TModel(tempObject);

 

In the LUA script set the object pointer to the name ...

 

  SetGlobalObject( "car_chassis", chassis )

 

 

There's some older threads on this, search on "SetScriptObject" and "SetGlobalObject"

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

Thank you but somehow does not work.

 

OK. In Detail.

 

When I start the Editior and use the driver.lua then I can drive in the Editor with the viperscout.

In this Script file "driver.lua" there load the Model and read from the objecttable:

 

chassis=LoadModel("abstract::vehicle_viperscout.gmf")
carobject=objecttable[chassis]
car=carobject.vehicle

 

Later in the script there add Torque to the tire:

car:AddTireTorque(tirespeed,0)

 

 

In BlitzMax I load the Model same way as in lua script file:

Global chassis:TModel 
chassis = LoadModel ("abstract::vehicle_viperscout.gmf")

 

 

In Blitzmax I must

AddTireTorque( tire:TTire, torque:Float ) 

 

but I have no tires only a TModel.

 

 

Ok how can I AddTireTorque to this Model in Blitzmax ?

Link to comment
Share on other sites

Yes, thats right,

but I load the Model and the lua script from the car load automatic with tires and Physik.

 

The car is ready for driving. I need a Command to manipulate or transfer my TireSpeed in the Script file from the car.

Link to comment
Share on other sites

oh.. gotcha... guess i should read the whole post first...

 

well, just do as Flexman stated and set the tires as GlobalObjects in lua then use GetGlobalObject() in bmax to access the tires, then you should be able to add torque... assuming that you cannot access the tires from the chassis in bmax if you make it a global object.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Ok, thank you but the is a error: Unable to convert from leadwerks.engine.TTire to TVehicle

 

What have I do:

 

In the viperscout.lua file i have add the SetGlobalObject command:

 

pivot=object.model:FindChild("tire1")
if pivot~=nil then
	tireradius=pivot.aabb.h/2.0
	object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
	object.tire[0]=LoadMesh("abstract::vehicle_viperscout_tire_left.gmf",model)
	SetGlobalObject( "car_tire1", object.tire[0])
                                          pivot:Hide()
end

 

In BMax first (before Load the Scene):

Global temp_tire1_Object:Object
SetGlobalObject("car_tire1", temp_tire1_Object)

 

Second after loading the viperscout.gmf (TModel) after load the scene:

Global car_Tire1:TTire = TTire(temp_tire1_Object)

 

and in the mainloop addTorque:

tirespeed# = -(KeyDown(KEY_W)-KeyDown(KEY_S))*5
AddTireTorque( car_Tire1,  tirespeed# ) 

 

 

and I get the Error Message.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...