text madness

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
Seth144k
Prole
Posts: 29
Joined: Wed Jan 19, 2022 8:45 pm

text madness

Post by Seth144k »

so i was working on an rpg prototype and decided hey, lets interact with this object! so the basic idea is that I want the object (the square at the end of the thing) to display some text which i got working. the problem is when I want to change that text. I did a circular query around the player and it doesnt seem to do anything. I want the player to lose all control of the player and then diffrent text to appear, and then regain control, and if you walk away then the text should go away. please help as i find making text very difficult in love2d
Attachments
main.love
(49.94 KiB) Downloaded 60 times
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: text madness

Post by ReFreezed »

It's a bit unclear what you want. What text should be displayed? I'm assuming we're talking about the code in interactable.lua. Do you want each 'interactable' object to display different a text? You could add a text field to 'self' in interactable:load() and draw the text with love.graphics.print(self.text) in interactable:draw().

Code: Select all

function interactable:load()
    self.text = "foobar" -- You can use different texts for different interactables.
    -- ...
end

function interactable:draw()
    -- ...
    love.graphics.print(self.text)
    -- ...
end
The interactable's text could also be an argument for the interactable:load() function.

Code: Select all

function interactable:load(text)
    self.text = text
    -- ...
end
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: text madness

Post by Andlac028 »

Something like this?
main.love
(50.22 KiB) Downloaded 61 times
If you reach that object, you can not move, and the keypresses are used to display next message. When all messages were displayed, control is gained to player again.

Basically I added texts and textsShown to interactable:load, then handled text draw in interactable:draw and added interactable:keypressed which is called in new love.keypressed which switches texts (see attached code)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 153 guests