1688 posts
Location
'MURICA
Posted 18 November 2012 - 10:32 AM
implement
Making your life easier one implementation at a time.
DescriptionAllows you to append the code of another file at the top of the file(s) of your choosing. It also removes existing implementations. Useful if, for example, you have a checkFuel() function stored in another file, and you'd like to copy it over to other turtle programs.
Works with normal and advanced computers.
Usageimplement <source> into <file> (<file2> <file3> ...)
Downloadhttp://pastebin.com/rv2gGQDXScreenshots
536 posts
Posted 18 November 2012 - 10:54 AM
I'll let this pass my personal rule of not posting anything unless it's above or around 100 lines of code :)/>/>
It looks pretty good; but isn't it essentially fs.combine but with a comment either side of the inputted lines?
I kinda made something similar as my first program and am working on something vaguely similar to this now :D/>/>
1688 posts
Location
'MURICA
Posted 18 November 2012 - 11:07 AM
I'll let this pass my personal rule of not posting anything unless it's above or around 100 lines of code :)/>/>
It's pretty simple and tiny, but useful nonetheless. My analog clock was smaller, I'm pretty sure. :D/>/>
It looks pretty good; but isn't it essentially fs.combine but with a comment either side of the inputted lines?
Those comments are there so that the script knows there's an existing implementation, and to remove it before readding the implementation.
And I don't think this really does the job of fs.combine. Even if it did, there are a couple more features with this, and it's more convenient as a command line application.
I kinda made something similar as my first program and am working on something vaguely similar to this now :D/>/>
That's pretty cool. Good luck on that.
536 posts
Posted 18 November 2012 - 11:16 AM
not saying you shouldn't have made it, maybe try making it unimplement it by writing the file again but missing any lines which equal
"–IMPLEMENT base"
or
"–END"
and anything in between
I created this function for that other project and as it's of utter relevance to the suggestion I just made I though I would post it:
Spoiler
local function getChunk(lns, open, close)
local lines = {}
local on = false
for i=1,#lns do
local line = lns[i]
if line == close then on = false end
if on then
lines[#lines + 1] = line
end
if line == open then on = true end
end
return lines
end
This specific code gets all of the lines in a table (lns) between the opening and closing statement, but it could be easily modified to include the opening and closing statement.
1688 posts
Location
'MURICA
Posted 18 November 2012 - 11:28 AM
I would rather use :gsub than loop through the file's lines. I'll keep the suggestion in mind, though.