Okay, so this is what I want to create:
I am trying to make a recreational application (hard to consider it a game) and what it does is to use this giant dictionary of english to dragon language words.
You type in a sentence, and then you press the button "Translate". The game tries to convert as many english words available for translation into dragon language and prints it right below. The words that cannot be translated are left as the original words.
Right now, I have the part where you can type in anything (only letters + numbers), and I am just trying to get the button to at least print something so I will know that I can move on to the translation part of the script. By the way, I am pretty mediocre or even lower about pure lua coding and love lua. I've only learned my knowledge on lua from a game called ROBLOX.
So my help here is pretty much to make the button work and for another question: is there a possible way where I can have a function from another script be usable in the main.lua? You will see my DragonLanguageTranslator.lua in my file. (Not done translating all the possible words, but it is still usable)
I see that I have some errors in this script, so I was wondering if anyone can help me. I am pretty sure that you will try to see what I mean from the coding. I have some notes for you in the coding.
And thank you so very much if you are willing to help me.
Help: Dragon Language Translator - buttons and stuff
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Help: Dragon Language Translator - buttons and stuff
- Attachments
-
- DragonLanuageTranslatorAppHelp.love
- (4.94 KiB) Downloaded 236 times
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Help: Dragon Language Translator - buttons and stuff
Welcome around.
You're trying to compare a string and boolean. Lua assumes this is always false.
See this and this for more info.
Change this.
Plus, you're drawing the confirmation message "Hello" out of the screen.
Move its y position to a less lower value.
You're trying to compare a string and boolean. Lua assumes this is always false.
See this and this for more info.
Change this.
Code: Select all
local on = false
--instead of local on="false"
Move its y position to a less lower value.
Re: Help: Dragon Language Translator - buttons and stuff
*Smacks myself in the face for absent-minding-ly adding the quotes for the word false*
Wow, I didn't even catch myself do that. How much should I make the y value lower? And you mean the " love.graphics.print("hello",10,400) " part?
Wow, I didn't even catch myself do that. How much should I make the y value lower? And you mean the " love.graphics.print("hello",10,400) " part?
Re: Help: Dragon Language Translator - buttons and stuff
Nevermind. I fixed it. Thank you.
And another thing:
Is it possible for me to use that DragonLanguageTranslator.lua function in the main.lua, or do I have to copy and paste the whole function in that script in put it in the main.lua?
And another thing:
Is it possible for me to use that DragonLanguageTranslator.lua function in the main.lua, or do I have to copy and paste the whole function in that script in put it in the main.lua?
Re: Help: Dragon Language Translator - buttons and stuff
Sure is! Assuming main.lua and DragonLanguageTranslator.lua are in the same folder, putting...Yolo wrote:Is it possible for me to use that DragonLanguageTranslator.lua function in the main.lua, or do I have to copy and paste the whole function in that script in put it in the main.lua?
Code: Select all
require "DragonLanguageTranslator"
(Note that there is no .lua at the end of the file name)
Re: Help: Dragon Language Translator - buttons and stuff
Great!Santos wrote:Sure is! Assuming main.lua and DragonLanguageTranslator.lua are in the same folder, putting...Yolo wrote:Is it possible for me to use that DragonLanguageTranslator.lua function in the main.lua, or do I have to copy and paste the whole function in that script in put it in the main.lua?
...at the top of main.lua (or anywhere before you use what's in DragonLanguageTranslator.lua) should work.Code: Select all
require "DragonLanguageTranslator"
(Note that there is no .lua at the end of the file name)
So if I state a function that is inside the DragonLanguageTranslator in my main.lua, it will work?
Re: Help: Dragon Language Translator - buttons and stuff
Sure will!Yolo wrote:So if I state a function that is inside the DragonLanguageTranslator in my main.lua, it will work?
To clarify, there is no ".lua" at the end of a file name when using "require", but there is in the filesystem. So name your file DragonLanguageTranslator.lua, and require it in main.lua with require "DragonLanguageTranslator"
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Help: Dragon Language Translator - buttons and stuff
Yolo wrote: Is it possible for me to use that DragonLanguageTranslator.lua function in the main.lua, or do I have to copy and paste the whole function in that script in put it in the main.lua?
Indeed, it will.Yolo wrote: So if I state a function that is inside the DragonLanguageTranslator in my main.lua, it will work?
As I like providing links, learn more about require here.
Anytime you use require, it loads the designed file, adding every variables defined inside in the global environment.
So that they can be accessible everywhere, even inside the file where you make the call.
But, use it with caution, and pay attention to scoping. I don't like messing with globals, as it's commonly mentionned as a bad programming behaviour...
Who is online
Users browsing this forum: No registered users and 6 guests