I tried to code something using a script entity, but failed.
I also searched for a way for the script to check if the item is present in that tile, but failed, again.
Could anyone please help me?
Code: Select all
function isThere(self)
local isOk = false
for ent in self.go.map:entitiesAt(self.go.x,self.go.y) do
if (ent.name == "blue_gem") then
isOk = true
end
end
if (isOk) then
-- do whatever you want
self:disable() -- one shot only if the item is ok.
end
endCode: Select all
defineObject{
name = "pressure_plate_surface",
baseObject = "base_pressure_plate",
components = {
{
class = "Model",
model = "assets/models/env/dungeon_pressure_plate.fbx",
staticShadow = true,
},
{
class = "Animation",
animations = {
activate = "assets/animations/env/dungeon_pressure_plate_down.fbx",
deactivate = "assets/animations/env/dungeon_pressure_plate_up.fbx",
},
},
{
class = "Occluder",
model = "assets/models/env/dungeon_floor_01_occluder.fbx",
},
{
class = "Surface",
offset = vec(0, 0.1, 0),
size = vec(2, 2),
--debugDraw = true,
},
{
class = "Clickable",
offset = vec(0, 0.0, 0),
size = vec(2, 0.0, 2),
maxDistance = 1,
--debugDraw = true,
},
},
}Code: Select all
function drop(self)
local object = false
for _,ent in self.go.surface:contents() do
object = true
if (ent.go.name == "blue_gem") then
-- do what you want
end
end
if (object) then
self.go.animation:play("activate") -- lower the plate
playSound("pressure_plate_pressed")
end
end
Code: Select all
function take(self)
local none = true
for _,ent in self.go.surface:contents() do
none = false
end
if (none) then
self.go.animation:play("deactivate") -- raise the plate
playSound("pressure_plate_released")
end
endI agree...zimberzimber wrote:I think I'll simply add a small piece of instructions concerning the inconvenience.
Thank you anyways!