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

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Fri Apr 15, 2016 18:01

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?
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

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

by sofar » Fri Apr 15, 2016 22:07

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.
 

User avatar
qwertymine3
Member
 
Posts: 194
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

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

by qwertymine3 » Sat Apr 16, 2016 03:44

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)
Avatar by :devnko-ennekappao:
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Sat Apr 16, 2016 04:41

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
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

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

by sofar » Sat Apr 16, 2016 05:45

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.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 8 guests

cron