Jump to content

Collision table


thehankinator
 Share

Recommended Posts

Just for giggles... 

local window = Window:Create("Collision Type Response",0,0,400,300,Window.Titlebar+Window.Center)
local context = Context:Create(window)
local gui = GUI:Create(context)
local base = gui:GetBase()
base:SetScript("Scripts/GUI/Panel.lua")

function AddingItems(widget,table)
	for n=1,#table do
        widget:AddItem(table[n], n==1)
	end
end

types = {"PROP","SCENE","CHARACTER","TRIGGER","DEBRIS","PROJECTILE","LINEOFSIGHT"}
response = {{1,1,1,4,1,1,0},{1,1,1,0,0,1,1},{1,1,1,4,0,1,0},{4,0,4,0,0,0,0},
	{1,0,0,0,0,0,0},{1,1,1,0,0,0,0},{0,1,0,0,0,0,0}}

choicebox1 = Widget:ChoiceBox(20,120,170,60,base)
choicebox2 = Widget:ChoiceBox(190,60,170,60,base)
answer = Widget:Label("COLLIDE",190,120,170,60,base)
answer:SetString("align","Center")
answer:SetString("valign","Center")
answer:SetBool("border",true)
AddingItems(choicebox1,types)
AddingItems(choicebox2,types)

while not window:KeyHit(Key.Escape) do
	if window:Closed() then return false end
       
	while EventQueue:Peek() do
		local event = EventQueue:Wait()
		if event.source == choicebox1 or event.source == choicebox2 then
			local answervalue = response[choicebox1:GetSelectedItem()+1][choicebox2:GetSelectedItem()+1]
			if answervalue == 0 then answer:SetText("NONE") end
			if answervalue == 1 then answer:SetText("COLLIDE") end
			if answervalue == 4 then answer:SetText("TRIGGER") end
		end
	end
	context:Sync()
end

response.jpg.b425a93fc04ef6391e0abf671c1b527b.jpgresponse2.jpg.e2bbd22e4bb578a4fe3bbb8ca85707af.jpg

 

I never realized before writing this up that you have no way of getting the current response set for the collision types... for the life of me, I could have sworn it was possible - but no. If there was a Collision:GetResponse(type,type) to go with the undocumented Collision:SetResponse(type,type,response), this little example program would be more accurate/trustworthy. As it stands right now, you have to trust that the table that its based upon is correct and will never change.

 

  • Like 2

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

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