I’ve got a script i’m working on for the player, that “should”(if i did it right) spawn and delete a hitbox from the direction the player is facing. But i’m getting a random syntax error on line 30 about my if. I don’t really know why. If anyone thinks they might know why i’m getting this error please let me know what you think. I appreciate any help you guys can give me
Here’s the script for reference:
function init(self)
msg.post(".", "acquire_input_focus")
self.dir = vmath.vector3()
factory.delete(#Inspectionobject)
end
function final(self)
-- Add finalization code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function update(self, dt)
if vmath.length_sqr(self.dir) > 1 then
self.dir = vmath.normalize(self.dir)
end
local p = go.get_position()
go.set_position(p + self.dir * speed * dt)
-- Inspection
local hash("idle")
if self.dir.x > 0 and -- This one here's 30
hash("select") factory.create(#Inspectionobject[x.12.5, y.0.5, z.0,]) then
timer.delay(0.5, factory.delete(#Inspectionobject)
elseif self.dir.x < 0 and
hash("select") factory.create(#Inspectionobject[x.-12.5, y.0.5, z.0,]) then
timer.delay(0.5, factory.delete(#Inspectionobject)
elseif self.dir.y > 0 and
hash("select") factory.create(#Inspectionobject[x.0.5, y.12.5, z.0,]) then
timer.delay(0.5, factory.delete(#Inspectionobject)
elseif self.dir.y < 0 and
hash("select") factory.create(#Inspectionobject[x.-0.5, y.12.5, z.0,]) then
timer.delay(0.5, factory.delete(#Inspectionobject)
end
function fixed_update(self, dt)
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here. The game object this script is attached to
-- must have acquired input focus:
--
-- msg.post(".", "acquire_input_focus")
--
-- All mapped input bindings will be received. Mouse and touch input will
-- be received regardless of where on the screen it happened.
-- Learn more: https://defold.com/manuals/input/
-- Remove this function if not needed
end
function on_reload(self)
-- Add reload-handling code here
-- Learn more: https://defold.com/manuals/hot-reload/
-- Remove this function if not needed
end