Jump to content

Object properties question


ArBuZ
 Share

Recommended Posts

Hi guys! I have a little problem.

 

I have a model and want to add custom properties to it. Here is LUA file for it

require("scripts/class")

local class=CreateClass(...)

function class:InitDialog(grid)
self.super:InitDialog(grid)
group=grid:AddGroup("Box01")
group:AddProperty("hitpoints",PROPERTY_INTEGER,"","hitpoints")
group:AddProperty("type",PROPERTY_INTEGER,"","type")
group:AddProperty("Param7",PROPERTY_FLOAT,"","Param7")
group:AddProperty("Param8",PROPERTY_BOOL,"false","Param8")
group:AddProperty( "BColor", PROPERTY_COLOR, "1" )
group:AddProperty("Param10",PROPERTY_STRING,"","Param10")
group:AddProperty("Param11",PROPERTY_FLOAT,"","Param11")
end

 

properies window looks like this:

post-36-126881043234_thumb.jpg

 

All values are zero.

 

So if I save this map with this object and DONT EDIT any of my custom properties of the object, then in sbx file this properties are absent!

Here sbx file:

SBX_ASCII_1.0

cameraposition=0.000000000,5.73576403,-8.19152069
camerarotation=34.9999962,0.000000000,0.000000000

Model {
path="light_directional.gmf"
position=0.000000000,1.00000000,0.000000000
rotation=45.0000000,34.9999962,3.01372808e-007
scale=1.00000000,1.00000000,1.00000000
id=141729016
"aligntoground"="0"
"class"="Model"
"collisiontype"="0"
"damping"="0.000000000,0.000000000"
"friction"="0.000000000,0.000000000"
"gravity"="0"
"intensity"="1.0000000000000000"
"linearoffset"="0.310000002,0.400000006,0.699999988"
"mass"="0.00000000000000000"
"name"="light_directional_1"
"order"="0"
"range"="500.00000000000000"
"resolution"="2"
"shadowdistance"="6.00000000,20.0000000,100.000000"
}

Model {
path="luatest_box.gmf"
position=1.00000000,0.000000000,-1.00000000
rotation=0.000000000,0.000000000,0.000000000
scale=1.00000000,1.00000000,1.00000000
id=144936072
"class"="Model"
"intensity"="1.0"
"name"="box_2"
}

But if I edit them (at least one of them) then all this properties are present in sbx map file.

So the question is why does that happen? and

Can I somehow set initial values of custom properties?

 

Thanks in advanced.

PS

I need it for my 3ds max exporter. It will be possible to set properties for models in 3ds max and then automatically have them in the editor!

Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

Link to comment
Share on other sites

I had same problem, ... because i forgot add functions for read and write values for user defined properties. Here is part of my code. I think that help you.

 


function class:InitDialog(grid)

self.super:InitDialog(grid)

group = grid:AddGroup("GameProperties")
group:AddProperty("classname", PROPERTY_STRING, "classname")


group = grid:AddGroup("Key Binding")
group:AddProperty("key_forward", PROPERTY_STRING, "KEY_UP","Key Forward")
group:AddProperty("key_backward", PROPERTY_STRING, "","Key Backward")
group:AddProperty("key_turn_left", PROPERTY_STRING, "","Key Turn left")
group:AddProperty("key_turn_right", PROPERTY_STRING, "","Key Turn right")


end

function class:CreateObject(model)

local object=self.super:CreateObject(model)

object.classname = "func_gamecontrol"

-- default key binds
object.key_forward = "KEY_UP"
object.key_backward = "KEY_DOWN"
object.key_turn_left = "KEY_LEFT"
object.key_turn_right = "KEY_RIGHT"



function object:SetKey(key,value)
	if key=="classname" then
		object.classname = value
	elseif key=="key_forward" then object.key_forward = value
	elseif key=="key_backward" then object.key_backward = value
	elseif key=="key_turn_left" then object.key_turn_left = value
	elseif key=="key_turn_right" then object.key_turn_right = value
	else
		return self.super:SetKey(key,value)
	end
	return 1
end



function object:GetKey(key,value)
	if key=="classname" then
		return object.classname
	elseif key=="key_forward" then return object.key_forward
	elseif key=="key_backward" then  return object.key_backward
	elseif key=="key_turn_left" then  return object.key_turn_left
	elseif key=="key_turn_right" then  return object.key_turn_right

	else
		return self.super:GetKey(key,value)
	end
	return value
end

       ...

[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

Thank you!

Problem is solved. I think I understand now how all this works. INI file contains all initial values. If you dont change them in the editor then values from ini are used. If you change them in the editor then values from sbx file are used.

Interesting then how Josh is going to remove ini files from the engine. I saw somewhere he told that. :)

Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

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