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 .
Evrim
Prole
Posts: 20 Joined: Fri Apr 01, 2011 4:22 pm
Post
by Evrim » Tue Apr 05, 2011 2:16 pm
Code: Select all
function love.load()
timert = 4.0
statet = 0
story = "none"
end
function love.draw()
love.graphics.printf(story, 48, 144, 500, 'center')
end
story is a string, but it gives an error of being nil
vrld
Party member
Posts: 917 Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:
Post
by vrld » Tue Apr 05, 2011 2:30 pm
Works on my end... Maybe you have a typo somewhere?
You can find these kinds of errors with a
strict -module, like
strict.lua .
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.
hump |
HC |
SUIT |
moonshine
Evrim
Prole
Posts: 20 Joined: Fri Apr 01, 2011 4:22 pm
Post
by Evrim » Tue Apr 05, 2011 2:35 pm
the problem is not because of printf as if I add ' ' or " " to the ends of story, it just accepts it
but I need that for a timer that replaces the variable story
also is there a way that I can store all my variables in another lua file to keep love.load tidy?
EDIT: Ran the code, "variable story not declared"?
Last edited by
Evrim on Tue Apr 05, 2011 2:50 pm, edited 1 time in total.
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Tue Apr 05, 2011 2:48 pm
Could you give a .love of your code, please? Because this fragment just works.
Evrim
Prole
Posts: 20 Joined: Fri Apr 01, 2011 4:22 pm
Post
by Evrim » Tue Apr 05, 2011 2:55 pm
Loads of code commented in case I forget what I wrote
Also I need help with using vars.lua, can I use variables from there to main or other scripts?
EDIT: Image in your signature is pretty scary
Attachments
Taverno.love
(28.76 KiB) Downloaded 100 times
vrld
Party member
Posts: 917 Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:
Post
by vrld » Tue Apr 05, 2011 2:59 pm
It would have been nice if you gave an example on how to reach the error ('press s' would have sufficed)
love.load() will not call itself after you require story.lua, so you have to do it.
That is not a good way of handling gamestates.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.
hump |
HC |
SUIT |
moonshine
Evrim
Prole
Posts: 20 Joined: Fri Apr 01, 2011 4:22 pm
Post
by Evrim » Tue Apr 05, 2011 3:05 pm
How am I supposed to call it
love.load() at the line 1?
and if you mean "state" or "statet", they are just here because I'm new to Lua and general coding (would you suggest better ways to handle my variables and so?)
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Tue Apr 05, 2011 3:14 pm
You shouldn't redefine callbacks (not in this way at least). I suggested in another thread how to deal with this:
Make a table called states.
Put require "story" at the top of your main.lua file.
Put the code for the menu in another file and require that.
Code: Select all
states = {}
require("story")
require("menu")
function love.load()
Do this in love.draw:
Do the save for love.update and love.keypressed.
Change story.lua and menu.lua so that they do not override the love callbacks, but call them states.story.update and states.menu.update and so on.
Evrim
Prole
Posts: 20 Joined: Fri Apr 01, 2011 4:22 pm
Post
by Evrim » Tue Apr 05, 2011 6:08 pm
Tried a font, first it ran correctly without problems
But I added fontbig ( 32pt one, same font ) and now code does not recognises it?
Attachments
Innsront.love
(34.24 KiB) Downloaded 99 times
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Tue Apr 05, 2011 6:36 pm
I don't see a bigfont anywhere?
Plus, the file is named "font.TTF", not "font.ttf". That matters.
Plus, you misunderstood a couple of things about game state. I'd explain it more clearly, but I don't know how. Tell me, how much experience do you have with Lua?
Users browsing this forum: Ahrefs [Bot] , Bing [Bot] , Google [Bot] and 4 guests