Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.16.0.3
I hope love.graphics.line is next
Re: Simple Tiled Implementation - STI v0.16.0.3
Karai, thanks for the help
Re: Simple Tiled Implementation - STI v0.16.0.3
Hello! I am new to Lua and Love, and am attempting to follow the tutorial provided here: http://lua.space/gamedev/using-tiled-maps-in-love
I've dropped the sti folder into the same directory as main.lua, and written the most basic of main.luas as suggested in the tutorial:
But love just halts with an error:
What am I doing wrong?
I've dropped the sti folder into the same directory as main.lua, and written the most basic of main.luas as suggested in the tutorial:
Code: Select all
-- Include Simple Tiled Implementation into project
local sti = require "sti"
function love.load()
-- Load map file
map = sti.new("democave.lua")
end
function love.update(dt)
-- Update world
map:update(dt)
end
function love.draw()
-- Draw world
map:draw()
end
Code: Select all
Program starting as '"C:\Love\love.exe" "J:\dev\demo" -debug'.
Program 'love.exe' started in 'J:\dev\demo' (pid: 19608).
Error: main.lua:6: attempt to call field 'new' (a nil value)
stack traceback:
main.lua:6: in function 'load'
[string "boot.lua"]:439: in function <[string "boot.lua"]:435>
[C]: in function 'xpcall'
Program completed in 69.39 seconds (pid: 19608).
- CrackedP0t
- Citizen
- Posts: 69
- Joined: Wed May 07, 2014 4:01 am
- Contact:
Re: Simple Tiled Implementation - STI v0.16.0.3
replace sti.new( with sti(Scottbert wrote:Hello! I am new to Lua and Love, and am attempting to follow the tutorial provided here: http://lua.space/gamedev/using-tiled-maps-in-love
I've dropped the sti folder into the same directory as main.lua, and written the most basic of main.luas as suggested in the tutorial:But love just halts with an error:Code: Select all
-- Include Simple Tiled Implementation into project local sti = require "sti" function love.load() -- Load map file map = sti.new("democave.lua") end function love.update(dt) -- Update world map:update(dt) end function love.draw() -- Draw world map:draw() end
What am I doing wrong?Code: Select all
Program starting as '"C:\Love\love.exe" "J:\dev\demo" -debug'. Program 'love.exe' started in 'J:\dev\demo' (pid: 19608). Error: main.lua:6: attempt to call field 'new' (a nil value) stack traceback: main.lua:6: in function 'load' [string "boot.lua"]:439: in function <[string "boot.lua"]:435> [C]: in function 'xpcall' Program completed in 69.39 seconds (pid: 19608).
/人 ◕‿‿◕ 人\
Here, have an umlaut. Ö
Here, have an umlaut. Ö
Re: Simple Tiled Implementation - STI v0.16.0.3
Thank you!
...But now the player sprite doesn't display. I copied everything exactly, except for the filename of the player sprite (which is right because it gives me an error if it's wrong) and the name of the object layer in the file (I called it 'Objects' instead of 'Spawn Point' in Tiled)
The map displays, but it does not place the Player. What am I doing wrong now?
...But now the player sprite doesn't display. I copied everything exactly, except for the filename of the player sprite (which is right because it gives me an error if it's wrong) and the name of the object layer in the file (I called it 'Objects' instead of 'Spawn Point' in Tiled)
Code: Select all
-- Include Simple Tiled Implementation into project
local sti = require "sti"
function love.load()
-- Load map file
map = sti("democave.lua")
-- Create new dynamic data layer called "Sprites" as the 8th layer
local layer = map:addCustomLayer("Sprites", 8)
-- Get player spawn object
local player
for k, object in pairs(map.objects) do
if object.name == "Player" then
player = object
break
end
end
-- Create player object
local sprite = love.graphics.newImage("img/playerstatic.png")
layer.player = {
sprite = sprite,
x = player.x,
y = player.y,
ox = sprite:getWidth() / 2,
oy = sprite:getHeight() / 1.35
}
-- Draw player
layer.draw = function(self)
love.graphics.draw(
self.player.sprite,
math.floor(self.player.x),
math.floor(self.player.y),
0,
1,
1,
self.player.ox,
self.player.oy
)
-- Temporarily draw a point at our location so we know
-- that our sprite is offset properly
love.graphics.setPointSize(5)
love.graphics.point(math.floor(self.player.x), math.floor(self.player.y))
end
-- Remove unneeded object layer
map:removeLayer("Objects")
end
function love.update(dt)
-- Update world
map:update(dt)
end
function love.draw()
-- Draw world
map:draw()
end
Re: Simple Tiled Implementation - STI v0.16.0.3
How many layers do you have, Scottbert? Might be you're running into the same issue I had - count your layers and add the sprites after them, so if you have 2 layers you make sprites the 3rd.
Re: Simple Tiled Implementation - STI v0.16.0.3
Yup! Now the player draws, but I get this...Zireael wrote:How many layers do you have, Scottbert? Might be you're running into the same issue I had - count your layers and add the sprites after them, so if you have 2 layers you make sprites the 3rd.
Code: Select all
Error: main.lua:46: attempt to call field 'point' (a nil value)
Re: Simple Tiled Implementation - STI v0.16.0.3
I tried to have the article updated but the pr was never accepted.
As for your issue, change "love.graphics.point" to "love.graphics.points".
As for your issue, change "love.graphics.point" to "love.graphics.points".
Last edited by Karai17 on Fri Sep 09, 2016 9:50 am, edited 1 time in total.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.16.0.3
I poked Etaine on Twitter, she's gonna accept my PRs soon, so hopefully this issue is resolved from hence forth.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.16.0.3
Ah, so STI updated and broke old code, but you weren't allowed to update the tutorial? That sucks. If that doesn't work out, maybe post an updated tutorial elsewhere?Karai17 wrote:I tried to have the article updated but the pr was never accepted.
Thank you for the tutorial, hopefully after I'll be far enough to learn more on my own and get coding!
Who is online
Users browsing this forum: No registered users and 4 guests