Jump to content

Recommended Posts

Posted

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.

Posted

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

Let's build cool stuff and have fun. :)

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...