Thanks for this. But so far with the set up I have from using this script I can't get the keys to go into the socket. I have the keys set up with the trait "crystal_key". But I'm sure there is something I'm doing wrong
. Here is my set up on it. But because I use the chest component it must have a surface component in there somewhere or it doesn't work. Not sure if that effects the script in any way tho.
Code: Select all
defineObject{
name = "rc_puz_pedestal_01",
baseObject = "base_obstacle",
components = {
{
class = "Model",
model = "mod_assets/stotp_models/red_cave/env/rc_puz_pedestal_01.fbx",
staticShadow = true,
},
{
class = "Animation",
animations = {
open = "assets/animations/env/treasure_chest_open.fbx",
close = "assets/animations/env/treasure_chest_close.fbx",
},
onAnimationEvent = function(self, event)
if event == "open" then
playSound ("gen_body_motion")
self.go.controller:open()
elseif event == "close" then
playSound ("gen_body_motion")
self.go.controller:close()
end
end,
playOnInit = "close",
},
{
class = "Socket",
name = "socket_top_right",
offset = vec(-0.23, 0.98, 0.10),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 1 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_tr:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_tr:isEnabled() then self.go.click_tr:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_top_middle",
offset = vec(-0.02, 0.98, 0.10),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 2 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_tm:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_tm:isEnabled() then self.go.click_tm:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_top_left",
offset = vec(0.21, 0.98, 0.10),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 3 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_tl:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_tl:isEnabled() then self.go.click_tl:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_mid_left",
offset = vec(0.21, 0.88, 0.39),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 4 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_ml:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_ml:isEnabled() then self.go.click_ml:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_mid",
offset = vec(-0.02, 0.88, 0.39),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 5 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_m:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_m:isEnabled() then self.go.click_m:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_mid_right",
offset = vec(-0.23, 0.88, 0.39),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 6 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_mr:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_mr:isEnabled() then self.go.click_mr:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_bot_left",
offset = vec(0.21, 0.78, 0.69),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 7 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_bl:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_bl:isEnabled() then self.go.click_bl:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_bot_mid",
offset = vec(-0.02, 0.78, 0.69),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 8 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_bm:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_bm:isEnabled() then self.go.click_bm:enable() else return false end end,
debugDraw = false,
},
{
class = "Socket",
name = "socket_bot_right",
offset = vec(-0.23, 0.78, 0.69),
rotation = vec(-100, 0,0),
onAcceptItem = function(self,item)
if GameMode.g1_tempSurface == 9 then
GameMode.g1_tempSurface = nil
if self:count() == 0 and item:hasTrait("crystal_key") and not (item:hasTrait("yig_gem") or item:hasTrait("dm_gem") or item:hasTrait("gem")) then
return true
end
end
return false
end,
onInsertItem = function(self,item) self.go.click_br:disable() end,
onRemoveItem = function(self,item) if self:isEnabled() and self:count() == 0 and not self.go.click_br:isEnabled() then self.go.click_br:enable() else return false end end,
debugDraw = false,
},
{
class = "Clickable",
name = "click_tr",
offset = vec(-0.22, 0.98, 0.18),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 1 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_tm",
offset = vec(0, 0.98, 0.18),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 2 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_tl",
offset = vec(0.22, 0.98, 0.18),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 3 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_ml",
offset = vec(-0.22, 0.88, 0.47),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 4 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_m",
offset = vec(0, 0.88, 0.47),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 5 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_mr",
offset = vec(0.22, 0.88, 0.47),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 6 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_bl",
offset = vec(-0.22, 0.78, 0.76),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 7 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_bm",
offset = vec(0, 0.78, 0.76),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 8 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "click_br",
offset = vec(0.22, 0.78, 0.76),
size = vec(0.12, 0.12, 0.12),
onClick = function(self)
if getMouseItem() then GameMode.g1_tempSurface = 9 end
end,
debugDraw = true,
},
{
class = "Clickable",
name = "chest_move",
offset = vec(0,0.4,0.45),
size = vec(0.9, 0.4, 0.9),
maxDistance = 1,
debugDraw = true,
},
{
class = "Chest",
},
{
class = "Surface",
offset = vec(0,1,0),
size = vec(0,0,0),
debugDraw = true,
onAcceptItem = function(self, item)
return (item.go.name == "island_map") and self:count() == 0
end,
debugDraw = false,
},
{
class = "Controller",
onOpen = function(self)
self.go.controller:activate()
end,
onClose = function(self)
self.go.controller:deactivate()
end,
},
},
editorIcon = 8,
tags = { "shadowgate", "red cave", "vanblam", "puzzel" },
}