"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
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

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

Post by Whatthefuck »

I want to give a shot at computing the lighting via a shader and was wondering if there's a way to get the colors of another pixel (in whatever direction) ?
User avatar
IceQB
Citizen
Posts: 67
Joined: Sat Nov 03, 2012 1:11 pm

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

Post by IceQB »

I have little question, how to make something work only for all numbers more from n?
For example:

Code: Select all

egg = {1,2.3.4,5}
n = 2

--egg 3,4 and 5 do /something/
User avatar
dusoft
Party member
Posts: 611
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

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

Post by dusoft »

IceQB wrote:I have little question, how to make something work only for all numbers more from n?
For example:

Code: Select all

egg = {1,2.3.4,5}
n = 2

--egg 3,4 and 5 do /something/

Code: Select all

if egg>2 then do...
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post by Robin »

Does n refer to index or value?

If the former, I'd use a numeric for loop:

Code: Select all

for i = n + 1, #egg do
 --- do something with egg[i]
end
otherwise it's a bit more complicated and it depends on a lot of things what the best way to go about it would be. (Probably either looking up the index with binary search, or building a reverse-lookup table beforehand.)
Help us help you: attach a .love.
User avatar
IceQB
Citizen
Posts: 67
Joined: Sat Nov 03, 2012 1:11 pm

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

Post by IceQB »

Thanks Robin, It is it what I was looking for.
lumlune
Prole
Posts: 12
Joined: Fri May 02, 2014 9:50 pm

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

Post by lumlune »

Question on optional args...

Code: Select all

wordbank = { }
function wordbank.init()
    wordbank.activate("goosanders", "optional flag")
end

function wordbank.activate(selection, ...)
    for idx, flag in ipairs(arg) do
        print(flag)
        -- e.g. "optional flag" prints here
    end
end

wordbank.init()
In its own script apart from LÖVE, this works. In my project it does not, printing this instead.

Code: Select all

%project path% love.exe
embedded boot.lua
What does LÖVE do differently?
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

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

Post by DaedalusYoung »

LÖVE uses LuaJIT, based on Lua 5.1, which doesn't use arg anymore.

Change this:

Code: Select all

for idx, flag in ipairs(arg) do
to this:

Code: Select all

for idx, flag in ipairs(...) do
[edit] See also this topic.
lumlune
Prole
Posts: 12
Joined: Fri May 02, 2014 9:50 pm

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

Post by lumlune »

Thank you. :awesome:
User avatar
Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

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

Post by Zilarrezko »

I'm putting my question here because I think I'm starting to clutter stuff up with my own topics.

So I've been working with 3D for the past few weeks. Mostly looking forward into concepts that I'll need in the future.

I've watch oysi's videos of course, but I wanted to walk myself forward without watching a tutorial and it seems I've hit a snag on something several times in the same spot. and of all things I believe it's either tables confusing me (A lot of tables within tables), or I'm doing something that lua can't do.

The problem is in my algorithm at line 44

and bonus points to whoever can get the model loader to recognize 3 vertex face from a 4 vertex face and run the proper one and not both.

PS. Very inefficient, yet functional shunting yard algorithm in there with reverse polish notation calculator too.
Attachments
_Workspace.love
Here's about 4 weeks of work and thought, have fun.
(387.36 KiB) Downloaded 160 times
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 »

DaedalusYoung wrote:

Code: Select all

for idx, flag in ipairs(...) do
You mean

Code: Select all

for idx, flag in ipairs({...}) do
or

Code: Select all

for idx, flag in ipairs{...} do
Locked

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests