[Question]How to close a running program.
#1
Posted 27 November 2012 - 12:55 PM
#2
Posted 27 November 2012 - 12:59 PM
loadstring('me=read()')()
you are not allowed to make the global variable me so it errors
EDIT: a way around this is to write your information to a file and execute it. rather than
loadstring(yourcode)()use
local f=io.open('running','w')
f:write(yourcode)
f:close()
shell.run('running')
fs.delete('running')
if you do this you should also add something at the start of your program that checks if 'running' exists and either runs or deletes it (based on what you want it to do) because if you terminate, shutdown or restart the computer while it is running it will then remain, in turtles it is a bad idea to then start from the beginning again because they may be half way through making stairs to your base or something, restarting would then make them dig stairs through your base :| something I have done all too often. if it is a computer you may want to just restart running to do whatever was planned.... up to you
#3
Posted 27 November 2012 - 01:06 PM
#4
Posted 27 November 2012 - 01:08 PM
#5
Posted 27 November 2012 - 01:10 PM
local x = 4as opposed to
x = 4
#6
Posted 27 November 2012 - 01:18 PM
that isn't a great example as you can just term.redirect it but you get the general idea. in order for it to be executed exactly like local code it must be run from a program.
PS: if you know an alternate method PLEASE post it, I hate having to save files all the time, it's messy
#7
Posted 27 November 2012 - 01:31 PM
#8
Posted 27 November 2012 - 01:37 PM
#9
Posted 27 November 2012 - 01:41 PM
#10
Posted 27 November 2012 - 01:44 PM
#11
Posted 27 November 2012 - 02:00 PM
Lights and controlling stuff like that will be in a another system/building.
#12
Posted 27 November 2012 - 03:43 PM
if you are feeling super ambitious you can try a project I abandoned due to a loss of ccSensors, basically you have sensors everywhere in your base, recording everything, when you take something from a chest, where you stand, when you put something in a chest or anything like that, all of your activities should be recorded and then you can ask the server to assign a turtle that is not busy to perform those tasks for you, it can follow the path you took, take the items out of chests and load them in other places, I am not sure how to detect crafting recipes though to mimic that
do you know how coroutines work?
#13
Posted 27 November 2012 - 03:48 PM
#14
Posted 27 November 2012 - 03:52 PM
coroutines are Lua's way of imitating multitasking, running multiple codes almost simultaneously... strictly speaking it isn't simultaneous but it swaps between the threads so fast you cannot notice unless you do not yield
#15
Posted 27 November 2012 - 03:57 PM
#16
Posted 27 November 2012 - 03:59 PM
My second question is that having your own internet would allow people to search useful stuff/random stuff. And everything would be compatible.
#18
Posted 27 November 2012 - 04:03 PM
#19
Posted 27 November 2012 - 04:03 PM
#20
Posted 27 November 2012 - 04:06 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











