"Questions that don't deserve their own thread" thread

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.
Locked
Skeletonxf
Citizen
Posts: 87
Joined: Tue Dec 30, 2014 6:07 pm

Re: "Questions that don't deserve their own thread" thread

Post by Skeletonxf »

Thanks for the links it's got me much further along and lua rocks seems to be able to install some rocks now but still not love-release

I do intend to get a Linux system up and running but I need a hard drive to put it on first. :/

Anyway so I added a load of things to the PATH so command prompt can find them and lua rocks then gave this error on installing one of love-release's dependencies

Code: Select all

Installing http://luarocks.org/repositories/rocks/love-release-2.0.3-1.rockspec.
..
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc

Missing dependencies for love-release:
middleclass
lua-zip

SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc

Error: Failed installing dependency: http://luarocks.org/repositories/rocks/midd
leclass-4.1-0.rockspec - Error fetching file: Failed downloading https://github.
com/kikito/middleclass/archive/v4.1.0.tar.gz
I've been able to reduce that missing dependencies list down to just these two but I'm not sure what I'm meant to do to deal with the middleclass error. My browser can download that file from the url with no issues.
BathtubAmbassador
Prole
Posts: 7
Joined: Thu Jul 07, 2016 8:11 pm

Re: "Questions that don't deserve their own thread" thread

Post by BathtubAmbassador »

I'm having an issue with kikito's tween.lua library where the tween movement never finishes, it only slows down to a crawl. This is a problem because this tween controls a sprite, and when the tween finishes I want the sprite to move somewhere else. But it never reaches the end state. The relevant part of my code:

Code: Select all

			if soldier.moving == true then
				if soldier.inc == 1 then
					soldier.moveTween = tween.new(0.1,soldier,{x = soldier.movePath[soldier.inc].location.x * 16, y = soldier.movePath[soldier.inc].location.y * 16},'linear')
				end

				local finished = soldier.moveTween:update(dt)
				print(finished)

				if finished then
					print("new node")
					soldier.inc = soldier.inc + 1
					soldier.moveTween = tween.new(0.1,soldier,{x = soldier.movePath[soldier.inc].location.x * 16, y = soldier.movePath[soldier.inc].location.y * 16},'linear')
				end

				if soldier.inc >= table.getn(soldier.movePath) then
					soldier.moving = false
				end

			else
				soldier.inc = 1
				soldier.moving = false
			end
By the way, the second print() statement never activates, which tells me that "finished" never is true.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: "Questions that don't deserve their own thread" thread

Post by pgimeno »

Are you sure that soldier.moving stays true all the time, so that soldier.moveTween:update(dt) gets called? Does it print an endless series of 'false'?
BathtubAmbassador
Prole
Posts: 7
Joined: Thu Jul 07, 2016 8:11 pm

Re: "Questions that don't deserve their own thread" thread

Post by BathtubAmbassador »

Looks like soldier.moving is constantly true. And yeah, print(finished) just prints "false" over and over.

EDIT: Further fiddling reveals that the duration of the tween is never met, because after a while the internal timer of the tween just becomes whatever the current delta time is, and not 0 like it's supposed to. I'm really not sure where to go with this info cause it looks like my code is fine but the tween library isn't running correctly. I'm using Lua 5.2.3 and LOVE 10.1, if that helps.
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: "Questions that don't deserve their own thread" thread

Post by airstruck »

BathtubAmbassador wrote: I'm really not sure where to go with this info cause it looks like my code is fine but the tween library isn't running correctly.
Try a different tween library? I think they're all pretty similar though, but at least you'll know where the issue is if the problem persists.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by bartbes »

BathtubAmbassador wrote: EDIT: Further fiddling reveals that the duration of the tween is never met, because after a while the internal timer of the tween just becomes whatever the current delta time is, and not 0 like it's supposed to.
I checked, and it seems kikito's tween.lua counts up, not down, suggesting a different problem...

Code: Select all

			if soldier.moving == true then
				if soldier.inc == 1 then
					soldier.moveTween = tween.new(0.1,soldier,{x = soldier.movePath[soldier.inc].location.x * 16, y = soldier.movePath[soldier.inc].location.y * 16},'linear')
				end
... which may be the above piece of code? I haven't thoroughly read your code, but nothing here suggests soldier.inc changes, so if it's 1 and stays 1, you create a new tween every frame.
BathtubAmbassador
Prole
Posts: 7
Joined: Thu Jul 07, 2016 8:11 pm

Re: "Questions that don't deserve their own thread" thread

Post by BathtubAmbassador »

bartbes wrote:... so if it's 1 and stays 1, you create a new tween every frame.
That was indeed the issue. I rewrote it so that .inc instead starts at 0 for all soldiers, and if .inc == 0 then it instantly increments .inc up to 1 and then creates the first tween. It works now, thanks!

By the way, I tried flux in the meantime and it was weird because flux tweens can only run functions when they finish, so i had this weird recursive function calling going on that didn't exit properly. Coding is hard.
BathtubAmbassador
Prole
Posts: 7
Joined: Thu Jul 07, 2016 8:11 pm

Re: "Questions that don't deserve their own thread" thread

Post by BathtubAmbassador »

Alright, I'm back with another really weird problem.

I'm trying to optimize my fog-of-war system in my demo program. The player character currently has a 25x25 box within which they can see. To prevent to player from seeing around corners I use a raycast projected in many directions around the player to determine what is visible and what is not. A ray is incapable of returning duplicate coordinates, but multiple rays can, so naturally before I go to draw what tiles are visible or not I want to get rid of duplicates to prevent slowdown. So I implemented my table.sort and make a second list supposedly without duplicates. Vispass is the list with duplicates, and self.player.visible is the clean list.

Code: Select all

function has_val(tabl,var)							
	for i, valu in ipairs(tabl) do 					
		if valu.x == var.x and valu.y == var.y then
			return true
		end
	end

	return false									
end

-- later...

table.sort(vispass, function(a,b) if a.y == b.y then return a.x < b.x end return a.y < b.y end)

for t, tile in ipairs(vispass) do
	if has_val(self.player.visible,tile) == false then
		table.insert(self.player.visible, tile)
	end
end
			
print(table.getn(vispass),table.getn(self.player.visible))
Now, given that 25*25 = 625, the self.player.visible list shouldn't contain more items than that, BUT, sometimes self.player.visible contains more than 2,000 items? The screencap attached is what gets output by that print statement.

I want my game to run silky smooth but iterating over lists 2000 items long makes it...not smooth.
Attachments
whygodwhy.png
whygodwhy.png (37.43 KiB) Viewed 3445 times
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by unixfreak »

Hi, i have been trying to find a way to calculate the minimum height of a rectangle depending on the height of a wrapped text string. Basically, i am trying to make a dynamically sized message box which holds varying text.

How can i get a pixel count for the height of the wrapped text?

Here is a screenshot showing what i am trying to achieve, box on the left is how things should look, so that the box grows with the text in height. Image

I can wrap the text according to the width of the rectangle using love.graphics.printf(), i've tried looking at https://love2d.org/wiki/Font:getWrap , although this only gives me the number of lines the text wraps into.

I hope that made sense :awesome:
Last edited by unixfreak on Wed Jul 13, 2016 2:46 pm, edited 1 time in total.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by undef »

Use [wiki]Font:getHeight[/wiki]*#wrappedText.
wrappedText ist the second return value of Font:getWrap.
twitter | steam | indieDB

Check out quadrant on Steam!
Locked

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 6 guests