Help Making a Word table/list

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
User avatar
Qcode
Party member
Posts: 170
Joined: Tue Jan 10, 2012 1:35 am

Help Making a Word table/list

Post by Qcode »

Hi Everybody I'm pretty new to coding and I haven't got any experience in any format before. Basically the project I've been working on is a clone of the big red button game http://www.85qm.de/up/BigRedButton.swf I've been getting pretty far except after the first 2 messages I can't load any more messages in order, so I was wondering whether you could make a table or list of words that you could display in order. Here's the code I've already got it's also attached if you want to see how it works.

Code: Select all

function love.load()
  text = "DO NOT PUSH"
  screen_width = 1280
  screen_height = 800
  love.graphics.setMode(screen_width, screen_height)
  love.graphics.setBackgroundColor(255, 255, 255)
  rect = {
    x = 400,
    y = 204,
    width = 200,
    height = 200,
    }
end

function love.draw()
  love.graphics.setColor(255, 0, 0)
  love.graphics.rectangle("fill", rect.x, rect.y, rect.width, rect.height)
  love.graphics.setColor(0, 0, 0)
  love.graphics.print(text, 500, 600)
end

function love.mousepressed(x, y, button)
  if button == "l"
  and x > rect.x and x < rect.x + rect.width
  and y > rect.y and y < rect.y + rect.height
  then 
  	text = "*Ahem* Do NOT push" 
  end
end
Would be much appreciated if anybody could help
Thanks
Qcode
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Help Making a Word table/list

Post by ivan »

Hey, I remember the Red Button game from way back.
Anyway, try replacing the bottom of your code with something like:

Code: Select all

responses = { "*Ahem* Do NOT push", "I said don't do it!", "Noo!" }
current = 1
text = responses[current]

function love.mousepressed(x, y, button)
  if button == "l"
  and x > rect.x and x < rect.x + rect.width
  and y > rect.y and y < rect.y + rect.height
  then 
      if current < #responses then
          current = current + 1
          text = responses[current] 
      else
          -- the end
      end
  end
end
Hope this helps.
User avatar
Qcode
Party member
Posts: 170
Joined: Tue Jan 10, 2012 1:35 am

Re: Help Making a Word table/list

Post by Qcode »

Thanks man it helped tons the games fully working now I'll put a new download link up if you want to play it.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Help Making a Word table/list

Post by Nixola »

When you create a .love file, you have to put the main.lua in the 'root' of that file... Your file contains a folder that contains main.lua, and that's not right.
Also, your file is called 'Big red button.love.zip', so I had to rename it to make it run... what OS are you using?
Anyway, here is a .love file that works, as an example
Attachments
BigRedButton.love
(80.35 KiB) Downloaded 71 times
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Qcode
Party member
Posts: 170
Joined: Tue Jan 10, 2012 1:35 am

Re: Help Making a Word table/list

Post by Qcode »

Sorry about that I'm running Mac Os X for me simply renaming the folder .love worked on my computer. I'm assuming you're running windows or linux. Do you mind me just leaving your version up for people to download?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Help Making a Word table/list

Post by Nixola »

Surely I don't mind, why should I have uploaded that version?
I'm on Linux and I had Windows, so I can use both, but I didn't ever use a Mac, so I can't help you...
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 84 guests