Jump to content

Variables in model


Gilmer
 Share

Recommended Posts

Hi peoples...

Im having the follow problem: I have a model called trigger2. Always that I create a new trigger2 in editor, it is called as "trigger2_x_y", where 'x' is the ID, 1,2,3,4....and 'y' is the fx that will received, that is set in own properties. I.e, if I create the first 'trigger2' in scene, with the fx set to '0', it name as "trigger2_0_0", if I create other in the scene, it is named as "trigger2_1_0", and so on.

 

The problem is each trigger2 that I create in the scene, is add a value in the first trigger too, and not only in last trigger. If have 10 trigger in the scene, the first trigger, is named as "trigger2_0_1_3_4_5_9_5_6...."..

 

I think that something with the global variables in the own class model. But dont know how solve this..

 

This is the trigger code:

 

require("scripts/class")
local class=CreateClass(...)

function class:InitDialog(grid)
self.super:InitDialog(grid)
group=grid:AddGroup("Tipo")
group:AddProperty("tipofx",PROPERTY_CHOICE,"0,1,2,3,4,5,6,7,8,9,10","Tipo Fx")
group:Expand(1)
end

function class:CreateObject(model)
local object=self.super:CreateObject(model)

local mesh=nil

object.model:SetKey("tipofx","0")

if(n~=nil) then n=nil end
if(n2~=nil) then n2=nil end
if(id~=nil) then id=nil end
if(id2~=nil) then id2=nil end


id=0
id2=0
function object:SetKey(key,value)
	if key=='tipofx' then --overrides color setting
		n2 = n.."_"..value
		object.model:SetKey("name",n2)
	end

	return 1
end


function object:Update()

	if debug==1 and mesh==nil then
		mesh=LoadModel("abstract::pista1_models_triggers_trigger3_trigger3mesh.gmf",model)
		model:SetShadowMode(0,1)
		mesh:SetKey("name",model:GetKey("name"))
	elseif debug == 0 and mesh ~= nil then 
		mesh:Free()
		mesh=nil
	end

	if(id2==0) then
		n=object.model:GetKey("name")
		n2 = n.."_"..object.model:GetKey("tipofx")

		n=object.model:GetKey("name")
		local fx=object.model:GetKey("tipofx")
		local n2=n.."_"..fx
		self.model:SetKey("name",n2)
		id2=1
	end
end


function object:Collision(entity,position,normal,force,speed)
	if chave==0 then
		Trigger()
		chave=1	
	end	
end


function object:Free(model)

	if mesh~=nil and debug==0 then	
		mesh:Free()
		mesh=nil
	end

end


end


Link to comment
Share on other sites

So, I have three trigger types:

1: to determine the progress of player in the scene.

2: THIS of my example, that is to activate some fx, like audio fx, post process etc...

3: a fence to limit the car in the road, when the car over this trigger, he is brought back to road.

 

In the car player script have a function Collide, when it collides with some trigger, is sent a menssage to c++ code(ReceiveMessage()) with the name of the trigger collided. For this, the naming convention. If it collided in the trigger type 3 for sample, is sent this message: "trigger3_4", so, the car will positioned in the last trigger1 that has been collided.

 

In the case of Trigger2, in the second number("trigger2_x_y"), the "y", is the fx(if 1:sound x, if 2: postfx x....etc), but the first number, the "x", is need be different, cause when the c++ receive the message with the name, is stored in a array, and "x" is the index of this array.

 

I tried explain better my problem, my english no help much...hehe

But if need, I try explain in other way..

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