[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
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

[SOLVED!]

Post by Darlex »

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.
Hi! I wish you have an amazing day!
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: HELLLPPPP

Post by Nixola »

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
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

Re: HELLLPPPP

Post by Darlex »

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!!
Hi! I wish you have an amazing day!
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: [closed]

Post by Nixola »

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: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: [closed]

Post by Tjakka5 »

It's arguably better than "HELLLPPPP" :p
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

Re: [closed]

Post by Darlex »

Tjakka5 wrote: Tue Jul 17, 2018 5:43 pm It's arguably better than "HELLLPPPP" :p
y u p
Hi! I wish you have an amazing day!
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

Re: [closed]

Post by Darlex »

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
Hi! I wish you have an amazing day!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests