Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if turtle then pos = t.getPos() end
- if not fs.exists('config') then
- t.save({map=true}, 'config')
- end
- config = t.load('config')
- r = {val=true}
- if turtle then data = {
- x = {val=pos.x},
- y = {val=pos.y},
- z = {val=pos.z},
- direction = {val=pos.direction},
- label = {val=os.getComputerLabel()},
- map = {val=config.map}
- } end
- s = {val='Save'}
- function save()
- pos.x = data.x.val
- pos.y = data.y.val
- pos.z = data.z.val
- pos.direction = data.direction.val
- t.save(pos,'locale')
- config.map = data.map.val
- t.save(config, 'config')
- os.setComputerLabel(data.label.val)
- s.val = 'Saved!'
- end
- if turtle then f = {
- gui.createField{data.x, typ='int', cursurPos={x=5,y=5}},
- gui.createField{data.y, typ='int', cursurPos={x=5,y=6}},
- gui.createField{data.z, typ='int', cursurPos={x=5,y=7}},
- gui.createField{data.direction, typ='options', cursurPos={x=5,y=8}, options={'North', 'East', 'South', 'West'}},
- gui.createField{data.map, typ='bool', cursurPos={x=25,y=5}},
- gui.createField{data.label, typ='string', cursurPos={x=8,y=10}, maxLength=15},
- gui.createField{s, typ='select', cursurPos={x=3,y=12}, func=save},
- gui.createField{{val='Exit'}, typ='select', cursurPos={x=31,y=12}, func=function() r.val=false end}
- }
- else f = {
- gui.createField{{val='Exit'}, typ='select', cursurPos={x=gui.default.width-10,y=gui.default.height-2}, func=function() r.val=false end}
- } end
- term.clear()
- gui.drawBox{colors.gray,{1,1},{gui.default.width,2}}
- if turtle then
- gui.writeText{'[Turtle Config]', cursurPos={x=12,y=1}, bg=colors.gray}
- term.setCursorPos(1,3)
- print('\nPosition:')
- print(' x: ')
- print(' y: ')
- print(' z: ')
- print(' d: ')
- print('\nLabel: ')
- gui.writeText{'Other config:', cursurPos={x=19,y=4}}
- gui.writeText{'Map: ', cursurPos={x=20,y=5}}
- else
- gui.writeText{'[Computer Config]', cursurPos={x=math.floor(gui.default.width/2)-9,y=1}, bg=colors.gray}
- term.setCursorPos(1,3)
- print('\nNo config options available!')
- end
- selection = {val=0}
- key = gui.createMenuListener{f, r, onChange=function() s.val = 'Save' end, sel=selection}
- click = gui.createMenuClickListener{f, r, sel=selection}
- parallel.waitForAny(key, click)
- gui.reset()
- print('Setup finished')
Add Comment
Please, Sign In to add comment