Author Topic: (Solved)Table?  (Read 4070 times)

0 Members and 1 Guest are viewing this topic.

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • Active - Making stories can take the most time.
    • View Profile
(Solved)Table?
« on: April 03, 2017, 03:23:56 AM »
I have been trying to figure out the error with my table for the pixel movement.
Quote
trajectory (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)


Code: [Select]
[2150] Error: In on_started: [string "maps/Map_4.lua"]:83: bad argument #3 to set_trajectory (table expected, got number)
« Last Edit: April 03, 2017, 08:23:11 AM by zutokaza »

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Table?
« Reply #1 on: April 03, 2017, 06:44:17 AM »
I have been trying to figure out the error with my table for the pixel movement.
Quote
trajectory (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)


Code: [Select]
[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.”

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • Active - Making stories can take the most time.
    • View Profile
Re: Table?
« Reply #2 on: April 03, 2017, 07:39:50 AM »
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

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Table?
« Reply #3 on: April 03, 2017, 07:54:18 AM »
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.”

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • Active - Making stories can take the most time.
    • View Profile
(Solved)Table?
« Reply #4 on: April 03, 2017, 08:14:52 AM »
Oh, forgot it was in pixels. All is good now. Thank you for your help Diarandor!
« Last Edit: April 03, 2017, 08:22:46 AM by zutokaza »