Jump to content




[mc 1.6.x] Openperipheral


  • This topic is locked This topic is locked
1184 replies to this topic

#521 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 03:07 AM

 Yurij, on 14 July 2013 - 06:36 PM, said:

I wrote a simple program to figure out what sort of info about mobs you could get out of the sensor
http://pastebin.com/qnty0gUm

The problem is that it silently quits at the "local mobData = sensor.getMobData(id)" line
if I am riding a horse within the sensors range.
Horses not ridden within range works.

Good spot! Thanks!

#522 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 03:17 AM

I think I'm going to change riddenBy and riding. At the moment they're trying to return full map of information about the rider or entity being ridden, but of course this means you get recursive data.

I'll probably change "ridden by" so that it returns the full map of information about the user, but change "riding" so that it just returns the id of the thing the user/mob is riding.

is that makes sense!

#523 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 03:18 AM

Until I document things, this might help you work out what information you can get about an entity:

https://github.com/m...ntityUtils.java

#524 karelmikie3

  • Members
  • 112 posts

Posted 15 July 2013 - 03:27 AM

 Mikeemoo, on 12 July 2013 - 02:43 PM, said:

https://dl.dropboxus....1-preview2.jar

preview for MC 1.6.2

Would be good to get some feedback and bug reports..etc.

The only thing I know is missing is fuel() related stuff and the gauge from openccsensors

Would love some beta testers! NEI the recipes because they're not documented. And p.listMethods() is now p.listMethods(true) for the time being (but i'll fix that)

when i shift clicked a robot in the controller block then i crash (also with normal clicking)

report:
http://pastebin.com/3GU7fL6G

#525 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 03:28 AM

 karelmikie3, on 15 July 2013 - 03:27 AM, said:

 Mikeemoo, on 12 July 2013 - 02:43 PM, said:

https://dl.dropboxus....1-preview2.jar

preview for MC 1.6.2

Would be good to get some feedback and bug reports..etc.

The only thing I know is missing is fuel() related stuff and the gauge from openccsensors

Would love some beta testers! NEI the recipes because they're not documented. And p.listMethods() is now p.listMethods(true) for the time being (but i'll fix that)

when i shift clicked a robot in the controller block then i crash (also with normal clicking)

report:
http://pastebin.com/3GU7fL6G

Check about 5 posts up. Already fixed with a new preview download

#526 Spaceshipable

  • Members
  • 8 posts

Posted 15 July 2013 - 06:40 AM

I have been trying to use a terminal glasses bridge to control one of jakjs redstone in motion carriage controllers however whenever I move the carriage the connection to the glasses is lost. Is there a way to remedy this issue? The same also happens with moving the bridge with a portal gun.

#527 Spaceshipable

  • Members
  • 8 posts

Posted 15 July 2013 - 06:54 AM

 Spaceshipable, on 15 July 2013 - 06:40 AM, said:

I have been trying to use a terminal glasses bridge to control one of jakjs redstone in motion carriage controllers however whenever I move the carriage the connection to the glasses is lost. Is there a way to remedy this issue? The same also happens with moving the bridge with a portal gun.
Maybe you could add a command to link the bridge to the glasses key

#528 Yurij

  • Members
  • 18 posts

Posted 15 July 2013 - 11:14 AM

If i name a mob and display its information with the sensor, the type shows the name.
Also you can't see what armor horses have.

#529 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 11:55 AM

 Yurij, on 15 July 2013 - 11:14 AM, said:

If i name a mob and display its information with the sensor, the type shows the name.
Also you can't see what armor horses have.

Thanks again! I'll get that fixed.

#530 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 11:57 AM

A little API I've been messing around with..

Some of you might find this useful. Some of you, I'm sure, will want to rewrite it! I'm not very good at lua.

Usage:

os.loadAPI("openperipheral")

-- wrap all of the mfsus and batboxes on the whole network in one go
local energy = openperipheral:new():types("mfsu", "batbox");

-- sum up the eu capacity of all of them
-- note, in 1.6.2 it's EUCapacity, in 1.5.2 versions it's probably getCapacity or similar
local totalStorage = table.reduce(
  energy:getEUCapacity(),
  function(a, b )
	return a + b
  end
)

print("total storage on network = "..totalStorage)

You can also target things individually:

os.loadAPI("openperipheral")

local noteblocks = openperipheral:new():wrap("noteblock_1", "noteblock_2");
noteblocks.triggerNote()


Or append to a previous list

os.loadAPI("openperipheral")

local chests = openperipheral:new():types("chest"):types("trapped_chest"):wrap("barrel_0"):wrap("something_else_0")
chests.doSomething()


Any function call will return all of the results in a lua table.


Name this file "openperipheral"

local sideNames = rs.getSides()

table.reduce = function (list, fn)
	local acc
	for k, v in ipairs(list) do
		if 1 == k then
			acc = v
		else
			acc = fn(acc, v)
		end
	end
	return acc
end

local openperipheral = {

  -- wrap multiple targets at once
  wrap = function (self, ...)
	local meta = getmetatable(self)
	for k, name in pairs({...}) do
	  table.insert(self.names, name)
	  for k2, methodName in pairs(peripheral.getMethods(name)) do
		meta.__index[methodName] = function (a, ...)
		  local returnVal = {}
		  for k3, pName in pairs(a.names) do
			for k4, mName in pairs(peripheral.getMethods(pName)) do
			  if mName == methodName then
				table.insert(returnVal, peripheral.call(pName, methodName, ...))
			  end
			end
		  end
		  return returnVal
		end
	  end
	end
	return self
  end,

  -- wrap multiple targets by their type
  types = function(self, ...)
	local checkTypes = { ... }
	local addNames = {}
	for k, side in pairs(sideNames) do
	  local sideType = peripheral.getType(side)
	  if sideType == "modem" then
		for k1, remoteName in pairs(peripheral.call(side, "getNamesRemote")) do
		  local remoteType = peripheral.call(side, "getTypeRemote", remoteName)
		  for k2, checkType in pairs(checkTypes) do
			if remoteType == checkType then
			  table.insert(addNames, remoteName)
			end
		  end
		end
	  else
		for k2, checkType in pairs(checkTypes) do
		  if sideType == checkType then
			table.insert(addNames, side)
		  end
		end
	  end
	end

	return self:wrap(unpack(addNames))
  end,

  getNames = function(self)
	return self.names
  end

}

local gmetatable = {
  __index = openperipheral,
  __tostring = function(g) return g:tostring() end,
}

function new()
  local g = {
	names = {}
  }
  setmetatable(g, gmetatable)
  return g
end


#531 Yurij

  • Members
  • 18 posts

Posted 15 July 2013 - 12:17 PM

 Mikeemoo, on 15 July 2013 - 11:57 AM, said:

A little API I've been messing around with..

Some of you might find this useful. Some of you, I'm sure, will want to rewrite it! I'm not very good at lua.

-- SNIP --

Useful and awesome. This will come in handy in future projects
Thanks

#532 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 12:59 PM

https://dl.dropboxus....1-preview5.jar

Another preview build.

Horse armor is available, as well as some other horse stats

eatingHaystack, chestedHorse, hasReproduced, bred, horseType, horseVariant, horseTemper, horseTame, ownerName

#533 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 01:11 PM

Another preview build.

I think i'll do a whole bunch of these. I'm not in a big rush to release for MC 1.6.2, so I'd rather get everything finished off before any official builds!

This one adds "sheepColor" (an integer, should match up to the damage value of wool color)
It also adds "isVillagerZombie" to zombies

https://dl.dropboxus....1-preview6.jar

#534 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 01:20 PM

https://dl.dropboxus....1-preview7.jar

Fixed auto-mounting of base openperipheral lua files

2 files should now get auto mounted. the twitter script for the peripheral classes and the API I posted above, named "multiperipheral"

#535 Falesh

  • Members
  • 9 posts

Posted 15 July 2013 - 02:17 PM

This is an awesome mod!

One query, can you check how many of a specific item is stored an Applied Energistics network? I'm planning to keep certain items always in stock using "requestCrafting" but I haven't figured out how to check how much of a specific item is already in the network.

#536 Yurij

  • Members
  • 18 posts

Posted 15 July 2013 - 02:25 PM

What does this mean?
http://pastebin.com/1CUwVtiW
from ForgeModLoader-client-0.log

#537 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 02:35 PM

 Yurij, on 15 July 2013 - 02:25 PM, said:

What does this mean?
http://pastebin.com/1CUwVtiW
from ForgeModLoader-client-0.log

It means I've derped!

I'm in the middle of fixing that now, so all of that should disappear (and applied energistics integration will be fixed) in the next preview release :)

(They're actually warnings I put in place for myself to stop myself from derping, but I forgot about them!)

#538 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 15 July 2013 - 04:15 PM

https://dl.dropboxus....1-preview8.jar

Added/Fixed up all the Applied Energistics methods - all except requestCrafting, which I'm just kinda hoping is still working..

isFuzzyPreformatted()
getAvailableItems()
getAdvancedMethodsData()
getPreformattedItems()
getStoredItemCount()
getTotalBytes()
getUnusedItemCount()
getTotalItemTypes()
getFreeBytes()
isPreformatted()
listMethods()
containsItemType(temId, dmgValue)
countOfItemType(itemId, dmgValue)
getStoredItemTypes()
canHoldNewItem()
getPriority()
getRemainingItemTypes()
getName()
getUnusedBytes()
getRemainingItemCount()



#539 Russoul

  • Members
  • 14 posts

Posted 16 July 2013 - 01:31 AM

Can you realese your preview builds for 1.5.2

#540 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 16 July 2013 - 03:19 AM

 Russoul, on 16 July 2013 - 01:31 AM, said:

Can you realese your preview builds for 1.5.2

No





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users