Page 1 of 1

data:index(x, y, z) = attempt to call method 'index'

PostPosted: Fri Apr 15, 2016 18:01
by burli
Hi, I tried to make a simple mod and I used code from the wiki.

But the line
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local vi = data:index(minp.x, y, z)

throws an error

attempt to call method 'index' (a nil value)


I'm not really familiar with lua yet, so I'm struggling a little bit. What does the : mean in this situation? Is it a method call, in this case the method "index" from a table? I couldn't find a reference yet

I looked at some other code. I changed data:index to area:index and the code runs without errors, but also without the expected result.

Is there an error in the code?

Re: data:index(x, y, z) = attempt to call method 'index'

PostPosted: Fri Apr 15, 2016 22:07
by sofar
A little bit hard to see what's wrong without seeing the rest of the code, especially the place where you declare `data`.

The error says that `data` doesn't have a function `index`. Perhaps print(dump(data)) may show some useful clues.

Re: data:index(x, y, z) = attempt to call method 'index'

PostPosted: Sat Apr 16, 2016 03:44
by qwertymine3
Looking at the code on the wiki, it seems there may be an error with it.
I think that line of code should be :
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local vi = area:index(minp.x,y,z)

Re: data:index(x, y, z) = attempt to call method 'index'

PostPosted: Sat Apr 16, 2016 04:41
by burli
It is the code Form the wiki and nothing more. Use it as a mod.

I already changed data to area. No errror, but also no effect

Re: data:index(x, y, z) = attempt to call method 'index'

PostPosted: Sat Apr 16, 2016 05:45
by sofar
maybe look at this commit for some hints on how to use the vmanip:

https://github.com/minetest/minetest_game/pull/1039/commits/e376de99a8ada118ccc936d980ab7094ddefa45e

You're probably not writing back the vmanip data to the world.