Jump to content


wackozacko's Content

There have been 6 items by wackozacko (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#37040 [MC 1.2.5] - [CC 1.33] ccSensors [SMP/SSP]

Posted by wackozacko on 05 October 2012 - 01:27 AM in Peripherals and Turtle Upgrades

I'm pretty sure I found a bug with this mod. At least with version mc125 build 017pr1 which is in the current build of Technic SMP. I've been browsing google for the last couple of hours trying to find a solution, but I haven't come across anything helpful.

The error is with function call getSensorReadingAsDict on LargeChests.

The code I have is as follows
os.unloadAPI("sensors")
os.loadAPI("/rom/apis/sensors")
side = sensors.getController()
sens = sensors.getSensors(side)
INV1 = sens[1]
targets = sensors.getAvailableTargetsforProbe("top",INV1,"InventoryContent")
data = sensors.getSensorReadingAsDict("top",INV2,targets[1],"InventoryContent")

Which gives me this server output
02:18:23 [INFO] [mod_ccSensors] callMethod:3 args[0]:
02:18:23 [INFO] [mod_ccSensors] callMethod:5 args[2]:
02:18:23 [INFO] [mod_ccSensors] callMethod:6 args[2]:
02:18:23 [INFO] null
02:18:23 [SEVERE] java.lang.NullPointerException
02:18:23 [SEVERE]	   at ccSensors.shared.SensorTarget.getTargetType(SensorTar
get.java:206)
02:18:23 [SEVERE]	   at ccSensors.shared.sensorModules.BaseSensor.setTarget(B
aseSensor.java:399)
02:18:23 [SEVERE]	   at ccSensors.shared.TileEntityComputerSensor.setTarget(T
ileEntityComputerSensor.java:82)
02:18:23 [SEVERE]	   at ccSensors.shared.TileEntitySensorController.setTarget
(TileEntitySensorController.java:465)
02:18:23 [SEVERE]	   at ccSensors.shared.TileEntitySensorController.callMetho
d(TileEntitySensorController.java:673)
02:18:23 [SEVERE]	   at dan200.computer.core.Computer$PeripheralWrapper.call(
Computer.java:128)
02:18:23 [SEVERE]	   at dan200.computer.core.Computer$46.invoke(Computer.java
:1435)
02:18:23 [SEVERE]	   at org.luaj.vm2.lib.VarArgFunction.onInvoke(Unknown Sour
ce)
02:18:23 [SEVERE]	   at org.luaj.vm2.TailcallVarargs.eval(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.TailcallVarargs.arg1(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.call(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.lib.BaseLib.pcall(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.lib.BaseLib$BaseLibV.invoke(Unknown Sour
ce)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.lib.BaseLib.pcall(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.lib.BaseLib$BaseLibV.invoke(Unknown Sour
ce)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.call(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.execute(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.onInvoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaClosure.invoke(Unknown Source)
02:18:23 [SEVERE]	   at org.luaj.vm2.LuaThread$State.run(Unknown Source)
02:18:23 [SEVERE]	   at java.lang.Thread.run(Unknown Source)
02:18:23 [INFO] [mod_ccSensors] callMethod:9 args[2]:
02:18:23 [INFO] [mod_ccSensors] callMethod:2 args[1]:
and the program simple quits in the CC terminal.

If I use targets[2] instead, which is a SortingMachine rather than a LargeChest I get the following
02:13:27 [INFO] [mod_ccSensors] callMethod:3 args[0]:
02:13:27 [INFO] [mod_ccSensors] callMethod:5 args[2]:
02:13:27 [INFO] [mod_ccSensors] callMethod:6 args[2]:
02:13:27 [INFO] [SETTARGET] TileSorter
02:13:27 [INFO] [mod_ccSensors] callMethod:9 args[2]:
02:13:27 [INFO] [mod_ccSensors] callMethod:2 args[1]:
And useful output in the CC terminal telling me what is actually in the chest.

If anyone knows a way to deal with this it'd be really helpful (I don't want to have to upgrade every chest in my sorting system) or if this is a known bug, when do you think it will be fixed?



#30650 [LUA] Global vector keeps getting reset?

Posted by wackozacko on 08 September 2012 - 09:23 AM in Ask a Pro

View Posttomass1996, on 08 September 2012 - 03:37 AM, said:

I'm not sure if it might be a reference issue, where mineLocation just becomes a 'pointer' to the exact same object as location instead of a copy
Try changing:
mineLocation = location
to:
mineLocation = vector.new(location.x,location.y,location.z)

SUCCESS!! Thanks so much for your insight. Wish I had asked on these forums sooner.

View PostLyqyd, on 08 September 2012 - 04:02 AM, said:

First, if you're not opposed to using an external API, you could check out my Location API, which is very similar to the vector API with a few added things to make turtle tracking much easier. The latest version can be found here; the discussion topic on these forums is found here. Even if you don't choose to use it, please feel free to take a look through the code. It's not very long and it may help you tighten up some of your code. If you have any questions about it, feel free to ask here or PM me.

Also, when printing vectors (and locations, if using my API), passing the vector or location to tostring() will output a reasonably formatted (comma-separated) string output.

I would most likely suspect that mineLocation = location line, that does assign mineLocation to simply point to whatever table location points to already, so they are then linked until either of them is set to a new value.

I'm not opposed to an external API, but the purpose of this exercise was learning LUA, not actually getting a working miner. I did take a look at the API and might well use it, or at least integrate part of it, in future. Very clean. Going to have to learn LUA coding standards as well as just the language.



#30573 [LUA] Global vector keeps getting reset?

Posted by wackozacko on 08 September 2012 - 02:35 AM in Ask a Pro

View PostLettuce, on 08 September 2012 - 02:32 AM, said:

I see. Personally, I've never used them. Learn something new everyday, eh? I like variables, and I have done the same things with them.
(x, y, z coordinates) If you are dead-set on vectors, I can't help you, I'm inexperienced with them. Someone else will eventually pick this up. But if you are willing to use a table, I'll be happy to lend what knowledge I do have. I'm not incredibly experienced, but I know enough to get most of my programs running.
--Lettuce
I figure it's possible to do it with tables and other variables, but I don't know if that would solve the problem I've run into. My other vectors seem to be working fine so I don't know what the problem is. I don't really want to go through a whole rewrite of the code just cause a single vector doesn't want to work and the rest do.



#30572 [LUA] Global vector keeps getting reset?

Posted by wackozacko on 08 September 2012 - 02:33 AM in Ask a Pro

View PostMysticT, on 08 September 2012 - 02:26 AM, said:

Well, I don't see any part that modifies the vectors. I guess you do it in the movement functions (forward, back, etc.), so you should post them.

The only vector that is regularly being modified is the location vector to keep track of where the turtle is. All the code that references mineLocation has been posted above.

For reference I'm including my movement functions and a couple of the supporting functions below.
Spoiler



#30565 [LUA] Global vector keeps getting reset?

Posted by wackozacko on 08 September 2012 - 02:12 AM in Ask a Pro

Vectors do work, though they are somewhat basic. I'm more just using them to store x,y,z coordinates than any complex mathematics.

http://computercraft...tle=Vector_(API)



#30562 [LUA] Global vector keeps getting reset?

Posted by wackozacko on 08 September 2012 - 02:03 AM in Ask a Pro

So, I've just started with ComputerCraft and LUA, but I come from a programming background so it hasn't been too hard to pick up. Until now.

As a part of learning, I'm trying to write a simple program for a mining turtle so that, starting from a chest, it will dig a shaft N by M down. When it runs low on fuel or fills it's inventory up, it will return to the chest and dump everything before refuelling. I'm doing my path-finding with vectors. The start location is vector <0,0,0>, the mineshaft starts at vector <2,0,0> (2 blocks away from the chest), and every time I move I increase the vector appropriately.

The plan was, when the turtle does need to return to the chest, it can record it's current location as a vector, navigate to <0,0,0> to drop everything, and then use the previously recorded position to return to where it was last.

The problem is that reading the vector in, that I thought I'd stored, always returns <0,0,0> no matter what, so the turtle starts from where it's at and destroys the chest it just dumped everything into.

I think it's a scoping issue, but despite researching it for the last couple of hours, I haven't figured it out.

The relevant code is as follows:
Spoiler