Jump to content




Turtle.attack() Rednet Toggle Possible?


  • You cannot reply to this topic
27 replies to this topic

#21 Alcheya

  • Members
  • 24 posts

Posted 30 September 2013 - 08:56 AM

View PostLordIkol, on 30 September 2013 - 07:16 AM, said:

Untested but should give you a clue about how it can work
Spoiler
edit: corrected an error now it should work ;D


Yes, it works and works well, but any reason why it would be incredibly more laggy than the standard "while true do" turtle attack program?

(with the normal program and all my machines/etc running, I'm normally sitting at about 50 fps.. with them running I dropped down to 6/7, even in another dimension with no mobs spawned)

#22 Alcheya

  • Members
  • 24 posts

Posted 30 September 2013 - 03:45 PM

Yep, something is definitely not right there. 60 fps without, down to 40 fps while the code is running, but when they go into attack mode, instant 6 fps. Sad times. :(

#23 Wojbie

  • Members
  • 631 posts
  • LocationKinda lost

Posted 30 September 2013 - 03:55 PM

I don't see how it could cause lag - I am using similar setup with more complicated code on turtles and more turtles - and no lag - what mods are you using/version of minecraft/SSP or SMP?

#24 Alcheya

  • Members
  • 24 posts

Posted 30 September 2013 - 04:09 PM

View Postwojbie, on 30 September 2013 - 03:55 PM, said:

I don't see how it could cause lag - I am using similar setup with more complicated code on turtles and more turtles - and no lag - what mods are you using/version of minecraft/SSP or SMP?

I'm sorry about that.

Using FTB Unleashed 1.1.4 SSP, but you're right, I don't know whats causing it. I was using 8 turtles with attack loop just fine the other day, but I guess something I did in the last 2 days ruined CC. I tried just doing basic attack loop on 1 turtle and I go from 60-70 fps down to 20. Ugh..

#25 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 01 October 2013 - 07:43 AM

To the fps problem, I would suggest to make a more reliable setup. Make the mobs move to one place via water or something, and then have one or two turtles just killing them. Saves space in your world and it should save a lot of 'lag'.

Thats the point of a mob grinder, have it as easy as possible and kill it. With your current setup. how are you going to collect the loot while you have the grinder running? Then the turtle is similair to lava, only there is no xp dropped.

#26 LordIkol

  • Members
  • 197 posts
  • LocationSwitzerland

Posted 02 October 2013 - 02:17 AM

Hi there sorry have not much time at the moment

I checked my Code again and see that you can reduce it to one while loop cause the parralell is executed in a while true loop you dont need the loop in the atk function.
Depending on your setup you can play around with the sleep command a bit to increase performance.
to make it easier for you to play around with the delay i added the delay as argument
if you start your program without arguments the delay is 1 second. if you want to start it with another delay just use <yourprogramname> x
where x is delay between attacks in seconds

rednet.open("right")
local running = true
args = ... or 1

local function atk()
if running == true then
turtle.attack()
print("attacking")
sleep(tonumber(args))
else
print("wait for command")
sleep(10)
end
end

local function switchit()
event, id, text = os.pullEvent()
if text == "on" then
running = true
elseif text =="off" then
running = false
print("Stop attack")
end
end

while true do
parallel.waitForAny(switchit,atk)
end

Greets Loki

Edited by LordIkol, 02 October 2013 - 02:34 AM.


#27 keyboardhack

  • Members
  • 4 posts

Posted 04 October 2013 - 06:40 PM

do this
cake = true
while true do
os.startTimer(1)
e,s,msg,dis = os.pullEvent()
if (e == "timer" and cake == true) then
turtle.attack()
elseif e == "rednet_message" then
if msg == "stop attacking" then
  cake = false
elseif msg == "start attacking" then
  cake = true
end
end
will stop the turtels when it receives a rednet message saying "stop attacking" and start again when it receives a rednet message saying "start attacking"

#28 MudkipTheEpic

  • Members
  • 639 posts
  • LocationWhere you'd least expect it.

Posted 04 October 2013 - 06:58 PM

The last

cake==true

needs to be:

cake=true







1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users