TokOut's collection

You don’t understand meshes, if you think 4 vertices is ok. You need 6.

I think you should go back and read some more about them

K

I made a scroll for people who needs:

function AllDiscussions:touched(t)
    -- Action List
    self.testdiscussion:touched(t)
    -- Main Action
    if t.state == ENDED then
        self.touch = false
        local currentY = 0
    else
        if t.y < 650 then
            self.touch = true
            local currentY = t.y
            translate(0, currentY)
            if currentY > self.y then
                self.y = self.y + t.deltaY/2
            else
                self.y = self.y - t.deltaY/2
            end
            translate(0, -currentY)
        end
    end
end

A forest background for people who needs:

displayMode(FULLSCREEN)

function setup()
    z = 50
    tab = {}
end

function draw()
    background(0, 0, 0, 255)
    for x = 0.6, 25 do
        tab[x] = {}
        for y = 0.5, 15 do
            -- First triangle
            stroke(0, 255, 0, 255)
            strokeWidth(5)
            line(x * z, y * z, x * z + 10, y * z)
            line(x * z, y * z, x * z + 5, y * z + 5)
            line(x * z + 5, y * z + 5, x * z + 10, y * z)
            -- Second triangle
            v = 9.5
            line(x * z, y * z + v, x * z + 10, y * z + v)
            line(x * z, y * z + v, x * z + 5, y * z + v + 5)
            line(x * z + 5, y * z + v + 5, x * z + 10, y * z + v)
            -- Wooden
            stroke(75, 50, 25, 255)
            strokeWidth(6.5)
            line(x * z + 5, y * z, x * z + 5, y * z - 10)
        end
    end
end

@TokOut the installer that you used here:

https://codea.io/talk/discussion/comment/66517/#Comment_66517

Isn’t working because the URL needs to be to the raw version of the file (from the gist page, press the “raw” button, then use that URL). Generally, using http.request to grab a file, you need a raw URL (ie a page that has just the content and nothing else)

I released a forum for people who needs:

--Installer
--Known issue: the code being installed should have its Main tab as the left-most tab

local function success(data)
    if data:find("%-%-%# Main") then --paste-into-project format
        data = data.."--# " --add new file tag to end in order to capture last file
        for name, file in data:gmatch("(%w+)\
(.-)\
%-%-%# ") do --capture each name and file
            saveProjectTab(name, file)
            print("Saved", name)
        end
    else --put it all in one tab
        saveProjectTab("Main", data)
    end
    load(data)() --load the file
    setup() --run it
end

local function failure(error)
    print("Error", error)
end

http.request("https://gist.github.com/TokOut/86801d2085e3bc7334e8", success, failure)

Deleted

--Installer
--Known issue: the code being installed should have its Main tab as the left-most tab

local function success(data)
    if data:find("%-%-%# Main") then --paste-into-project format
        data = data.."--# " --add new file tag to end in order to capture last file
        for name, file in data:gmatch("(%w+)\
(.-)\
%-%-%# ") do --capture each name and file
            saveProjectTab(name, file)
            print("Saved", name)
        end
    else --put it all in one tab
        saveProjectTab("Main", data)
    end
    load(data)() --load the file
    setup() --run it
end

local function failure(error)
    print("Error", error)
end

http.request("https://raw.githubusercontent.com/TokOut/iForum/master/Version1-0.lua", success, failure)

I also found out, how to use type:

function setup()
    c = 6896532
    print(c .. "is a " .. type(c))
    c = "A string"
    print(c .." is a "  ..type(c))
    c = {67865, 368865}
    print("{67865, 368865} is a " .. type(c))
    c = true
    print("true is a " .. type(c))
    c = nil
    print("nil value is " .. type(c))
    c = mesh()
    print("A mesh is a " .. type(c))
end

Try it and see!

Sorry, autogist doesn’t work {=< Use this URL:
https://gist.github.com/TokOut/86801d2085e3bc7334e8

Ok, so you have just to copy this code and put it in any project:

https://gist.github.com/TokOut/86801d2085e3bc7334e8

@yojimbo2000, what do you think? Is it bad? Or good?

Will it work with https://raw.githubusercontent.com/TokOut/iForum/master/Version1-0.lua?

20! == 2432902008176640000
With a simple project…

Updated the installer a bit:


n = 0
displayMode(FULLSCREEN)

local function success(data)
    if data:find("%-%-%# Main") then
        data = data.."--# "
        for name, file in data:gmatch("(%w+)\
(.-)\
%-%-%# ") do
            saveProjectTab(name, file)
            print(n .." tabs saved.")
            n = n + 1
        end
    else
        saveProjectTab("Main", data)
    end
    load(data)()
    restart()
end

local function failure(error)
    print("Error", error)
end

http.request("https://raw.githubusercontent.com/TokOut/iForum/master/Version1-0.lua", success, failure)

I learned physics:



function setup()
    ball = physics.body(CIRCLE, 50)
    PlatForm = physics.body(EDGE, vec2(0, HEIGHT), vec2(WIDTH, HEIGHT))
    ball.y = 250
    ball.x = WIDTH/2
    ball.gravityScale = -5
    ball.restitution = 0
end

function draw()
    background(0, 0, 0, 255)
    fill(255, 200, 50, 255)
    ellipse(ball.x, ball.y, 50)
end

function collide(c)
    print("Collided!")
end

Can someone say me plz how to bring your body jump?

Search the forum. Everything you want to do has already been done and posted on the forum.

@dave1707, run this code. Is it also for you crashing or only for me?



function setup()
    supportedOrientations(CurrentOrientation)
    ball = physics.body(CIRCLE, 50)
    ball.x = 100
    ball.y = 100
    ball.gravityScale = 0
end

function draw()
    background(0, 0, 0, 255)
    -- Bodys
    bodyArea(50, 500, 200, 400)
    bodyArea(250, 50, 200, 500)
    --Body
    strokeWidth(0)
    blendMode(ADDITIVE)
    fill(255, 200, 50, 255)
    ellipse(ball.x, ball.y, 50)
    -- Move
    ball.x = ball.x + Gravity.x * 10
    ball.y = ball.y + Gravity.y * 10
    text("I coded this on my iPad", WIDTH/2, 750)
end

function bodyArea(x, y, x2, y2)
    local t = physics.body(EDGE, vec2(x, y), vec2(x2, y2))
    stroke(255, 255, 255, 255)
    strokeWidth(50)
    line(x, y, x2, y2)
end

You are creating 2 new physics body every frame. You will soon run out of resources and crash Codea.