Open mstram opened 12 years ago
Is it possible to inquire (from rubyc) what a chip's input / output "#" is ?
Or is that info "buried" / "hidden" internally ?
Ok I've gotten to the point where :
1) A selection of blocks have signs applied to them
But I'm stuck figuring out how to use the chip scanner / get the input / output chip numbers
require 'java' import 'org.tal.rubychip.RubyCircuit' import 'org.tal.redstonechips.circuit.RCTypeReceiver'
import 'org.tal.rubychip.RubyCircuit' import 'org.tal.redstonechips.circuit.Circuit' import 'org.bukkit.event.player.PlayerMoveEvent'
################## import 'java.lang.reflect.InvocationTargetException' import 'java.lang.reflect.Method' import 'java.util.ArrayList' import 'java.util.HashMap' import 'java.util.List' import 'java.util.Map' import 'java.util.logging.Level'
######################### import 'org.bukkit.ChatColor' import 'org.bukkit.Location' import 'org.bukkit.Material' import 'org.bukkit.block.Block' import 'org.bukkit.command.Command' import 'org.bukkit.command.CommandSender' import 'org.bukkit.entity.Player' import 'org.bukkit.material.MaterialData' import 'org.bukkit.plugin.Plugin' import 'org.tal.redstonechips.PrefsManager'
########################################### import 'org.tal.redstonechips.circuit.ChipScanner'
#
#############
class Cuboid2b < RubyCircuit include RCTypeReceiver FACENORTH = 2 #: Facing north (for ladders and signs, attached to the north side of a block) FACESOUTH = 3 FACEWEST = 4 FACEEAST = 5
WALLSIGN = 68
def init info "Cuboid test." rc.addRCTypeReceiver(circuit.activationBlock, self) true end
def input(idx, state) end
def type(words, player) session = rc.getUserSession(player.name, false)
if session!=nil && session.cuboid!=nil l = session.cuboid l0 = l[0].blockX.to_s + ", " + l[0].blockY.to_s + ", " + l[0].blockZ.to_s l1 = l[1].blockX.to_s + ", " + l[1].blockY.to_s + ", " + l[1].blockZ.to_s
debug("Cuboid selection: " + l0 + " and " + l1)
@x = l[0].blockX
@y = l[0].blockY
@z = l[0].blockZ
begin
c = rc.getCircuitManager().getCircuitById('178')
debug "getCircuitById : c = #{c}"
rescue Exception
debug "error on rc.getCircuitManager().getCircuitById(1) error = #{$!}"
end
debug "@x=#{@x} @y=#{@y} @z={@z}"
if l[0].blockZ == l[0].blockZ makeSign("x",l[0].blockZ,l[0].blockX,l[1].blockX,l[0].blockY,FACESOUTH) else makeSign("z",l[0].blockX,l[0].blockZ,l[1].blockZ,l[0].blockY,FACEEAST) end
else debug("No cuboid selected") end end ##########################3 def makeSign(orient,zx,sBlock,eBlock,ypos,dir) if orient == "x" zx +=1 begin (sBlock..eBlock).each {|bpos| circuit.world.getBlockAt(bpos,ypos,zx).setTypeId(WALLSIGN) circuit.world.getBlockAt(bpos,ypos,zx).setData(dir) } rescue Exception debug "(makesign orient = '#{orient}'): error = #{$!}" end else begin (sBlock..eBlock).each {|bpos| circuit.world.getBlockAt(zx,ypos,bpos).setTypeId(WALLSIGN) circuit.world.getBlockAt(zx,ypos,bpos).setData(dir) } rescue Exception debug "(makesign orient = '#{orient}'): error = #{$!}" end end end
end
Cuboid2b.new()
Point at an rc chip, do /rclabel, it then attaches a sign to each input / output with it's pin #
/rclabel [remove] if you want to remove the signs
(I'm attempting to do this with rubyc now) for the "big board"
I was thinking mabye it could be an option when creating a chip, but don't know what the cleanest way to do it would be ("lbl" as the last sign argument ?)