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

ICBM Map Monitor launching

Started by adamjan2000, 20 January 2015 - 12:52 PM
adamjan2000 #1
Posted 20 January 2015 - 01:52 PM
How I could make map displayed on monitor, and launch rockets (from ICBM mod)into clicked point?
p.s. I'm not from countries, which use english, so my language isn't perfect
Cranium #2
Posted 20 January 2015 - 03:38 PM
I've split your question into a new topic rather than reviving a two year old topic.
KingofGamesYami #3
Posted 20 January 2015 - 04:00 PM
You could use

> monitor <side> paint
To paint an image of the map. As for interfacing with ICBM, I'm not sure of the information needed to launch the rockets.
Lyqyd #4
Posted 20 January 2015 - 04:02 PM
The original topic was this one, in case the previous discussion gives more insight into where the OP is coming from. Please don't post on it, anyone.
adamjan2000 #5
Posted 22 January 2015 - 12:24 PM
How can I load map to the screen of CC monitor, if it's in directory (this is only example of path) C:/Users/adam/AppData/Roaming/.minecraft/map.png?
KingofGamesYami #6
Posted 22 January 2015 - 01:23 PM
Short answer: you can't.

Long answer: Two reasons
1) CC is sandboxed. The computers cannot reach anything that isn't inside their specific folder.
2) CC doesn't know how to deal with png files. It could be possible to do, if you created a parser for it.
adamjan2000 #7
Posted 22 January 2015 - 01:31 PM
ok, so i have 2 questions:
1. Is it picture in .bmp or .jpg good?
2. Is it a way to read coordinates of clicked point on screen as coordinates, which are connected with point in overworld?
KingofGamesYami #8
Posted 22 January 2015 - 02:15 PM
1 - I believe someone has made a .bmp converter, not sure about .jpg
2 - Sure, check here.
adamjan2000 #9
Posted 22 January 2015 - 08:02 PM
What's that "side"? It's needed, when i have monitor on the corner?
How I can change string to number, needed to setTarget(x, y, z) command?
How big coordinates can I get, if I'll click to right down corner of screen 3x3?
KingofGamesYami #10
Posted 22 January 2015 - 10:09 PM
The monitor should be adjacent to a side of the computer. If you have only one monitor connected, you don't need to check this variable - it's purely for determining which monitor was touched if you have multiple.

Changing string to number is easy, just call tonumber() on it. A simple script to get a number from the user:

local num
repeat
  num = tonumber( read() )
until num

To measure the max size of your monitor, use this.


local mon = peripheral.wrap( "side" ) --#side is where monitor is attached
mon.setTextScale( 0.5 )
local x, y = mon.getSize()
print( x )
print( y )
adamjan2000 #11
Posted 23 January 2015 - 12:29 PM
So, is it this program good?
If there is something missing, could you write it?
I'll be very grateful

local mon = peripheral.wrap("left") - monitor on the left
local launcher = peripheral.wrap("right") - launch console on the right
local image = paintutils.loadImage("map")
paintutils.drawImage(image, 0, 0)
event, side, xPos, yPos = os.pullEvent("monitor_touch")
xPos=xPos*50+100 - depends for map
yPos=yPos*25+100 - depends for map
launcher.setTarget(xPos, 0, yPos) - setting coordinates of rocket
launcher.launch() - launching
KingofGamesYami #12
Posted 23 January 2015 - 02:21 PM
They only problem I see is where you are drawing the map - the upper-left pixel isn't (0,0) it's (1, 1)

Not sure why you're multiplying and adding xPos/yPos.

I'd also put everthing from os.pullEvent() on into a while true do … end loop, so it can be used more than once without restarting the program.
adamjan2000 #13
Posted 23 January 2015 - 04:20 PM
Is it better?
This multiplying and adding is needed to adapt map to the screen
Is there any way to load specified rocked into missle silo (the best option will be, in my
opinion, list of species of rockets, which can be show after click on a map)?

local mon = peripheral.wrap("left")
local launcher = peripheral.wrap("right")
local image = paintutils.loadImage("map")
paintutils.drawImage(image, 1, 1)
while true do
   event, side, xPos, yPos = os.pullEvent("monitor_touch")
   xPos=xPos*50+100
   yPos=yPos*25+100
   launcher.setTarget(xPos, 0, yPos)
   launcher.launch()
end
KingofGamesYami #14
Posted 23 January 2015 - 04:50 PM
That's indeed what I was getting at. I don't know much anything about the peripheral you are using (the launcher), so I have no idea what you can do with it.

If you are using CC 1.63+ and a turtle you might be able to simply turtle.drop() the item in.
adamjan2000 #15
Posted 23 January 2015 - 05:01 PM
Ok, but how program list of rockets on the monitor and send good order to turtle?
KingofGamesYami #16
Posted 23 January 2015 - 06:54 PM
Put them in a table, according to slots in the turtle.

Ei:

local rockets = {
 [1] = "rocket_type",
 [2] = "rocket_type",
 [3] = "rocket_type",
}

Then to display

for k, v in pairs( rockets ) do
  term.setCursorPos( 1, k )
  term.write( v )
end

As for click detection, you can easily check the y against the table, then use rednet to send the number to the turtle. The turtle will simply be waiting for a rednet message, then selecting a slot and dropping one item from that slot.
adamjan2000 #17
Posted 24 January 2015 - 04:25 PM
Will it work?

local mon = peripheral.wrap("left")
local launcher = peripheral.wrap("right")
local image = paintutils.loadImage("map")
local rockets = {
[1] = "rocket_type",
[2] = "rocket_type",
[3] = "rocket_type",
}
local a=1
local b=1
while true do
paintutils.drawImage(image, 1, 1)
   event, side, xPos, yPos = os.pullEvent("monitor_touch")
   a=xPos*50+100
   b=yPos*25+100
   launcher.setTarget(a, 0, B)/>
   clear
   print("Do you really want to launch?")
   setCursorPos(1,2)
   print("yes")
   setCursorPos(1,3)
   print("no")
   event, side, xPos, yPos = os.pullEvent("monitor_touch")
   if yPos=2 then
	  launcher.launch()
end