[SOLVED!]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Darlex
Prole
Posts: 41
Joined: Sun Sep 24, 2017 10:02 am
Contact:

[SOLVED!]

Post by Darlex » Tue Jul 17, 2018 3:25 pm

I found a strange error and I need help

Snapshot:
Image

Main.lua:

Code: Select all

function love.load()
	require("gutil")
end

function love.mousepressed(x,y)

end

function love.update(dt)

end

function love.draw()
	love.graphics.rectangle("fill",gutil.tile(0,0),gutil.tile(1,1)) --test
end
gutil.lua:

Code: Select all

gutil = {}
function gutil.tile(tix,tiy) --max 10
	h , w = love.graphics.getDimensions()
	hw = h - w
	he = hw / 2
	ta = w / 11
	t = ta * tix
	tt = t + he
	tn = ta * tiy
	return tt , tn
end

function gutil.getScale()
	h , w = love.graphics.getDimensions()
	ta = w / 11
	scale = ta / 16 --EXAMPLE
	return scale
end
NO HELP NEEDED
Last edited by Darlex on Wed Aug 08, 2018 10:33 pm, edited 2 times in total.
ERROR

User avatar
Nixola
Inner party member
Posts: 1935
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: HELLLPPPP

Post by Nixola » Tue Jul 17, 2018 3:36 pm

gutil.tile returns two values, but since it's followed by a comma Lua will only get the first value and discard the second one. You should do something like this:

Code: Select all

love.draw = function()
   local x, y = gutil.tile(0, 0)
   local w, h = gutil.tile(1, 1)
   love.graphics.rectangle("fill", x, y, w, h)
end
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
Darlex
Prole
Posts: 41
Joined: Sun Sep 24, 2017 10:02 am
Contact:

Re: HELLLPPPP

Post by Darlex » Tue Jul 17, 2018 4:03 pm

Nixola wrote:
Tue Jul 17, 2018 3:36 pm
gutil.tile returns two values, but since it's followed by a comma Lua will only get the first value and discard the second one. You should do something like this:

Code: Select all

love.draw = function()
   local x, y = gutil.tile(0, 0)
   local w, h = gutil.tile(1, 1)
   love.graphics.rectangle("fill", x, y, w, h)
end
Clever... I'm gonna try it

Edit: YEAH! IT WORKS!
THANKS!!
ERROR

User avatar
Nixola
Inner party member
Posts: 1935
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: [closed]

Post by Nixola » Tue Jul 17, 2018 4:31 pm

Please don't just rename the topic to "closed". Use a descriptive title and add something like "[SOLVED]" at the beginning or end, so people know what it is.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
Tjakka5
Party member
Posts: 235
Joined: Thu Dec 26, 2013 12:17 pm

Re: [closed]

Post by Tjakka5 » Tue Jul 17, 2018 5:43 pm

It's arguably better than "HELLLPPPP" :p
Check out my portfolio: http://tjakka5.sorunome.de/

User avatar
Darlex
Prole
Posts: 41
Joined: Sun Sep 24, 2017 10:02 am
Contact:

Re: [closed]

Post by Darlex » Wed Aug 08, 2018 10:33 pm

Tjakka5 wrote:
Tue Jul 17, 2018 5:43 pm
It's arguably better than "HELLLPPPP" :p
y u p
ERROR

User avatar
Darlex
Prole
Posts: 41
Joined: Sun Sep 24, 2017 10:02 am
Contact:

Re: [closed]

Post by Darlex » Wed Aug 08, 2018 10:34 pm

Nixola wrote:
Tue Jul 17, 2018 4:31 pm
Please don't just rename the topic to "closed". Use a descriptive title and add something like "[SOLVED]" at the beginning or end, so people know what it is.
Oh.. Sorry
ERROR

Post Reply

Who is online

Users browsing this forum: master both and 9 guests