Howdy, Stranger!

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

In this Discussion

Getting Started

edited October 2017 in Codea Craft Posts: 1

Hi there! I love Lua but I’m new to Codea. Just trying to get one of these models to appear on screen. I’m using an example but all that appears when I run is the gradient from the sky. Where is the entity I created? Any help is much appreciated!

I’m also unsure of how to tag code in this forum so apologies for the sloppiness...

-- Craft Template

function setup()
    -- Create a new craft scene
    scene = craft.scene()

    -- Move the main camera position
    scene.camera.position = vec3( 0, -20, 0)

    -- Adjust the scene lighting
    scene.sun.rotation = quat.eulerAngles( 45, 0, 45)
    scene.ambientColor = color(181, 98, 98, 255)

    -- Get sky material and alter sky and horizon colors
    local skyMaterial = scene.sky.material
    skyMaterial.sky = color(0, 221, 255, 255)
    skyMaterial.horizon = color(0, 0, 0, 255)

    -- Create a new entity
    local e = scene:entity()
    e.model = craft.model("Blocky Characters:Adventurer")
    e.eulerAngles = vec3( 45, 0, 45 )
    e.z = -10
end

function update(dt)
    -- Update the scene (physics, transforms etc)
    scene:update(dt)
end

-- Called automatically by codea 
function draw()
    update(DeltaTime)

    -- Draw the scene
    scene:draw()    
end

Comments

  • dave1707dave1707 Mod
    edited October 2017 Posts: 8,464

    @Akaya Whenever you post code, put ~~~ on a line before and after your code. Here’s your code with a few additions or changes.

    -- Craft Template
    
    function setup()
        parameter.integer("x",-180,180,0)
        parameter.integer("y",-180,180)
        parameter.integer("z",-180,180,0)
    
        -- Create a new craft scene
        scene = craft.scene()
    
        -- Move the main camera position
        scene.camera.position = vec3( 0, 0, -10)
    
        -- Adjust the scene lighting
        scene.sun.rotation = quat.eulerAngles( 45, 150, 0)
        scene.ambientColor = color(181, 98, 98, 255)
    
        -- Get sky material and alter sky and horizon colors
        local skyMaterial = scene.sky.material
        skyMaterial.sky = color(0, 221, 255, 255)
        skyMaterial.horizon = color(164, 223, 190, 255)
    
        -- Create a new entity
        e = scene:entity()
        e.model = craft.model("Blocky Characters:Adventurer")
        e.scale = vec3(1,1,1) / 10
    end
    
    function update(dt)
        -- Rotate the entit   
        e.eulerAngles = vec3(x,y,z)
    
        -- Update the scene (physics, transforms etc)
        scene:update(dt)
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()       
    end
    
Sign In or Register to comment.