Posted 27 July 2014 - 10:10 AM
Hi folks
The Location Aware Movement API (LAMA) by fnuecke (https://github.com/fnuecke/lama) used some clever code to keep track of turtle positions even over chunk unload / reload and server restarts by peeking at the event queue sequence and comparing the current turtle fuel level to that which it had recorded to see if pending moves had completed or not.
Sadly with the upgrade to CC1.6 it looks like the keystone to the method has been removed and it no longer functions at all.
In 1.5x, CC turtle.native calls returned a numeric value corresponding to their command/event ID (https://github.com/f...apis/lama#L1608):
Then the LAMA code looks for a turtle_response event that matches (paraphrased code for the simplest case, for the real code see https://github.com/f...apis/lama#L1766):
So given that the CC API has moved on (from 1.6 the native calls return booleans instead), is there any way now for me to modify the LAMA approach, perhaps by injecting an event into the queue myself? I tried some experiments with os.queueEvent() / os.pullEventRaw() but that doesn't expose the event ids either.
I suspect I'm on a wild goose chase, but this is a pity since the utility of ComputerCraft would be hugely improved if turtles could reliably continue their work over restarts / chunk unloads. While I can understand the desire to keep the internals properly hidden, I'm left feeling that the only alternative is to look at competing mods that implement persistence as a core function…
Hope someone can help steer me onto a 'CC blessed' approach?
Mike
The Location Aware Movement API (LAMA) by fnuecke (https://github.com/fnuecke/lama) used some clever code to keep track of turtle positions even over chunk unload / reload and server restarts by peeking at the event queue sequence and comparing the current turtle fuel level to that which it had recorded to see if pending moves had completed or not.
Sadly with the upgrade to CC1.6 it looks like the keystone to the method has been removed and it no longer functions at all.
In 1.5x, CC turtle.native calls returned a numeric value corresponding to their command/event ID (https://github.com/f...apis/lama#L1608):
-- Process event queue (blocks until processed) and get the ID which is indicative of how long the turtle has lived (since command IDs grow
-- steadily over the lifetime of a computer). This is used for the validity checks below.
local id
repeat
os.sleep(0.1)
id = turtle.native.detect()
until id ~= -1
Then the LAMA code looks for a turtle_response event that matches (paraphrased code for the simplest case, for the real code see https://github.com/f...apis/lama#L1766):
local event, responseID, result = os.pullEvent("turtle_response")
if event == "turtle_response" then
if ids == responseID then
success = result
end
end
So given that the CC API has moved on (from 1.6 the native calls return booleans instead), is there any way now for me to modify the LAMA approach, perhaps by injecting an event into the queue myself? I tried some experiments with os.queueEvent() / os.pullEventRaw() but that doesn't expose the event ids either.
I suspect I'm on a wild goose chase, but this is a pity since the utility of ComputerCraft would be hugely improved if turtles could reliably continue their work over restarts / chunk unloads. While I can understand the desire to keep the internals properly hidden, I'm left feeling that the only alternative is to look at competing mods that implement persistence as a core function…
Hope someone can help steer me onto a 'CC blessed' approach?
Mike
Edited on 27 July 2014 - 03:55 PM