Page 61 of 91

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

Posted: Mon Apr 04, 2016 6:50 pm
by Davidobot
Jarodeno93 wrote:I've been playing a game that uses love2d and it was running fine until recently. Now the game can only run when my laptop is plugged into my tv through an hdmi cable. Without it double clicking on the .exe/trying to run it results in nothing happening. Any idea on what could cause this and how to fix this?
Check if your display is set as your primary screen. LOVE could be starting on the primary monitor, which is set to your HDMI output and so doesn't show up on your main display,

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

Posted: Sun Apr 10, 2016 7:36 pm
by TheMeq
Can someone make me a function that posts to a PHP script and returns the result?

I have this that I found on a Lua forum, but I can't get it working.

Code: Select all

local http = require "socket.http"
local ltn12 = require "ltn12"

function postForm(url, body)
    local sink, responseData = ltn12.sink.table()
    local responseCode, statusCode, headers, statusLine = http.request {
        url = url,
        method = "POST",
        headers = {
            ["Content-Type"] = "application/x-www-form-urlencoded",
            ["Content-Length"] = #body -- this header might not be necessary
        },
        source = ltn12.source.string(body),
        sink = sink        
    }
    return table.concat(responseData), responseCode
end

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

Posted: Mon Apr 11, 2016 1:07 am
by pgimeno
Works for me.

PHP:

Code: Select all

<?php
  foreach ($_POST as $k => $v)
  {
    echo "$k = $v\n";
  }
 
Lua (added after your code):

Code: Select all

local s = postForm('http://www.formauri.es/personal/pgimeno/temp/ping.php',
                   'data1=first&data2=second')

print(s)

function love.draw()
  love.graphics.printf(s, 0, 0, 800)
end
Output:

Code: Select all

data1 = first
data2 = second

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

Posted: Mon Apr 11, 2016 12:17 pm
by TheMeq
Ah, I must have been doing it wrong xD

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

Posted: Thu Apr 14, 2016 9:13 pm
by pgimeno
Is the data passed to [wiki]love.image.newImageData[/wiki](w, h, data) always RGBA pixels, left-to-right, top-to-bottom? If not, how do I find what data does it expect?

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

Posted: Thu Apr 14, 2016 9:53 pm
by slime
It is.

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

Posted: Fri Apr 15, 2016 3:01 pm
by toolebox
Hey guys, any chance you could explain to me what the z and w values of the vec4 vertex_position in the vertex shader are for and if there is any way i can utilise them? Working on a small-scale 3d thing for a project (switching between 2d topdown and 3d in realtime), and I believe I can implement it in pure Love2D quite efficiently. cheers.

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

Posted: Sun Apr 17, 2016 4:14 am
by Ctastic
So i'm doing some basic drawing for a little project i'm working on, and in the draw function i'm drawing rectangles and text and then drawing an image. When I draw the sprite, it is being filled by the color I last set to draw with. Looking at the documentation it seems that there used to be a function "setColorMode" I could use in order to set the way images (sprites) were affected by "setColor" but it was removed for 9.0 and I can't figure out how to do it now!

Help!

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

Posted: Sun Apr 17, 2016 4:32 am
by Vimm
why can't you use tables as values for setColor? lets say I make a variable called r and in setColor I do

Code: Select all

love.graphics.setColor(r, 255,255)
whatever I set r to produces the result you would think, but lets say i make a table called colors and do something like

Code: Select all

colors = {}
colors.r = 255
colors.g = 255
colors.b = 255

love.graphics.setColor(colors.r, colors.g, colors.b)
why doesnt this work? the error says its expecting an integer and its getting a nil value, I'm just curious why I can't use tables.

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

Posted: Sun Apr 17, 2016 5:35 am
by Doctory
Vimm wrote:-snip-
You can use tables. Theres probably something wrong with your code.