Gordon_G Posted June 4, 2017 Posted June 4, 2017 (edited) Hello, I've a little problem with the lua unpack function. This is my code : -- CLIENT local loginPanelPos = { ["globalPanel"] = {0,0,557,400} } function showLoginPanel( ) a = guiCreateStaticImage( unpack(loginPanelPos["globalPanel"]), "LOGIN.png", false ) end This is what I'm getting in /debugscript 3 Bad argument @guiCreateStaticImage [Expected number at argument 3, got boolean] Edited June 4, 2017 by Gordon_G
koragg Posted June 4, 2017 Posted June 4, 2017 For some reason it counts the "unpack(loginPanelPos["globalPanel"]" as one argument (doesn't unpack it) and that's why it gives the boolean error at arg3 (I think). Try this: -- CLIENT local loginPanelPos = { ["globalPanel"] = {0,0,557,400} } function showLoginPanel( ) a = guiCreateStaticImage(loginPanelPos["globalPanel"][1], loginPanelPos["globalPanel"][2], loginPanelPos["globalPanel"][3], loginPanelPos["globalPanel"][4], "LOGIN.png", false) end
Gordon_G Posted June 4, 2017 Author Posted June 4, 2017 (edited) I know this'll work but, I'll need to do this for all my guiFunc's I would like to be faster Edited June 4, 2017 by Gordon_G
Hale Posted June 4, 2017 Posted June 4, 2017 I had the same problem, tried to find a way but there is none I discovered, it just counts it as one argument.
Tails Posted June 4, 2017 Posted June 4, 2017 (edited) You can't use unpack like that if you have other arguments coming after it. local pos = {100, 200, 300} setElementPosition(localPlayer, unpack(pos)) -- works setElementPosition(localPlayer, unpack(pos), false) -- won't work Nothing can come behind unpack() So try one of these methods instead: local x, y, w, h = unpack(loginPanelPos["globalPanel"]) guiCreateStaticImage(x, y, w, h, "LOGIN.png", false) -- or local pos = loginPanelPos["globalPanel"] guiCreateStaticImage(pos[1], pos[2], pos[3], pos[4], "LOGIN.png", false) I recommend the last one if you're doing it in a render because it is faster, performance wise. Edited June 4, 2017 by Tails 1
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