#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# [Suggestion] x, y, z = translate()

Mod
Posts: 849

Or how to get the translation?

• Mod
Posts: 7,809

@TokOut I'm not sure how to respond to you. You just posted a 2000 line program (Minefield) that took a lot of time and experience to write. There are a lot of translate statements in that code, yet you're asking for an explanation on how to use translate. It seems that someone who can write a 2000 line program that works pretty well, should be able to read the build in reference or at least use Google for what you want.

• Mod
edited September 2016 Posts: 849

I am suggesting to add this. In the Reference it's said, that translate has arguments X, Y and optional Z, but it doesn't require anything.

Also don't forget to mention the filler system, ... * I am quiet *

• Mod
Posts: 7,809

• Mod
Posts: 5,396

If you want to get the current translation position, you can do it like this

``````local m=modelMatrix()
x,y,z = m[13],m[14],m[15]
``````

But if you want to get answers to your questions, you need to explain them a lot more clearly

• Mod
Posts: 849

The normal `translate`, how to return it's values

• Mod
Posts: 5,396

Use more words to explain

• Mod
edited September 2016 Posts: 849
``````fill(255, 255)
local d = fill() -- We return the fill color

translate(50, 50)
translate(-x, -y, -z) -- Come back to 0, 0, 0
``````
• Mod
Posts: 5,396

• Mod
Posts: 7,809

Put a pushMatrix() and a popMatrix() before and after the translate and the other code that uses it. Or you can do a translate(-50,-50). It's all explained in the reference for translate.

• Mod
Posts: 849
``````function setup()
translate(50, 60, 1000)
local m=modelMatrix()
for a, b in ipairs(m) do
print(a, b)
end
end

--[[
Cannot index a matrix outside range 1 to 16
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
Main:5: in function 'setup'
]]
``````

The commented is the error the m returns

• Mod
Posts: 5,396

Why are you using a for loop? ModelMatirx is not a table

For the second time, this is how to do it

``````local m=modelMatrix()
x,y,z = m[13],m[14],m[15]
``````
• Posts: 160

@TokOut modelMatrix() returns a matrix.

• Mod
Posts: 849

But what's a matrix?

• Mod
Posts: 7,809

Have you ever heard of Google. Try that.

• edited September 2016 Posts: 112

There is no reason to be rude. Instead of "Have you ever heard of Google. Try that" Try something like this ... "Hey man, I don't know the answer you are looking for, but I am sure you could find out by looking around a bit. Good luck!" .. but what do I know? I am only 13.

• Mod
Posts: 7,809

@EvanDavis I don't know how many times TokOut has been told to either read the Codea reference or to use Google when he has a question about something. We're not his personal reference. He can read the Codea reference or search Google just as easy as we can. Besides, the answers we give him might not be what he's looking for anyways. We're here to help when someone has a problem, not to do his reading for him. He's not only wasting our time, he's wasting his.

• Mod
Posts: 5,396

Dave is speaking the truth.

• Mod
Posts: 849

@dave1707, so let's go to C. Reference: I am sure there aren't 50% of the Lua tags, then because of your Lua edits, 25% sites in the web are lying how to develop with Codea. I am sure IO is a part of Lua which is not avaibel in Codea, but on many sites.

Going to search for Lua functions;
* Lua doesn't even have the setup, draw or touched functions

The Lua articles on the web are for the Windows Lua - that means that there won't be teached about touches. Then I am going to add today Codea Wikia, so people can create pages for every tag, maybe then smt will be easier

• Mod
Posts: 5,396

@Tokout, let's take this thread as an example. Before asking what's a matrix, you could have looked it up in Codea. I have also referred you numerous times to stuff I have written that explains matrices among other things. If you read those and then asked to clarify something, that's fine, you tried - but just asking "what is a matrix" is lazy.

All Dave is saying, is do a little research yourself before putting up basic questions. Why should we bother to answer if you can't be bothered to look?

• Mod
Posts: 7,809

@TokOut Actually, IO is available in Codea. You can create files, read file, remove files, etc. You say Lua doesn't have setup(), draw(), or touched(). That's correct, because Lua wasn't written to have those functions. A car doesn't have 50 seats like a bus to carry a hundred people, because a car isn't made to have 50 seats. Different thing are made because they have a different purpose. Lua was written to do what it does, and Codea was written to do something different. They may be similar, but they're not the same. Just because Codea doesn't have everything that Lua does doesn't mean it's supposed to.

• Posts: 112

I see your point Ignatz and Dave.