Game Logic Issue

Hello all,
I’m fairly new to Lua and programming in general so bear with me.
I’m working on a tower defense game that uses tiles in order to create level maps. I created a toggle button to change the speed of the enemies from 1 block to 2 blocks. However, if the toggle is pressed when an enemy is 1.5 blocks from a turn, it will continue going straight through.

[lua]
local function getDirect( moveArray )
local speedVar
if speedAllowed == true then
speedVar = 2
else
speedVar = 1
end
local direc = moveArray
if direc == “right” then transDirecX = speedVar; transDirecY = 0; rotate = 0
elseif direc == “left” then transDirecX = -speedVar; transDirecY = 0; rotate = -180
elseif direc == “up” then transDirecX = 0; transDirecY = -speedVar; rotate = -90
elseif direc == “down” then transDirecX = 0; transDirecY = speedVar; rotate = 90; end
end
[/lua]
Is there some way I can fix this?
Thanks in advance for any discussion [import]uid: 221639 topic_id: 35745 reply_id: 335745[/import]

Hi Colt!

I notice from the code that that’s from our Tower Defense Template :slight_smile:

Could you drop me an email at “tech” at “tandgapps.co.uk” so I have your email? I’ll take a look at the template in an hour or two and see if there’s a way to easily change the speed like your doing and email you back.

Thanks,

Jamie Trinder

[import]uid: 69826 topic_id: 35745 reply_id: 142176[/import]

Hi Colt!

I notice from the code that that’s from our Tower Defense Template :slight_smile:

Could you drop me an email at “tech” at “tandgapps.co.uk” so I have your email? I’ll take a look at the template in an hour or two and see if there’s a way to easily change the speed like your doing and email you back.

Thanks,

Jamie Trinder

[import]uid: 69826 topic_id: 35745 reply_id: 142176[/import]