I can't get anything to load

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
Xenafey
Prole
Posts: 1
Joined: Wed Dec 07, 2022 6:54 am

I can't get anything to load

Post by Xenafey »

Hello, I'm new to Lua and have been slowly learning it. I tried making a base for a card game I've been planning but I can't seem to get anything to run. I've rewritten it a bunch and nothing seems to show... I can't figure out why. All I get is a black screen instead of what I've written even the intro. Could someone explain what I might have done wrong? I would be most grateful if you could.
Attachments
Main.lua
the Main game file
(523 Bytes) Downloaded 31 times
Ross
Citizen
Posts: 97
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: I can't get anything to load

Post by Ross »

First off, you shouldn't capitalize your file name: "Main.lua". That won't work on some systems. Rename it to lowercase, "main.lua", to be sure.

Regarding the code, this is what I see in your main.lua:

Code: Select all

function showintro()
load = intro
print ("WIN AND FAIL CARD GAME WIN AND FAIL IS PLAYED IN THE FOLLOWING MANNER THE DEALER (THE GAME MASTER) DEALS TWO CARDS FACE UP YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING ON WHETHER OF NOT YOU FEEL THE CARD WILL HAVE A VALUE BETWEEN THE FIRST TWO. IF YOU DO NOT WANT TO BET INPUT A 0", 100, 100 )
end
local starting_cash = 100

local card_names = {[11] = "JACK", [12] = "QUEEN", [13] = "KING", [14] = "ACE"}
for i = 2, 10 do
  card_names = string.format(" %d", i)
end
The only code that would do anything visible is the print() statement, but that's inside the function definition for 'showintro', and that function is never called, so it makes sense that you would not see anything. (Correct indentation would make this much more obvious.)

If you put a print statement in love.load or outside any function definitions, then you will see it in the console.

If you want something to show in the game window, then you need to define a love.draw function and put call some drawing functions in it.

Possibly you are confusing the base lua function 'print()', which outputs text to the console, with 'love.graphics.print()', a Löve function that draws text to the screen (use it inside love.draw()).
User avatar
BrotSagtMist
Party member
Posts: 604
Joined: Fri Aug 06, 2021 10:30 pm

Re: I can't get anything to load

Post by BrotSagtMist »

This isnt lua but Löve.
If you follow lua tutorials then of course you will keep getting a black window as there is nothing in your code that produces any pixels (nor is called).
look at the wiki page, look at how the hello world is described there.
obey
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests