(Solved)Table?

Started by zutokaza, April 03, 2017, 03:23:56 AM

Previous topic - Next topic
April 03, 2017, 03:23:56 AM Last Edit: April 03, 2017, 08:23:11 AM by zutokaza
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).


Code ( lua) Select
local table1 = {244,270}
pixel:set_trajectory(table1)
pixel:start(gerf)


and I tried:

Code ( lua) Select
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)

Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

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).


Code ( lua) Select
local table1 = {244,270}
pixel:set_trajectory(table1)
pixel:start(gerf)


and I tried:

Code ( lua) Select
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.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

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:

Code ( lua) Select
pixel:set_ignore_obstacles(true)

Full code:

Code ( lua) Select

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
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

It is normal. The coordinates of the translations are given in pixels and yours are too big. Try with small translations.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

April 03, 2017, 08:14:52 AM #4 Last Edit: April 03, 2017, 08:22:46 AM by zutokaza
Oh, forgot it was in pixels. All is good now. Thank you for your help Diarandor!
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616