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

Summoning Signal Help

Started by TechedZombie, 24 March 2015 - 10:04 PM
TechedZombie #1
Posted 24 March 2015 - 11:04 PM
I was making a main terminal for my base that controlled everything. I had a bug with my summoning…


How it works is it sends a signal to a command computer and it summons a mob. I cannot figure out why it isnt working and I do not get an error on other side.



Command Computer Code

rednet.open("top")
while true do

  local id, msg = rednet.receive()

  if id == 0 then

	commands.summon(msg, 1220, 6, 1720)

  end

end

Terminal Code

function clearS()
  term.setBackgroundColor(colors.white)
  term.clear()
  term.setTextColor(colors.blue)
  term.setCursorPos(1,1)
end
clearS()
print("TechedZombie:Command-OS")
while true do
  inp = read()
  if inp:lower() == "pig" then

	commands.summon("Pig", 1220, 8, 1720)
  
  elseif inp:lower() == "clear" then

	term.setBackgroundColor(colors.white)
	term.clear()
  
  else

	shell.run(inp)
  
  end
  sleep(1)
  clearS()
  print("TechedZombie:Command-OS  V - Alpha 0.1")
end


Thank you!
Bomb Bloke #2
Posted 24 March 2015 - 11:44 PM
I don't see any use of rednet.send() in this code…?
TechedZombie #3
Posted 25 March 2015 - 08:39 PM
Oops! I uploaded wrong Code!
TechedZombie #4
Posted 25 March 2015 - 08:45 PM
I don't see any use of rednet.send() in this code…?

Sorry Wrong Version Build! Here is the actual code!


function clearS()
  term.setBackgroundColor(colors.white)
  term.clear()
  term.setTextColor(colors.blue)
  term.setCursorPos(1,1)
end
clearS()
print("TechedZombie:Command-OS")
while true do
  inp = read()
  if inp:lower() == "pig" then
 
    commands.summon("Pig", 1220, 8, 1720) 
   
  elseif inp:lower() == "clear" then
 
    term.setBackgroundColor(colors.white)
    term.clear()
   
  elseif inp:match("summon") == "summon" then
 
    sum = inp:sub(8, -1)
    rednet.send(10, sub)
    print("Summoning")
   
  else
 
    shell.run(inp)
   
  end 
  sleep(1)
  clearS()
  print("TechedZombie:Command-OS  V - Alpha 0.1")
end
Bomb Bloke #5
Posted 26 March 2015 - 01:32 AM
Don't forget rednet.open().
TechedZombie #6
Posted 26 March 2015 - 08:46 PM
Don't forget rednet.open().
FacePalm
TechedZombie #7
Posted 27 March 2015 - 09:40 PM
Ok so I added rednet.open("back") and it still isn't working! HALP!
Bomb Bloke #8
Posted 28 March 2015 - 12:14 AM
Check that the ID numbers are correct.

Check that the systems aren't too far away from each other.

Rig the receiving system to print something every time it receives any message, and double-check that the sending system is printing "Summoning" when you use it.

Make sure you're typing the mob name using the correct capitalisation.
TechedZombie #9
Posted 28 March 2015 - 12:30 AM
Yes to all of those things its like 20 blocks away and the ids are correct the Mob name is case-correct and they both print the right things
Check that the ID numbers are correct.

Check that the systems aren't too far away from each other.

Rig the receiving system to print something every time it receives any message, and double-check that the sending system is printing "Summoning" when you use it.

Make sure you're typing the mob name using the correct capitalisation.
Bomb Bloke #10
Posted 28 March 2015 - 01:09 AM
Excellent! So if the receiver prints when the sender sends, we know the message is getting through.

Since the IDs are correct, that leaves only the summon command itself. Methinks you should check the co-ordinates - you've got one script targeting world layer 6, and one script targeting world layer 8. Is that as things should be?
TechedZombie #11
Posted 28 March 2015 - 01:43 AM
Yep
Bomb Bloke #12
Posted 28 March 2015 - 02:47 AM
In that case, if you STILL can't get it to work, have the receiving system output the command it's executing directly before attempting to perform it:

if id == 0 then
        print("summon "..msg.." 1220 6 1720")
        commands.summon(msg, 1220, 6, 1720)
end

If the result looks ok, go into the Lua prompt and test the command for yourself there. You'll get a success or a failure message - what's it say?
Edited on 28 March 2015 - 01:51 AM
TechedZombie #13
Posted 29 March 2015 - 09:30 PM
In that case, if you STILL can't get it to work, have the receiving system output the command it's executing directly before attempting to perform it:

if id == 0 then
		print("summon "..msg.." 1220 6 1720")
		commands.summon(msg, 1220, 6, 1720)
end

If the result looks ok, go into the Lua prompt and test the command for yourself there. You'll get a success or a failure message - what's it say?

It says false summon (<entityname> [x] [y] [z] [DataTag])
Bomb Bloke #14
Posted 30 March 2015 - 06:08 AM
In response to… what? I'd really only expect you to get that output if you didn't pass any parameters at all. What command did you use?
TechedZombie #15
Posted 30 March 2015 - 11:53 PM
I typed in first :
rednet.open("top")
id, message = rednet.receive()
commands.summon(msg, MyCoordsHere)
Bomb Bloke #16
Posted 31 March 2015 - 07:12 AM
So what's "msg" supposed to be, given that your stored your incoming rednet signal in "message"…?

What I asking you to do was report on what happens when you enter the command your actual script printed when it encountered this line I asked you to add to it earlier:

print("summon "..msg.." 1220 6 1720")

Let's say that printed out "summon Cow 1220 6 1720". You then go to the Lua console and enter commands.exec("summon Cow 1220 6 1720"), character for character. Don't use variables, use the exact syntax that print statement gave you.

What I want to know is what command do you end up entering, and what response do you get to it?
TechedZombie #17
Posted 31 March 2015 - 06:08 PM
So what's "msg" supposed to be, given that your stored your incoming rednet signal in "message"…?

What I asking you to do was report on what happens when you enter the command your actual script printed when it encountered this line I asked you to add to it earlier:

print("summon "..msg.." 1220 6 1720")

Let's say that printed out "summon Cow 1220 6 1720". You then go to the Lua console and enter commands.exec("summon Cow 1220 6 1720"), character for character. Don't use variables, use the exact syntax that print statement gave you.

What I want to know is what command do you end up entering, and what response do you get to it?

Oh I see I will try that and then tell you it will be a little while though because I am not presently at home
TechedZombie #18
Posted 31 March 2015 - 11:13 PM
I get Attempt to concatenate nil
So what's "msg" supposed to be, given that your stored your incoming rednet signal in "message"…?

What I asking you to do was report on what happens when you enter the command your actual script printed when it encountered this line I asked you to add to it earlier:

print("summon "..msg.." 1220 6 1720")

Let's say that printed out "summon Cow 1220 6 1720". You then go to the Lua console and enter commands.exec("summon Cow 1220 6 1720"), character for character. Don't use variables, use the exact syntax that print statement gave you.

What I want to know is what command do you end up entering, and what response do you get to it?

Oh I see I will try that and then tell you it will be a little while though because I am not presently at home
Edited on 31 March 2015 - 09:15 PM
HPWebcamAble #19
Posted 01 April 2015 - 02:09 AM
I get Attempt to concatenate nil

Make sure you use the same variables:

rednet.open("top")
id, message = rednet.receive()
commands.summon(message, MyCoordsHere)  --# You had 'msg' instead of 'message' originally

print("summon "..message.." 1 2 3") --# And here as well
TechedZombie #20
Posted 05 April 2015 - 08:18 PM
I get Attempt to concatenate nil

Make sure you use the same variables:

rednet.open("top")
id, message = rednet.receive()
commands.summon(message, MyCoordsHere)  --# You had 'msg' instead of 'message' originally

print("summon "..message.." 1 2 3") --# And here as well


Thanks but it still won't work but luckily dan announced a change it says : The “exec” program, commands.exec() and all related Command Computer functions now return the console output of the command. : So I think I can better bug fix now!