Page 64 of 91
Re: "Questions that don't deserve their own thread" thread
Posted: Sat Jul 09, 2016 11:28 am
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Jul 11, 2016 4:38 am
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Jul 11, 2016 8:15 am
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'?
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Jul 11, 2016 4:32 pm
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Jul 11, 2016 6:32 pm
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Jul 11, 2016 6:41 pm
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Mon Jul 11, 2016 6:56 pm
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Tue Jul 12, 2016 2:18 am
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Wed Jul 13, 2016 2:40 pm
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.
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
Re: "Questions that don't deserve their own thread" thread
Posted: Wed Jul 13, 2016 2:46 pm
by undef
Use [wiki]Font:getHeight[/wiki]*#wrappedText.
wrappedText ist the second return value of Font:getWrap.