I have been trying to figure out the error with my table for the pixel movement.
Quotetrajectory (table): An array of all successive translations to make. Each translation should be an array of two integers (x and y).
local table1 = {244,270}
pixel:set_trajectory(table1)
pixel:start(gerf)
and I tried:
pixel:set_trajectory{244,270}
pixel:start(gerf)
[2150] Error: In on_started: [string "maps/Map_4.lua"]:83: bad argument #3 to set_trajectory (table expected, got number)
Quote from: zutokaza on April 03, 2017, 03:23:56 AM
I have been trying to figure out the error with my table for the pixel movement.
Quotetrajectory (table): An array of all successive translations to make. Each translation should be an array of two integers (x and y).
local table1 = {244,270}
pixel:set_trajectory(table1)
pixel:start(gerf)
and I tried:
pixel:set_trajectory{244,270}
pixel:start(gerf)
[2150] Error: In on_started: [string "maps/Map_4.lua"]:83: bad argument #3 to set_trajectory (table expected, got number)
Your array is not an array of translations, but an array of integers.
You need an array of translations. Examples:
For 1 translation: table1 = {{244,270}}
For 2 translations: table1 = {{244,270}, {244,270}}
Etc.
Thank you Diarandor! That solved my first problem.
Now the problem is that the NPC does not move at all. I tried multiple different coordinates of x,y. Strangly, the sprite vanishes with:
pixel:set_ignore_obstacles(true)
Full code:
function map:on_started()
local pixel = sol.movement.create("pixel")
pixel:set_trajectory{{64,80},{368,384}}
pixel:set_loop(true)
pixel:set_ignore_obstacles(true)
pixel:start(gerf)
end
It is normal. The coordinates of the translations are given in pixels and yours are too big. Try with small translations.
Oh, forgot it was in pixels. All is good now. Thank you for your help Diarandor!