TokOut's collection

With a mailto openurl call. Have a look at this thread:

https://codea.io/talk/discussion/1123/the-power-of-openurl

In the urn I had this bug (by using the code):

The picture does not seem to be uploaded

So, he said: UNEXPECTED SYMBOL NEAR ‘<\194>’ - so I could not open the project

Why don’t you try just learning basic Lua first?

@yojimbo2000, @ignatz, why Codea hasn’t got any reference for io, assert, type and many other tags, why isn’t there any reference?

@TokOut It takes time to write documentation and the developers can’t add new functions to Codea and write documentation for everything. A lot of information can be found in the Lua reference. If you want to write documentation for anything not in the reference, you can. If it’s written well enough, the developers could add it to the reference.

But @dave1707, I have found an documention for io.lines
It was something like for line in io.lines do and in the example he would draw many lines. But actually he didn’t Drawen anything. I thought something like not all tags where programmed for lua. For the tag typeits something like a nil tag. It is only highlighted. I will try to find something…

I found a documentation for assert: http://luatut.com/assert.html

Here is a documentation for io http://www.lua.org/pil/21.2.html , but I didn’t understand anything

I learned tables, what know?

meshes, vectors, then practise, practise, practise until you are good at programming all these things

@mentioned; This is my code, I was trying to understand why by touching DOWN, It will go UP

    if self.hold then
        if self.holdMode == UP then
            self.body:move(0, 3)
        elseif self.holdMode == DOWN then
            -- Problem point TO-FIX [He is going Up!]
            self.body:move(0, -3)
        elseif self.holdMode == RIGHT then
            self.body:move(3, 0)
        elseif self.holdMode == LEFT then
            self.body:move(-3, 0)
        end
    end

The class self.body:move has got x and y attributes so you have to reset -3 to go down but wether 3 or -3 is working

More code: The Body:move function:

function Body:move(x, y)
    if x == nil then x = 0 end
    if y == nil then y = 0 end
    self.x = self.x + x
    self.y = self.y + y
end

More code: The touched function


function World:touched(t)
    if t.state == BEGAN then
        if t.x>25 and t.x<75 and t.y>25 and t.y<75 then
            -- LEFT
            self.holdMode = LEFT
            self.hold = true
        elseif t.x<150 and t.x>100 and t.y<75 and t.y>25 then
            -- DOWN
            self.holdMode = DOWN
            self.hold = true
        elseif t.x>175 and t.x<225 and t.y>25 and t.y<75 then
            -- RIGHT
            self.holdMode = RIGHT
            self.hold = true
        elseif t.x>100 and t.x<150 and t.y>100 and t.y<150 then
            -- UP
            self.holdMode = UP
            self.hold = true
        end
    elseif t.state == ENDED then
        self.hold = false
    end
end

I want to present you the Simple Windows:
https://github.com/TokOut/The-Great-Work/tree/master/Win

I need help! I have trouble with window moving! Can someone say me the problem? When I move the window he got stuck at many points! But I need to have a move without stuck points, I removed the thing. Here is the main code:

Window = class()

function Window:init()
    self.drawing = true
    self.pos = vec2(0, 0)
    self.size = vec2(400, 250)
    self.logo = readImage("Cargo Bot:Codea Icon")
    self.action = function() print("The window was clicked!") end
    self.name = "Test Window"
    self.fontSize = 25
    self.closeable = true
    self.logo_size = 45
end

function Window:draw()
    if self.drawing then
        fill(255, 255, 255, 255)
        rect(self.pos.x, self.pos.y, self.size.x, self.size.y)
        stroke(0, 0, 0, 255)
        strokeWidth(2.5)
        line(self.pos.x, self.pos.y+self.size.y-50, self.pos.x+self.size.x, self.pos.y+self.size.y-50)
        sprite(self.logo, self.pos.x + 25, self.pos.y+self.size.y-25, self.logo_size, self.logo_size)
        fill(0, 0, 0, 255)
        font("AmericanTypewriter")
        fontSize(self.fontSize)
        text(self.name, self.pos.x+self.size.x/2, self.pos.y+self.size.y-25)
        if self.closeable then
            fill(255, 0, 0, 255)
            stroke(0, 255, 50, 255)
            strokeWidth(1)
            rect(self.pos.x+self.size.x-45, self.pos.y+self.size.y-45, 40, 40)
            fill(255, 255, 255, 255)
            font("AmericanTypewriter-Bold")
            fontSize(40)
            text("X", self.pos.x+self.size.x-25, self.pos.y+self.size.y-25)
        end
    end
end

function Window:touched(t)
    if t.state == BEGAN and self.drawing then
        if t.x>self.pos.x and t.x<self.pos.x+self.size.x and t.y>self.pos.y and t.y<self.pos.y+self.size.y then
            self.action()
            if self.closeable and t.x>self.pos.x+self.size.x-45 and t.x<self.pos.x+self.size.x-5 and t.y>self.pos.y+self.size.y-45 and t.y<self.pos.y+self.size.y-5 then
                print("Window Closed!")
                self.drawing = false
            end
        end
    end
end

Put this code in Window:touched(t). I don’t know why you can’t figure this out yourself.

    if t.state == MOVING and self.drawing then
        if t.x>self.pos.x and t.x<self.pos.x+self.size.x and t.y>self.pos.y and t.y<self.pos.y+self.size.y then
            self.pos=vec2(t.x-200,t.y-125)
        end
    end

Oh, I didn’t thought about vectors :frowning:

Hurray! I learned meshes!

@TokOut You said you didn’t think about vectors, yet the code you posted has vec2’s and you’re using them all over the place.

@dave1707 yes but I thought about t.x + 1 = self.pos.x + 1 which was bugging

I need help with meshes, I expected a rect:

function setup()
    m = mesh()
    m.vertices = {vec3(0, 0 , 0), vec3(WIDTH, 0, 0), vec3(WIDTH, HEIGHT, 0), vec3(0, HEIGHT, 0)}
    m.colors = {color(255, 255, 255, 255), color(223, 216, 145, 255), color(167, 255, 0, 255), color(239, 0, 255, 255)}
end

function draw()
    background(0, 0, 0, 255)
    m:draw()
end