Ok thanks
Can I use this to learn and make games?
@Gamerage13 As far as I’m concerned, anything posted on this forum can be used by anyone. It would be nice to acknowledge if you use someone else’s code though.
A loot of this is my experience cause JavaScript and lua are
Almost the same
And you helped me with one thing and I learned how to write an if and else statement
Thanks to the forum and other people.
And yes I’m using a little bit from some examples in the codea app
I’m only using it now beacuse I’m still learning lua.
And I et some code frome the forum
Cause I’m a beginner in lua
And much of things I Learned am I using in other projects
@Gamerage13 It good that you’re learning. A lot of people give up because they say it’s too hard. Don’t think that you ask too many questions because that’s what a lot of us are here for, to help others. Anytime you have a question, just ask. Just make sure you include enough information. The more you include, the easier it is to answer.
@Gamerage13 - I’ve written a lot of stuff that may help you, summarised here
http://coolcodea.wordpress.com/2013/06/19/index-of-posts/
I recommend you start with the Lua and Codea ebooks.
Thanks for helping me!
And here is the itranslater beta
Its not the best but i work
If you write something the words will be displayer on the screen
I dont want that i want the answer to be displayed instead
-- itranslate beta
function setup()
print("please dont write with big words like A. everything you translate will be translated to swedish")
parameter.text("translate")
parameter.action("answer",answer)
end
function answer()
if translate=="hello" then
print("hej. on swedish")
translate=""
elseif translate=="goodbye" then
print("hejdå. on swedish")
else
if translate=="thanks" then
print("tack!. on swedish")
translate""
elseif translate=="what are you doing?" then
print("vad gör du?. on swedish")
else
print("i dont know what you want to translate")
end
end
end
function draw()
background(73, 168, 53, 255)
fill(255, 255, 255, 255)
fontSize(60)
font("AmericanTypewriter")
textWrapWidth(WIDTH) -- i want the output/translated on the screen instead of that im writting
sprite("Documents:CodeaCommunityClientBtn",WIDTH/2, HEIGHT/2)
text(translate, WIDTH/2, HEIGHT - 160)
end
@Gamerage13 I took the code I posted for someone else on the forum and modified it a little to do what you were doing. Try this and if you like it, make whatever changes you want.
displayMode(FULLSCREEN)
function setup()
createTable()
rectMode(CORNER)
textMode(CORNER)
showKeyboard()
str="Enter a word or phrase, then press return."
textWrapWidth(480)
end
function draw()
background(80,80,80)
fill(0)
noStroke()
rect(220,HEIGHT/2+110,500,100)
fill(255)
stroke(255,0,0)
strokeWidth(5)
rect(200,HEIGHT/2+130,500,100)
if keyboardBuffer()~=nil and keyboardBuffer()~="" then
str=keyboardBuffer()
end
fill(255,0,0)
text(str,210,HEIGHT/2+140)
if rtn then
rtn=false
translate()
hideKeyboard()
showKeyboard()
end
end
function translate()
for z=1,#tab1 do
if str==tab1[z] then
str=tab2[z]
return
end
end
str="I dont know what you want to translate."
end
function keyboard(k)
if k==RETURN then
rtn=true
end
end
function touched(t)
if t.state == ENDED then
showKeyboard()
end
end
function createTable()
tab1={
"hello",
"goodbye",
"thanks",
"what are you doing?"}
tab2={
"hej. on swedish",
"hejdå. on swedish",
"tack!. on swedish",
"vad gör du?. on swedish"}
end
Side note: You don’t have to tell users they can’t use uppercase letters, you can just use string.lower.
Ok
@Gamerage13 - here is another way to do it
Put the words in a dictionary format so you can look them up
Here is a table of words
function createTable()
tab1={
["hello"]="hej",
["goodbye"]="hejdå",
["thanks"]="tack!",
["what are you doing?"]="vad gör du?"
}
end
and now it’s much quicker to look them up (when you have thousands of words, later on)
function translate()
--this line looks up the word in the table
--if it doesn't find it, str wil be nil, and the "or" part makes str = the error message
local str2=tab1[str] or "I don't know what you want to translate."
--put the result on two ines, English first, \
goes to the next line
str="English: " .. str .. "\
" .. "Swedish: " ..str2
end
This isn’t necessarily better than Dave1707’s solution. Although it’s faster to look up, it can’t translate the other way from Swedish to English, whereas Dave has two tables and can look up either one, so it can translate both ways.