Vaelek Posted February 4, 2015 Share Posted February 4, 2015 I've hit a road block that I believe is a bug in Math:Max.. This is in the beta I started a new project and used the following bare bones code in a pivot to test/reproduce it Script.MyFont = Font:Load("Fonts/Arial.ttf", 12) function Script:Start() local FontWidth1 local FontWidth2 local FontWidth3 FontWidth1 = Math:Max(self.MyFont:GetTextWidth("A string"), 1) FontWidth2 = Math:Max(1, FontWidth1) FontWidth3 = Math:Max(1, self.MyFont:GetTextWidth("A string")) end The last line throws error in function 'Max'.; argument #4 is 'string'; '[no object]' expected. There is no argument #4.. This seems to happen whenever the 2nd argument is a call to GetTextWidth. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 4, 2015 Share Posted February 4, 2015 This is a known issue Lua has. Basically, it can't parse complicated functions inside function arguments. It's slightly annoying but I only come across it once in a great while. Here's the fixed code: Script.MyFont = Font:Load("Fonts/Arial.ttf", 12) function Script:Start() local FontWidth1 local FontWidth2 local FontWidth3 FontWidth1 = Math:Max(self.MyFont:GetTextWidth("A string"), 1) FontWidth2 = Math:Max(1, FontWidth1) FontWidth3 = self.MyFont:GetTextWidth("A string") FontWidth3 = Math:Max(1, FontWidth3) end Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Vaelek Posted February 4, 2015 Author Share Posted February 4, 2015 Sounds good Josh. That's basically how I'm working around it but wasn't aware it was an issue with Lua itself. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.