Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --inizialising global constants
- coorfile="coords-txt";
- redstoneside="top";
- coordoffset=1024;
- coordfactor=256;
- sensorside="back";
- startheight=64;
- sensor=peripheral.wrap(sensorside);
- while true do
- event=os.pullEvent();
- if redstone.getInput(redstoneside) then
- playerlist=sensor.getPlayers();
- if fs.exists(coorfile)==false then
- data={len=0,name={},x={},y={}}
- else
- file=fs.open(coorfile, "r");
- data=textutils.unserialize(file.readAll());
- file.close();
- end
- index=1
- while playerlist[index]~= nil do
- found=false;
- if data.len>0 then
- for i=1,data.len do
- if data.name[i]==playerlist[index].name then
- found=true;
- foundat=i;
- end
- end
- end
- if found then
- name=data.name[foundat];
- coordx=data.x[foundat];
- coordy=data.y[foundat];
- else
- data.len=data.len+1;
- name=playerlist[index].name;
- data.name[index]=name;
- puffx=math.sqrt(data.len-1)+1;
- puffxround=math.floor(puffx);
- roundnumber=puffxround*puffxround-2*puffxround+2;
- if puffx-puffxround>0.5 then
- data.y[data.len]=puffxround*coordfactor+coordoffset;
- data.x[data.len]=(1+data.len-roundnumber-puffxround)*coordfactor+coordoffset;
- else
- data.x[data.len]=puffxround*coordfactor+coordoffset;
- data.y[data.len]=(1+data.len-roundnumber)*coordfactor+coordoffset;
- end
- coordx=data.x[data.len];
- coordy=data.y[data.len];
- commands.tp(name,coordx,startheight+10,coordy);
- os.sleep(1);
- commands.setblock(coordx,startheight,coordy, "minecraft:dirt");
- commands.give(name, "minecraft:sapling", 2);
- commands.give(name, "minecraft:log", 8);
- file=fs.open(coorfile, "w");
- file.write(textutils.serialize(data));
- file.close();
- end
- commands.tp(name,coordx,startheight+1,coordy);
- index=index+1;
- end
- end
- if event=="key" then
- os.exit()
- end
- end
Add Comment
Please, Sign In to add comment