Jump to content

trigger problem


dennis
 Share

Recommended Posts

Hello all,

 

Today I followed one of aggror's tutorials on using triggers and events.

 

I tried to make a light that actually could flick on and off.

I wrote one, that didn't work.

so I wrote one exactly as his and that even didn't work,,,

Why isn't it working for me?

 

I use this code for the switch:

 

require("scripts/class")

local class=CreateClass(...)



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



function object:Update()
                     if KeyHit(KEY_E) ==1 then
                            for n = 0,7 do
                                 target = self.model:GetTarget(n)
                                       if target ~= nil then
                                            target:SendMessage("trigger_light", self.model,0)
                                        end
                                 end
                             end
                      end
end

 

for my light I'll spare the pre-written code for u and just go on to trigger part

 

 

function object:ReceiveMessage(message, delay)
       if message == "trigger_light" then


        if self.active == 1 then

                --hide the light
                 object.light:Hide()
                 self.active = 0

         elseif self.active == 0 then

                 --show the light
                 object.light:Show()
                 self.active = 1
           end
end
end

 

Why isn't this working?

Link to comment
Share on other sites

Yes I did. But i kinda solved it. But now it's only responding when i push the E key while pointing at the switch at the very bottom corner at the sides. Why is this so? Now i have the trigger working but the model or something is acting strange

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