Jump to content

Changing the Class of an Object in the SBX


Shard
 Share

Recommended Posts

Hey guys, quick question.

 

In the SBX, the Editor generates all the data for files. One of the keys for each entity is "class".

Does anyone know how I can change that in the editor or in Lua so that I can simply hand off these files to the artist for object placement in levels?

 

The main point of this is to be able to parse things in through code easily and reducing the artists work, who won't have to name each object of the same class several times overs.

 

Model {
path="oildrum.gmf"
position=5.00000000,0.000000000,5.00000000
rotation=-0.000000000,-0.000000000,0.000000000
scale=1.00000000,1.00000000,1.00000000
id=362643880
"class"="Model" //<-------------- Changing this class in Lua or the Editor
"collisiontype"="1"
"impactsound"="abstract::impact_metal12.wav,abstract::impact_metal07.wav,abstract::impact_metal13.wav"
"mass"="6"
"name"="oildrum_1"
"stepmode"="0"
}

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

When you need define your class category, then you have 2 ways:

 

1) create ini file with same name like model and define (i.e. classname="OBSTACLE")

2) add new property to lua script

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

When you need define your class category, then you have 2 ways:

 

1) create ini file with same name like model and define (i.e. classname="OBSTACLE")

2) add new property to lua script

 

 

Any chance you could go into a little bit more detail? I remember that the ini files were used at once but I thought they would be replaced by Lua files. As for adding a new property to a Lua script, would I just define a property named class and then define it to whatever it needs to be?

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Property name "class" is used internaly by engine and is created/added to sbx, when model is drag&drop to scene, when exist ini file with same name as model, then is added your property names from ini file to SBX too.

From my point of view, for you is better, create property name like "gameclass" or "classname" to ini file, when you don't need change value.

When you want use lua, then add to section

 

function class:InitDialog(grid)
self.super:InitDialog(grid)
group=grid:AddGroup("MyProperties")
       group:AddProperty("gameclass",PROPERTY_STRING,"OBSTACLE","My game class"
end

 

Note: this code is only example, not tested.

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

require("scripts/class")

local class=CreateClass(...)

function class:CreateObject(model)
local object=self.super:CreateObject(model)
object.model:SetKey("classname","OBSTACLE")
end

 

I wouldn't rename the class, but perhaps give it a classname... and while INI files are still useable at the moment, based on what Josh has said recently I wouldn't count on INI files working in future versions.

 

In any case, why are you parsing your sbx for your models? other than some issues with emitters and lights having pickable meshes (which can easily be taken care of with intelligent placement in the scene), the LoadScene command and the object's lua script basically takes care of the model's settings and properties.

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

require("scripts/class")

local class=CreateClass(...)

function class:CreateObject(model)
local object=self.super:CreateObject(model)
object.model:SetKey("classname","OBSTACLE")
end

 

I wouldn't rename the class, but perhaps give it a classname... and while INI files are still useable at the moment, based on what Josh has said recently I wouldn't count on INI files working in future versions.

 

In any case, why are you parsing your sbx for your models? other than some issues with emitters and lights having pickable meshes (which can easily be taken care of with intelligent placement in the scene), the LoadScene command and the object's lua script basically takes care of the model's settings and properties.

 

 

Its primarily for the purposes of placing enemies so that the Load can parsing in specific enemy details and then load the appropriate classes with it so that the model works with the code.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

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...