This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
aanonim1994's profile picture

Transfer to 1.7.10

Started by aanonim1994, 11 June 2015 - 03:26 PM
aanonim1994 #1
Posted 11 June 2015 - 05:26 PM
Hello,
I need help, I would like to transfer program Mobs Direwolf20 to 1.7.10.

Program works and its all features but program doesn't read type mobs so when i click on the button "Mob Selector" program crashed : :142: table index expected, got nil

when the chest doesn't have any safari net with mobs program works perfect.

http://pastebin.com/1YFDLFvF
KingofGamesYami #2
Posted 11 June 2015 - 07:37 PM

         data = c.getStackInSlot(i) --140
         --print(i..":"..data.captured) --141
         mobArray[data.captured] = i --142

The error says data.captured is nil, and therefor not a valid index of the table mobArray. From this information, I presume OpenPeripherals updated the keys returned by c.getStackInSlot when used on a safari net.

OpenPeripherals may have removed support for safari nets during the update, as well. Try printing the serialized result of c.getStackInSlot( i ) where i is the slot number of a safari net. If there is a key showing what is in the net, replace data.captured on line 142 with data.thenewkey.
aanonim1994 #3
Posted 11 June 2015 - 10:35 PM
You are right,

I saw now that it is possible to call a safari net in the anvil. So when the name of a piece of creeper - crepper. I could use this, but I need help what change in the code to take the name of an item.


KingofGamesYami #4
Posted 12 June 2015 - 12:52 AM
First, find out what OpenPeripherals knows about the safari net in a chest. To do this, place the safari net (with something in it) in the first slot of a chest. Next, place a computer to the left of the chest. (Alternatively, you can edit the code I gave below to wrap the chest)

Now, run this program:

local chest = peripheral.wrap( "right" )
local data = chest.getStackInSlot( 1 )
for k, v in pairs( data ) do
  print( k .. " : " .. v )
end

It should give you a list in this format:

Name : Value

If it does, find a value that is what you have in the safari net (eg. Creeper). It will have a Name to the left of it.

Change line 142 of the program you originally posted like this:

--#original
mobArray[data.captured] = i
--#take away the key that is not valid
mobArray[data.] = i
--#now add in the new, valid key (The Name mentioned earlier corresponding to the name of the mob)
mobArray[data.newkey] = i

If you have problems or do not understand what I'm trying to explain, please don't hesitate to ask further questions.
aanonim1994 #5
Posted 12 June 2015 - 01:39 AM
Yours program doesn't run, but I understood it so i change this line like this:


data = c.getStackInSlot(i) --140
		 --print(i..":"..data.display_name) --141
		 mobArray[data.display_name] = i --142

and running :)/>

thanks for your help:)
KingofGamesYami #6
Posted 12 June 2015 - 04:02 AM
No problem :)/>. I wish you luck in any future programming endeavors.