monday Posted May 4, 2015 Share Posted May 4, 2015 Hi, it looks like my function is not called when it needs to be. The script is a bit too long to paste for deep examination but here are the essential parts of it: function WhoAttacksFirst(_attackNumber) outputChatBox("--------reached WhoAttacksFirst stage 1") -- This information is displayed in game BoostMultiplier(1,1) outputChatBox("--------reached WhoAttacksFirst stage 2") -- This isn't (...) function BoostMultiplier(_number, _type) outputChatBox("--------reached BoostMultiplier stage 1") -- This isn't Is it because I should somehow initialise the function before calling it? Can it be the problem that I have another function named "Boost"? In case if it matters here's the whole function function BoostMultiplier(_number, _type) outputChatBox("--------reached BoostMultiplier stage") local m = 1 --multiplier if _type == 1 then if _number == -6 then m = 0.25 else if _number == -5 then m = 0.285 else if _number == -4 then m = 0.33 else if _number == -3 then m = 0.4 else if _number == -2 then m = 0.5 else if _number == -1 then m = 0.66 else if _number == 0 then m = 1 else if _number > 0 then m = 1 + (_number / 2) end end end end end end end end end if _type == 2 then if _number == -6 then m = 0.33 else if _number == -5 then m = 0.375 else if _number == -4 then m = 0.428 else if _number == -3 then m = 0.5 else if _number == -2 then m = 0.6 else if _number == -1 then m = 0.75 else if _number == 0 then m = 1 else if _number > 0 then m = 1 + (_number / 3) end end end end end end end end end if _type == 3 then _number = _number * -1 if _number == -6 then m = 0.33 else if _number == -5 then m = 0.375 else if _number == -4 then m = 0.428 else if _number == -3 then m = 0.5 else if _number == -2 then m = 0.6 else if _number == -1 then m = 0.75 else if _number == 0 then m = 1 else if _number > 0 then m = 1 + (_number / 3) end end end end end end end end end return m end Link to comment
xXMADEXx Posted May 4, 2015 Share Posted May 4, 2015 Are you sure that the WhoAttacksFirst function is being called? Also, check debugscript if you haven't already. Link to comment
monday Posted May 4, 2015 Author Share Posted May 4, 2015 I'm sure that the WhoAttacksFirst function is called because the message is displayed in the chat. It's a clientside script. Btw is there any limitation in terms of how many "if then else" statements you can use within each other? In other part of the same script there is like 20 of the following within each other: if then else if then else if then else end end end Edit: Fixed the problem, one "end" was missing in one place and there was one unwaned in another place. Thank you anyway If anyone has a similar problem, I found this tool very helpful: http://ideone.com/ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now