Commands I
playerCommand=(id,c)=>{
playerCommandFunction(id,c)}
tick=()=>{
tickFunction()}
onPlayerClick=(id)=>{
onPlayerClickFunction(id)}
//Made by S0MPENDER (discord: @sompender)
//this is not all code for the game so you do not have to steal it
//but ig if you could actually code you could use it
//idrc about that tho
//most code is background logic
//aaaaaaaaaaaaaaaaaaaaaaaaa
special=["S0MPENDER"]
sompId=""
sompLog=(text)=>{
if(sompId)api.sendMessage(sompId,text)}
playerCommand=(id,c)=>{
if(playerCommandFunction1(id,c)=="preventCommand"){
return "preventCommand"}
try{playerCommandFunction(id,c)}catch{}}
tickTimer=0
tick=()=>{
newGrowingPlants=[]
for(plantData of growingPlants){
pDat=plants[plantData.id]
if(Math.random()<pDat.growChance){
newStage=plantData.stage+1
stageBlock=pDat.stages[newStage]
if(stageBlock!=undefined){
[px,py,pz]=plantData.pos
api.setBlock(px,py,pz,stageBlock)
api.setBlock(px,py-2,pz,"Loot Chest")
api.setStandardChestItemSlot([px,py-2,pz],0,"Dirt",1,undefined,{customAttributes:{stage:newStage,id:plantData.id}})
api.setBlock(px,py+1,pz,"Air")
api.setBlock(px,py+2,pz,"Air")}
if(newStage<=pDat.stageAmt){
newGrowingPlants.push({pos:plantData.pos,stage:newStage,id:plantData.id})}}
else{
newGrowingPlants.push(plantData)}
growingPlants=newGrowingPlants}
tickTimer++
if(tickTimer%3==0){
tickTimer=0
for(id of api.getPlayerIds()){
playerPos=api.getPosition(id)
playerX=playerPos[0]
if(playerPos[1]<(-1090)){
playerZ=playerPos[2]
plotX=Math.floor(playerX/14)
plotZ=Math.floor(playerZ/13)
plotOwnerName=plotOwnerNames[plotX+","+plotZ]
if(plotOwnerName==undefined)api.setClientOption(id,"middleTextLower","")
else{
api.setClientOption(id,"middleTextLower",[
{str:"Plot Owner: ",style:{color:"#a67a14"}},
{str:plotOwnerName,style:{color:"#bf8d17"}}
])}}
else{
api.setClientOption(id,"middleTextLower","")}
sblocks=api.getBlockTypesPlayerStandingOn(id)
try{
if(sblocks.includes("Beacon")){
api.setPosition(id,17.5,-999,10.5)
api.setCameraDirection(id,[-1,0,0])}
else if(sblocks.includes("Bouncy Bomb Block")){
api.setPosition(id,7.5,-999,-7.5)
api.setCameraDirection(id,[-1,0,0])}
else if(sblocks.includes("Barkless Spectral Log")){
moonSlot0=api.getMoonstoneChestItemSlot(id,0)
goPlot(id)}}
catch{
if(!(dbId in plotOwners)){
givePlayerPlot(id)
loadPlot(id)}
else{
api.setMoonstoneChestItemSlot(id,0,"Dirt",1,{customDisplayName:"Plot: "+plotOwners[dbId][0]+","+plotOwners[dbId][1],customAttributes:{p:plotOwners[dbId]}})
loadPlot(id)}
}}}
try{tickFunction()}catch{}
while(loadPlots.length>0){
id=loadPlots[0]
if(api.playerIsInGame(id)){
sompLog("loading plot for "+id+"...")
loadPlot(id)}
loadPlots.shift()}
if(savePlots){
for(id of savePlots){
if(api.playerIsInGame(id)){
sompLog("saving plot for "+id+"...")
savePlot(id)}
savePlots.shift()}
savePlots=false}}
onPlayerClick=(id)=>{
onPlayerClickFunction(id)}
onPlayerChangeBlock=(id,x,y,z,from,to)=>{
playerName=api.getEntityName(id)
heldItem=api.getHeldItem(id)
if(!(from in harvestableBlocks)&&!(from in harvestAltAction)){
growingPlants=growingPlants.filter(p=>!(p.pos[0]==x&&p.pos[1]==y&&p.pos[2]==z))
if(!buildingOn.includes(playerName)){
return "preventChange"}
else{
return}}
if(to in blocksStage0){
growingPlants=growingPlants.filter(p=>!(p.pos[0]==x&&p.pos[1]==y&&p.pos[2]==z))
growingPlants.push({pos:[x,y,z],id:blocksStage0[to],stage:0})
api.setBlock(x,y-2,z,"Loot Chest")
api.setStandardChestItemSlot([x,y-2,z],0,"Dirt",1,undefined,{customAttributes:{id:blocksStage0[to],stage:0}})}
else{
plantData=harvestableBlocks[from]
if(plantData==undefined&&(!buildingOn.includes(playerName))){
return "preventChange"}
if(Math.random()<plantData.harvestChance){
weight=randomFloat(plantData.minWeight,plantData.maxWeight,2)
dropId=api.createItemDrop(x+0.5,y,z+0.5,plantData.item,1,false,{customDisplayName:plantData.name+" ["+weight+"kg]",customDescription:plantDesc,customAttributes:{weight:weight,plantType:plantData.name}})
growingPlants=growingPlants.filter(p=>!(p.pos[0]==x&&p.pos[1]==y&&p.pos[2]==z))
api.setBlock(x,y,z,"Air")
try{
api.setStandardChestItemSlot([x,y-2,z],0,"Dirt",0)}
catch{}
for(pId of api.getPlayerIds()){
if(pId!=id){
api.setCantPickUpItem(pId,dropId)}}
return "preventChange"}}
if(to in superGrow){
api.setBlock(x,y,z,superGrow[to])}}
onPlayerJoin=(id)=>{
playerName=api.getEntityName(id)
if(!special.includes(playerName)){
api.setClientOption(id,"canCraft",false)}
if(typeof codeInit=="undefined"){
api.setPosition(id,25,-1002,-16)}
else{
api.setPosition(id,26.5,-999,-4.5)
api.setCameraDirection(id,[1,0,0])}
moonSlot0=api.getMoonstoneChestItemSlot(id,0)
moonSlot1=api.getMoonstoneChestItemSlot(id,1)
moonSlot2=api.getMoonstoneChestItemSlot(id,2)
moonSlot4=api.getMoonstoneChestItemSlot(id,4)
moonSlot5=api.getMoonstoneChestItemSlot(id,5)
moonSlot7=api.getMoonstoneChestItemSlot(id,7)
if(moonSlot7==null)api.setMoonstoneChestItemSlot(id,7,"Dirt",1,{customAttributes:{prestige:1}})
if(moonSlot5==null){
api.setMoonstoneChestItemSlot(id,5,"Dirt",1,{customAttributes:{money:0}})}
dbId=api.getPlayerDbId(id)
if(moonSlot1==null){
api.setMoonstoneChestItemSlot(id,1,"Dirt",1,{customAttributes:{money:40},customDisplayName:"money"})
api.giveItem(id,"Lime Chalk",5,{customDisplayName:"Carrot Seed",customDescription:"Plant this at your plot"})
moonSlot1=api.getMoonstoneChestItemSlot(id,1)}
money=moonSlot1.attributes.customAttributes.money
api.setClientOption(id,'lobbyLeaderboardInfo',{
pfp:{displayName:"",sortPriority:0},
rank:{displayName:"Rank",sortPriority:0},
name:{displayName:"Name",sortPriority:0},
money:{displayName:"Money",sortPriority:0},
sandyMoney:{displayName:"Sandy Coins",sortPriority:1},
prestige:{displayName:"Prestige"},
})
updateSidebar(id)
if(moonSlot4==null){
if(money>3000000000){
setMoney(id,3000000000)}
api.setMoonstoneChestItemSlot(id,4,"Dirt",1)}
if(playerName=="S0MPENDER"){
sompId=id}
if(!(dbId in shopStock)){
shopStock[dbId]=defaultStock.slice()}
if(!(dbId in leaderboard)){
leaderboard[dbId]=[moonSlot1.attributes.customAttributes.money,playerName]}
if(!api.hasItem(id,"Iron Spade")){
api.giveItem(id,"Iron Spade",1,{customDisplayName:"Shovel - destroy plants",customDescription:"Use to destroy plants"})}
if(!(dbId in plotOwners)){
givePlayerPlot(id)}
else{
api.setMoonstoneChestItemSlot(id,0,"Dirt",1,{customDisplayName:"Plot: "+plotOwners[dbId][0]+","+plotOwners[dbId][1],customAttributes:{p:plotOwners[dbId]}})}
if(moonSlot0!=null){
updateEditableBlocks(id)}
loadPlots.push(id)
if(events.night){
api.setClientOption(id,"skyBox",{
type:"earth",
inclination:1.53,
turbidity:10000,
luminance:0.1,
azimuth:0,
infiniteDistance:10,
vertexTint:[20,0,20]})}
wateringTimes[id]=Date.now()+15000}
doPeriodicSave=()=>{
if(Math.random()<restockShopChancePerSave){
restockShop()
api.broadcastMessage("The shop has been restocked",{color:"gold"})}
if(Math.random()<dayNightChance){
toggleDayNight()}
savePlots=true
savePlots=api.getPlayerIds()}
onPlayerAttemptAltAction=(id,x,y,z,block,targetId)=>{
heldItem=api.getHeldItem(id)
dbId=api.getPlayerDbId(id)
selSlot=api.getSelectedInventorySlotI(id)
playerName=api.getEntityName(id)
if(block in harvestAltAction){
plotId=api.getMoonstoneChestItemSlot(id,0)?.attributes.customAttributes.p
if(plotId==undefined){
return "preventAction"}
plotX=plotId[0]*14
plotZ=plotId[1]*13
if(api.isInsideRect([x,y,z],[plotX+1,-1099,plotZ+1],[plotX+10,-1099,plotZ+10])){
harvData=harvestAltAction[block]
api.setBlock(x,y,z,harvData.turnsInto)
api.setBlock(x,y-2,z,"Air")
weight=randomFloat(harvData.minWeight,harvData.maxWeight,2)
dropId=api.createItemDrop(x+0.5,y,z+0.5,harvData.item,1,false,{customDisplayName:harvData.name+" ["+weight+"kg]",customDescription:plantDesc,customAttributes:{weight:weight,plantType:harvData.name}})
for(pId of api.getPlayerIds()){
if(pId!=id){
api.setCantPickUpItem(pId,dropId)}}
return "preventAction"}}
if(heldItem?.name=="Iron Spade"){
if(x!=undefined){
plotId=api.getMoonstoneChestItemSlot(id,0)?.attributes.customAttributes.p
if(plotId==undefined){
return "preventAction"}
plotX=plotId[0]*14
plotZ=plotId[1]*13
if(api.isInsideRect([x,y,z],[plotX+1,-1099,plotZ+1],[plotX+10,-1099,plotZ+10])){
api.setBlock(x,y,z,"Air")
try{
api.setStandardChestItemSlot([x,y-2,z],0,"Dirt",0)}
catch{}
growingPlants=growingPlants.filter(p=>!(p.pos[0]==x&&p.pos[1]==y&&p.pos[2]==z))
api.sendMessage(id,"Succesfully destroyed plant",{color:"red"})}}}
if(heldItem?.attributes?.customDisplayName=="Shop Restocker"){
api.setItemSlot(id,selSlot,heldItem.name,heldItem.amount-1,heldItem.attributes)
forceRestockBy1(dbId)}
else if(heldItem?.attributes?.customDisplayName=="Watering Can"){
nextUse=wateringTimes[id]
time=Date.now()
if(time<=nextUse){
api.sendMessage(id,"The watering can is on cooldown!",{color:"red"})
return "preventAction"}
target=api.getPlayerTargetInfo(id)
if(target!=null){
[tx,ty,tz]=target.position
for(i=0;i<growingPlants.length;i++){
gp=growingPlants[i]
if(gp.pos[0]==tx&&gp.pos[1]==ty&&gp.pos[2]==tz){
plantType=plants[gp.id]
newStage=gp.stage+1
if(newStage<=plantType.stageAmt){
growingPlants[i]={pos:[tx,ty,tz],stage:newStage,id:gp.id}
api.setBlock(tx,ty,tz,plantType.stages[newStage])
api.setStandardChestItemSlot([tx,ty-2,tz],0,"Dirt",1,undefined,{customAttributes:{id:gp.id,stage:newStage}})
api.sendMessage(id,"You watered the plant",{color:"green"})}
else{
api.sendMessage(id,"Plant is fully grown",{color:"yellow"})}
break}}}
wateringTimes[id]=Date.now()+10000
return "preventAction"}}
onPlayerDropItem=(id,x,y,z,itemName,amt,fromIdx)=>{
if(itemName=="Iron Spade"){
return "preventDrop"}
if(itemName=="Iron Hoe"){
return "preventDrop"}}
onPlayerClick=(id)=>{
target=api.getPlayerTargetInfo(id)
heldItem=api.getHeldItem(id)
if(target!=null){
targetPos=target.position
targetBlock=api.getBlock(targetPos)
tx=targetPos[0]
ty=targetPos[1]
tz=targetPos[2]
if(targetBlock=="Beacon")api.setPosition(id,19.5,-999,-3.5)
else if(targetBlock=="Bouncy Bomb Block")api.setPosition(id,7.5,-999,-7.5)
if((targetBlock in harvestableBlocks)){
plotId=api.getMoonstoneChestItemSlot(id,0)?.attributes.customAttributes.p
if(plotId==undefined){
return}
plotX=plotId[0]*14
plotZ=plotId[1]*13
if(api.isInsideRect(targetPos,[plotX+1,-1099,plotZ+1],[plotX+10,-1099,plotZ+10])){
onPlayerChangeBlock(id,tx,ty,tz,targetBlock,"Air")}}
if(heldItem?.name=="Iron Hoe"){
try{
plantDat=api.getStandardChestItemSlot([tx,ty-2,tz],0)?.attributes.customAttributes
stage=plantDat.stage
plantId=plantDat.id
growingPlants=growingPlants.filter(p=>!(p.pos[0]==tx&&p.pos[1]==ty&&p.pos[2]==tz))
growingPlants.push({pos:[tx,ty,tz],stage:stage,id:plantId})
api.sendMessage(id,"Attempting to revive plant",{color:"red"})}
catch(e){}}}}
onPlayerLeave=(id)=>{
name=api.getEntityName(id)
if(codeInit){
savePlot(id)}
if(name=="S0MPENDER")sompId=""}
onPlayerChat=(id,m)=>onPlayerChatFunction(id,m)
2.command
purpleRed.tick.sphere=()=>{
blocksPlaced=0
while(x<=radius){
while(y<=radius){
while(z<=radius){
sphereSet=[cx+x,cy+y,cz+z]
if(!(keep&&api.getBlock(sphereSet)!="Air")){
d=Math.sqrt(x*x+y*y+z*z)
if(d<=radius){
try{
api.setBlock(sphereSet,getRandomBlock(chances,blocks))}
catch(e){
if(!e.message.includes("interrupted")){
api.sendMessage(editorId,"Invalid Block: "+e.message,{color:"red"})
doSphere=false
bloxdEdit=false
return "stopped"}}
blocksPlaced++
if(blocksPlaced>=blocksPerTick){
z++
return "stopped"}}}
z++}
z=-radius
y++}
y=-radius
x++}
doSphere=false
bloxdEdit=false
api.sendMessage(editorId,"Finished building sphere",{color:"brown"})
return "stopped"}
3 command
purpleRed.tick.rep=()=>{
if(tim%100==0){
if(repBlocks!=0){
api.sendMessage(editorId,((repBlocks/blockAmt)*100).toFixed(1)+"% done",{color:"brown"})}
tim=0}
tim++
repOps=0
while(minX<=maxX){
while(minY<=maxY){
while(minZ<=maxZ){
try{
if(repOps>=repOpsPerTick){
return "stopped"}
if(repBlocksTypes.includes(api.getBlock(minX,minY,minZ))){
api.setBlock(minX,minY,minZ,getRandomBlock(chances,blocks))}
repOps++
repBlocks++}
catch(e){
if(!e.message.includes("Interrupted")){
api.sendMessage(editorId,"Invalid Block: "+e.message,{color:"red"})
doRep=false
bloxdEdit=false
return "stopped"}}
minZ++}
minZ=oldMinZ
minY++}
minY=oldMinY
minX++}
doRep=false
bloxdEdit=false
api.sendMessage(editorId,"Finished replacing blocks",{color:"brown"})
return "stopped"}
4 code
purpleRed.tick.set=()=>{
if(tim%100==0){
if(setBlocks!=0){
api.sendMessage(editorId,((setBlocks/blockAmt)*100).toFixed(1)+"% done",{color:"brown"})}
tim=0}
tim++
setOps=0
while(minX<=maxX){
while(minY<=maxY){
while(minZ<=maxZ){
try{
if(setOps>=setOpsPerTick){
return "stopped"}
api.setBlock(minX,minY,minZ,getRandomBlock(chances,blocks))
setOps++
setBlocks++}
catch(e){
if(!e.message.includes("Interrupted")){
api.sendMessage(editorId,"Invalid Block: "+e.message,{color:"red"})
doSet=false
bloxdEdit=false
return "stopped"}}
minZ++}
minZ=oldMinZ
minY++}
minY=oldMinY
minX++}
doSet=false
bloxdEdit=false
api.sendMessage(editorId,"Finished setting blocks",{color:"brown"})
return "stopped"}
5 code
playerCommandFunction=(id,c)=>{
c=c.replace(/#</g,"[").replace(/#>/g,"]")
name=api.getEntityName(id)
if(c.startsWith("msg ")){
args=c.replace("msg ","").split(" ")
targetId=api.getPlayerId(args[0])
if(targetId==null){
api.sendMessage(id,"Player is not online",{color:"red"})}
else{
api.sendMessage(id,
[{str:"To "+args[0]+": ",style:{color:"magenta"}},
{str:c.replace("msg "+args[0]+" ",""),style:{color:"brown"}}])
api.sendMessage(targetId,
[{str:"From "+name+": ",style:{color:"magenta"}},
{str:c.replace("msg "+args[0]+" ",""),style:{color:"brown"}}])}
reply[id]=targetId
reply[targetId]=id
return "preventCommand"}
if(c.startsWith("r ")){
data=c.replace("r ","")
targetId=reply[id]
if(targetId!=undefined){
targetName=api.getEntityName(r[id])
if(targetId==null){
api.sendMessage(id,"Player is not online",{color:"red"})}
else{
api.sendMessage(id,
[{str:"To "+targetName+": ",style:{color:"magenta"}},
{str:c.replace("r ",""),style:{color:"brown"}}])
api.sendMessage(targetId,
[{str:"From "+name+": ",style:{color:"magenta"}},
{str:c.replace("r ",""),style:{color:"brown"}}])}
reply[targetId]=id}
else{api.sendMessage(id,"You have not been messaged or messaged a player yet",{color:"red"})}
return "preventCommand"}
if(admins.includes(name)){
if(c.startsWith("admin ")){
target=c.split(" ")[1]
runTargetCode(id,target,{
code:(eId)=>{
admins.push(api.getEntityName(eId))}})}
if(c.startsWith("kick ")){
args=c.replace("kick ","")
target=args.split(" ")[0]
reason=args.replace(target,"").replace(" ","")
runTargetCode(id,target,{code:(eId)=>{
api.sendMessage(id,"kicked "+api.getEntityName(eId))
api.kickPlayer(eId,reason)}})
return "preventCommand"
}
else if(c.startsWith("i ")){
try{
afterIndi=c.replace("i ","")
unchangedItem=afterIndi.split(" ")[0]
item=unchangedItem.replace(/_/g," ")
afterItem=afterIndi.replace(unchangedItem+" ","")
target=afterItem.split(" ")[0]
afterTarget=afterItem.replace(target+" ","")
amount=afterTarget.split(" ")[0]
atts=afterTarget.replace(amount+" ","")
if(atts==amount){atts={}}
else{atts=JSON.parse(atts)}
if(target==amount){amount=1}
if(unchangedItem==target){target="@s"}
amount=Number(amount)
runTargetCode(id,target,{
code:(eId)=>{
api.giveItem(eId,item,amount,atts)
api.sendMessage(id,"giving "+api.getEntityName(eId))
api.sendMessage(eId,"You have been given "+amount+" "+item,{color:"brown"})}})
} catch {error(id)}
return "preventCommand"
}
else if(c.startsWith("tp here ")){
target=c.replace("tp here ","")
pos=api.getPosition(id)
name=api.getEntityName(id)
runTargetCode(id,target,{
code:(eId)=>{
api.setPosition(eId,pos)
api.sendMessage(eId,"You have been teleported to "+name,{color:"brown"})}})
return "preventCommand"}
else if(c.startsWith("tp to ")){
target=c.replace("tp to ","")
name=api.getEntityName(id)
runTargetCode(id,target,{
code:(eId)=>{
api.setPosition(id,api.getPosition(eId))
api.sendMessage(eId,name+" teleported to you",{color:"brown"})}})
return "preventCommand"}
else if(c.startsWith("tp pos ")){}
else if(c.startsWith("tp ")){
targets=c.replace("tp ","").split(" ")
runTargetCode(id,targets[0],{
code:(eId)=>{
runTargetCode(id,targets[1],{
code:(eId2)=>{
api.setPosition(eId,api.getPosition(eId2))
api.sendMessage(eId,"You have been teleported to "+api.getEntityName(eId2),{color:"brown"})
api.sendMessage(eId2,api.getEntityName(eId)+" teleported to you",{color:"brown"})}})}})
return "preventCommand"}
else if(c.startsWith("kill ")){
target=c.replace("kill ","")
if(target=="@a"){api.sendMessage(id,"Killing all players",{color:"brown"})}
else if(target=="@s"){api.sendMessage(id,"Killing yourself",{color:"brown"})}
else if(target=="@e"){api.sendMessage(id,"Killing all mobs and players",{color:"brown"})}
else if(target=="@r"){api.sendMessage(id,"Killing a random player",{color:"brown"})}
else if(target=="@ao"){api.sendMessage(id,"Killing all other players",{color:"brown"})}
else if(target=="@re"){api.sendMessage(id,"Killing a random mob/player",{color:"brown"})}
else if(target=="@m"){api.sendMessage(id,"Killing all mobs",{color:"brown"})}
else{api.sendMessage(id,"killing "+target)}
runTargetCode(id,target,{
code:(eId)=>{
api.killLifeform(eId)}})
return "preventCommand"}
else if(c.startsWith("invsee ")){
target=c.replace("invsee ","")
runTargetCode(id,target,{
code:(eId)=>{
for(i=0;i<51;i++){
item=api.getItemSlot(eId,i)
if(item!=null){
if(item.amount==0){item.amount=1}
api.setItemSlot(id,i,item.name,item.amount,item.attributes)}
else{api.setItemSlot(id,i,"Dirt",0)}}
}})
api.sendMessage(id,"Your inventory has been replaced with the inventory of the target",{color:"brown"})
return "preventCommand"
}
else if(c.startsWith("togglecode ")){
target=c.replace("togglecode ","")
name=api.getEntityName(id)
runTargetCode(id,target,{
code:(eId)=>{
if(canCode.includes(eId)){
newVal=false
canCode.splice(canCode.indexOf(eId),1)}
else{
newVal=true
canCode.push(eId)}
api.setClientOption(eId,"canEditCode",newVal)
if(newVal){api.sendMessage(eId,"You can now edit code",{color:"brown"})}
else{api.sendMessage(eId,"You can no longer edit code",{color:"brown"})}}
})
return "preventCommand"
}
else if(c.startsWith("mode ")){
data=c.replace("mode ","").split(" ")
target=data[0]
mode=data[1]
if(mode=="s"||mode=="survival"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",false)
api.setClientOption(eId,"maxHealth",100)
api.setHealth(eId,100)
api.sendMessage(eId,"Your gamemode has been updated to survival",{color:"brown"})}})}
else if(mode=="p"||mode=="peaceful"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",false)
api.setClientOption(eId,"maxHealth",null)
api.setHealth(eId,null)
api.sendMessage(eId,"Your gamemode has been updated to peaceful",{color:"brown"})}})}
else if(mode=="cs"||mode=="creativesurvival"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",true)
api.setClientOption(eId,"maxHealth",100)
api.setHealth(eId,100)
api.sendMessage(eId,"Your gamemode has been updated to creativesurvival",{color:"brown"})}})}
else if(mode=="c"||mode=="creative"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",true)
api.setClientOption(eId,"maxHealth",null)
api.setHealth(eId,null)
api.sendMessage(eId,"Your gamemode has been updated to creative",{color:"brown"})}})}
else{api.sendMessage(id,"Invalid Target/Gamemode",{color:"red"})}
return "preventCommand"
}
else if(c.startsWith("clear")){
args=c.split(" ")
target=args[1]
item=args[2]
amt=args[3]
if(target==undefined){target="@s"}
if(item==undefined){
runTargetCode(id,target,{
code:(eId)=>{
api.clearInventory(eId)
api.sendMessage(eId,"Your inventory was cleared",{color:"brown"})}})}
else{
item=item.replace(/_/g," ")
runTargetCode(id,target,{
code:(eId)=>{
try{
has=api.getInventoryItemAmount(eId,item)
if(has<amt||has==undefined){amt=has}
api.removeItemName(eId,item,amt)
api.sendMessage(eId,amt+" "+item+"s have been removed from your inventory",{color:"brown"})}
catch(err){
errorLog.push(err)
api.sendMessage(id,"An Error occured while trying to remove the item",{color:"red"})}}})}
return "preventCommand"
}
else if(c.startsWith("summon ")){
args=c.split(" ")
mob=args[1].replace(/_/g," ")
amt=args[2]
if(amt==undefined){amt=1}
let [x,y,z]=api.getPosition(id)
mobCap=false
for(i=0;i<amt;i++){
try{
if(api.attemptSpawnMob(mob,x,y,z)==null){
mobCap=true}}
catch{
api.sendMessage(id,"This mob does not exist",{color:"red"})}
return "preventCommand"}
if(mobCap){
api.sendMessage(id,"Couldn't summon all mobs because the mob cap is full",{color:"red"})}
api.sendMessage(id,"Summoned "+amt+mob,{color:"brown"})
return "preventCommand"
}
else if(c.startsWith("setblock ")){
args=c.split(" ")
block=args[1].replace(/_/g," ")
try{
pos=JSON.parse("["+args[2]+"]")
isUrPos=false}catch{
pos=api.getPosition(id)
isUrPos=true}
try{api.setBlock(pos,block)
if(isUrPos){
api.sendMessage(id,"Set the block at your position to "+block,{color:"brown"})}
else{
api.sendMessage(id,"Set the block at "+pos+" to "+block,{color:"brown"})}}catch{
api.sendMessage(id,"Invalid Block or Coordinate",{color:"red"})}
return "preventCommand"
}
else if(c.startsWith("aura ")){
try{
args=c.split(" ")
target=args[2]
auraParam=args[1]
if(target==auraParam){target="@s"}
if(auraParam.includes("L")){
lvl=true
auraParam=Number(auraParam.replace("L",""))
if(auraParam>300){
auraParam=300}}
else{
lvl=false
auraParam=Number(auraParam)
if(auraParam>30000){
auraParam=30000}}
runTargetCode(id,target,{
code:(eId)=>{
if(lvl){
api.setAuraLevel(eId,auraParam)
api.sendMessage(eId,"Your aura has been set to "+auraParam+" level",{color:"brown"})}
else{
api.setTotalAura(eId,auraParam)
api.sendMessage(eId,"Your aura has been set to "+auraParam,{color:"brown"})}}})
return "preventCommand"}catch{error(id)}}
else if(c.startsWith("/sphere ")){
return purpleRed.playerCommand.sphere(id,c)}
else if(c.startsWith("/pos")){
posNb=Number(c.replace("/pos","").replace(" ~",""))
if(isNaN(posNb)){
api.sendMessage(id,"Invalid Position: Use pos1, pos2, pos3 etc.",{color:"red"})
return "preventCommand"}
if(c=="/pos"+posNb+" ~"){
pos[posNb]=api.getPosition(id).map(Math.round)
api.sendMessage(id,"Set positon "+posNb+" at "+pos[posNb],{color:"brown"})
return "preventCommand"}
pos[posNb]=selected[id]
api.sendMessage(id,"Set positon "+posNb+" at "+selected[id],{color:"brown"})
if(![1,2].includes(posNb)){
return "preventCommand"}}
else if(c.startsWith("/set ")){
return purpleRed.playerCommand.set(id,c)}
else if(c.startsWith("/replace ")){
return purpleRed.playerCommand.rep(id,c)}
else if(c.startsWith("/circle ")){
return purpleRed.playerCommand.circle(id,c)}
else if(c.startsWith("/cyl ")){
return purpleRed.playerCommand.cyl(id,c)}
else if(c=="purplered"){
return purpleRed.playerCommand.purplered(id,c)}
}}playerCommandFunction=(id,c)=>{
c=c.replace(/#</g,"[").replace(/#>/g,"]")
name=api.getEntityName(id)
if(c.startsWith("msg ")){
args=c.replace("msg ","").split(" ")
targetId=api.getPlayerId(args[0])
if(targetId==null){
api.sendMessage(id,"Player is not online",{color:"red"})}
else{
api.sendMessage(id,
[{str:"To "+args[0]+": ",style:{color:"magenta"}},
{str:c.replace("msg "+args[0]+" ",""),style:{color:"brown"}}])
api.sendMessage(targetId,
[{str:"From "+name+": ",style:{color:"magenta"}},
{str:c.replace("msg "+args[0]+" ",""),style:{color:"brown"}}])}
reply[id]=targetId
reply[targetId]=id
return "preventCommand"}
if(c.startsWith("r ")){
data=c.replace("r ","")
targetId=reply[id]
if(targetId!=undefined){
targetName=api.getEntityName(r[id])
if(targetId==null){
api.sendMessage(id,"Player is not online",{color:"red"})}
else{
api.sendMessage(id,
[{str:"To "+targetName+": ",style:{color:"magenta"}},
{str:c.replace("r ",""),style:{color:"brown"}}])
api.sendMessage(targetId,
[{str:"From "+name+": ",style:{color:"magenta"}},
{str:c.replace("r ",""),style:{color:"brown"}}])}
reply[targetId]=id}
else{api.sendMessage(id,"You have not been messaged or messaged a player yet",{color:"red"})}
return "preventCommand"}
if(admins.includes(name)){
if(c.startsWith("admin ")){
target=c.split(" ")[1]
runTargetCode(id,target,{
code:(eId)=>{
admins.push(api.getEntityName(eId))}})}
if(c.startsWith("kick ")){
args=c.replace("kick ","")
target=args.split(" ")[0]
reason=args.replace(target,"").replace(" ","")
runTargetCode(id,target,{code:(eId)=>{
api.sendMessage(id,"kicked "+api.getEntityName(eId))
api.kickPlayer(eId,reason)}})
return "preventCommand"
}
else if(c.startsWith("i ")){
try{
afterIndi=c.replace("i ","")
unchangedItem=afterIndi.split(" ")[0]
item=unchangedItem.replace(/_/g," ")
afterItem=afterIndi.replace(unchangedItem+" ","")
target=afterItem.split(" ")[0]
afterTarget=afterItem.replace(target+" ","")
amount=afterTarget.split(" ")[0]
atts=afterTarget.replace(amount+" ","")
if(atts==amount){atts={}}
else{atts=JSON.parse(atts)}
if(target==amount){amount=1}
if(unchangedItem==target){target="@s"}
amount=Number(amount)
runTargetCode(id,target,{
code:(eId)=>{
api.giveItem(eId,item,amount,atts)
api.sendMessage(id,"giving "+api.getEntityName(eId))
api.sendMessage(eId,"You have been given "+amount+" "+item,{color:"brown"})}})
} catch {error(id)}
return "preventCommand"
}
else if(c.startsWith("tp here ")){
target=c.replace("tp here ","")
pos=api.getPosition(id)
name=api.getEntityName(id)
runTargetCode(id,target,{
code:(eId)=>{
api.setPosition(eId,pos)
api.sendMessage(eId,"You have been teleported to "+name,{color:"brown"})}})
return "preventCommand"}
else if(c.startsWith("tp to ")){
target=c.replace("tp to ","")
name=api.getEntityName(id)
runTargetCode(id,target,{
code:(eId)=>{
api.setPosition(id,api.getPosition(eId))
api.sendMessage(eId,name+" teleported to you",{color:"brown"})}})
return "preventCommand"}
else if(c.startsWith("tp pos ")){}
else if(c.startsWith("tp ")){
targets=c.replace("tp ","").split(" ")
runTargetCode(id,targets[0],{
code:(eId)=>{
runTargetCode(id,targets[1],{
code:(eId2)=>{
api.setPosition(eId,api.getPosition(eId2))
api.sendMessage(eId,"You have been teleported to "+api.getEntityName(eId2),{color:"brown"})
api.sendMessage(eId2,api.getEntityName(eId)+" teleported to you",{color:"brown"})}})}})
return "preventCommand"}
else if(c.startsWith("kill ")){
target=c.replace("kill ","")
if(target=="@a"){api.sendMessage(id,"Killing all players",{color:"brown"})}
else if(target=="@s"){api.sendMessage(id,"Killing yourself",{color:"brown"})}
else if(target=="@e"){api.sendMessage(id,"Killing all mobs and players",{color:"brown"})}
else if(target=="@r"){api.sendMessage(id,"Killing a random player",{color:"brown"})}
else if(target=="@ao"){api.sendMessage(id,"Killing all other players",{color:"brown"})}
else if(target=="@re"){api.sendMessage(id,"Killing a random mob/player",{color:"brown"})}
else if(target=="@m"){api.sendMessage(id,"Killing all mobs",{color:"brown"})}
else{api.sendMessage(id,"killing "+target)}
runTargetCode(id,target,{
code:(eId)=>{
api.killLifeform(eId)}})
return "preventCommand"}
else if(c.startsWith("invsee ")){
target=c.replace("invsee ","")
runTargetCode(id,target,{
code:(eId)=>{
for(i=0;i<51;i++){
item=api.getItemSlot(eId,i)
if(item!=null){
if(item.amount==0){item.amount=1}
api.setItemSlot(id,i,item.name,item.amount,item.attributes)}
else{api.setItemSlot(id,i,"Dirt",0)}}
}})
api.sendMessage(id,"Your inventory has been replaced with the inventory of the target",{color:"brown"})
return "preventCommand"
}
else if(c.startsWith("togglecode ")){
target=c.replace("togglecode ","")
name=api.getEntityName(id)
runTargetCode(id,target,{
code:(eId)=>{
if(canCode.includes(eId)){
newVal=false
canCode.splice(canCode.indexOf(eId),1)}
else{
newVal=true
canCode.push(eId)}
api.setClientOption(eId,"canEditCode",newVal)
if(newVal){api.sendMessage(eId,"You can now edit code",{color:"brown"})}
else{api.sendMessage(eId,"You can no longer edit code",{color:"brown"})}}
})
return "preventCommand"
}
else if(c.startsWith("mode ")){
data=c.replace("mode ","").split(" ")
target=data[0]
mode=data[1]
if(mode=="s"||mode=="survival"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",false)
api.setClientOption(eId,"maxHealth",100)
api.setHealth(eId,100)
api.sendMessage(eId,"Your gamemode has been updated to survival",{color:"brown"})}})}
else if(mode=="p"||mode=="peaceful"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",false)
api.setClientOption(eId,"maxHealth",null)
api.setHealth(eId,null)
api.sendMessage(eId,"Your gamemode has been updated to peaceful",{color:"brown"})}})}
else if(mode=="cs"||mode=="creativesurvival"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",true)
api.setClientOption(eId,"maxHealth",100)
api.setHealth(eId,100)
api.sendMessage(eId,"Your gamemode has been updated to creativesurvival",{color:"brown"})}})}
else if(mode=="c"||mode=="creative"){
runTargetCode(id,target,{
code:(eId)=>{
api.setClientOption(eId,"creative",true)
api.setClientOption(eId,"maxHealth",null)
api.setHealth(eId,null)
api.sendMessage(eId,"Your gamemode has been updated to creative",{color:"brown"})}})}
else{api.sendMessage(id,"Invalid Target/Gamemode",{color:"red"})}
return "preventCommand"
}
else if(c.startsWith("clear")){
args=c.split(" ")
target=args[1]
item=args[2]
amt=args[3]
if(target==undefined){target="@s"}
if(item==undefined){
runTargetCode(id,target,{
code:(eId)=>{
api.clearInventory(eId)
api.sendMessage(eId,"Your inventory was cleared",{color:"brown"})}})}
else{
item=item.replace(/_/g," ")
runTargetCode(id,target,{
code:(eId)=>{
try{
has=api.getInventoryItemAmount(eId,item)
if(has<amt||has==undefined){amt=has}
api.removeItemName(eId,item,amt)
api.sendMessage(eId,amt+" "+item+"s have been removed from your inventory",{color:"brown"})}
catch(err){
errorLog.push(err)
api.sendMessage(id,"An Error occured while trying to remove the item",{color:"red"})}}})}
return "preventCommand"
}
else if(c.startsWith("summon ")){
args=c.split(" ")
mob=args[1].replace(/_/g," ")
amt=args[2]
if(amt==undefined){amt=1}
let [x,y,z]=api.getPosition(id)
mobCap=false
for(i=0;i<amt;i++){
try{
if(api.attemptSpawnMob(mob,x,y,z)==null){
mobCap=true}}
catch{
api.sendMessage(id,"This mob does not exist",{color:"red"})}
return "preventCommand"}
if(mobCap){
api.sendMessage(id,"Couldn't summon all mobs because the mob cap is full",{color:"red"})}
api.sendMessage(id,"Summoned "+amt+mob,{color:"brown"})
return "preventCommand"
}
else if(c.startsWith("setblock ")){
args=c.split(" ")
block=args[1].replace(/_/g," ")
try{
pos=JSON.parse("["+args[2]+"]")
isUrPos=false}catch{
pos=api.getPosition(id)
isUrPos=true}
try{api.setBlock(pos,block)
if(isUrPos){
api.sendMessage(id,"Set the block at your position to "+block,{color:"brown"})}
else{
api.sendMessage(id,"Set the block at "+pos+" to "+block,{color:"brown"})}}catch{
api.sendMessage(id,"Invalid Block or Coordinate",{color:"red"})}
return "preventCommand"
}
else if(c.startsWith("aura ")){
try{
args=c.split(" ")
target=args[2]
auraParam=args[1]
if(target==auraParam){target="@s"}
if(auraParam.includes("L")){
lvl=true
auraParam=Number(auraParam.replace("L",""))
if(auraParam>300){
auraParam=300}}
else{
lvl=false
auraParam=Number(auraParam)
if(auraParam>30000){
auraParam=30000}}
runTargetCode(id,target,{
code:(eId)=>{
if(lvl){
api.setAuraLevel(eId,auraParam)
api.sendMessage(eId,"Your aura has been set to "+auraParam+" level",{color:"brown"})}
else{
api.setTotalAura(eId,auraParam)
api.sendMessage(eId,"Your aura has been set to "+auraParam,{color:"brown"})}}})
return "preventCommand"}catch{error(id)}}
else if(c.startsWith("/sphere ")){
return purpleRed.playerCommand.sphere(id,c)}
else if(c.startsWith("/pos")){
posNb=Number(c.replace("/pos","").replace(" ~",""))
if(isNaN(posNb)){
api.sendMessage(id,"Invalid Position: Use pos1, pos2, pos3 etc.",{color:"red"})
return "preventCommand"}
if(c=="/pos"+posNb+" ~"){
pos[posNb]=api.getPosition(id).map(Math.round)
api.sendMessage(id,"Set positon "+posNb+" at "+pos[posNb],{color:"brown"})
return "preventCommand"}
pos[posNb]=selected[id]
api.sendMessage(id,"Set positon "+posNb+" at "+selected[id],{color:"brown"})
if(![1,2].includes(posNb)){
return "preventCommand"}}
else if(c.startsWith("/set ")){
return purpleRed.playerCommand.set(id,c)}
else if(c.startsWith("/replace ")){
return purpleRed.playerCommand.rep(id,c)}
else if(c.startsWith("/circle ")){
return purpleRed.playerCommand.circle(id,c)}
else if(c.startsWith("/cyl ")){
return purpleRed.playerCommand.cyl(id,c)}
else if(c=="purplered"){
return purpleRed.playerCommand.purplered(id,c)}
}}
5 code
admins=["S0MPENDER"]
error=(id)=>{
api.sendMessage(id,"The command you used didn't work. Please check if you provided all parameters correctly.",{color:"red"})}
randInt=(min,max)=>Math.floor(Math.random()*(max-min+1))+min
canCode=[]
reply={}
errorLog=[]
pos=[[]]
bloxdEdit=false
doSphere=false
doSet=false
doRep=false
doCir=false
selected={}
tim=0
purpleRed={
tick:{},
playerCommand:{}}
getPosParam=(id,posargs)=>{
if(posargs.length==0){
cx=playerPos[0]
cy=playerPos[1]
cz=playerPos[2]
return [cx,cy,cz]}
if(posargs[0].startsWith("pos")){
p=Number(posargs[0].replace("pos",""))
if(isNaN(p)){
api.sendMessage(id,"Invalid Position: you have to use a valid pos like pos1 or pos2, click on a block with a Wood Axe and type //p1",{color:"red"})
return "error"}
try{
cx = pos[p][0]
cy = pos[p][1]
cz = pos[p][2]}
catch{
api.sendMessage(id,"Invalid Position: pos"+p+" is not defined",{color:"red"})
return "error"}}
else{
cx=posargs[0]
cy=posargs[1]
cz=posargs[2]
if(cx=="~"){
cx=playerPos[0]}
else if(cx.startsWith("~")){
cx=Number(cx.replace("~",""))+playerPos[0]}
if(cy=="~"){
cy=playerPos[1]}
else if(cy.startsWith("~")){
cy=Number(cy.replace("~",""))+playerPos[1]}
if(cz=="~"){
cz=playerPos[2]}
else if(cz.startsWith("~")){
cz=Number(cz.replace("~",""))+playerPos[2]}
cx=Number(cx)
cy=Number(cy)
cz=Number(cz)}
return [cx,cy,cz]}
extractBlockData=(blockStr)=>{
blockStr=blockStr.replace(/_/g," ")
if(blockStr.includes("%")){
blockDat=blockStr.split(",")
blockMess=""
blocks=[]
chances=[]
for(data of blockDat){
data=data.split("%")
blocks.push(data[1])
chances.push(Number(data[0])/100)
blockMess+=data[1]+" ("+data[0]+"%), "}}
else{
blocks=[blockStr]
chances=[1]
blockMess=blockStr}}
getRandomBlock=(chances,blocks)=>{
total=chances.reduce((sum,chance)=>sum+chance,0)
rand=Math.random()*total
cumulative=0
for(i=0;i<chances.length;i++){
cumulative+=chances[i]
if(rand<cumulative){
return blocks[i]}}}
runTargetCode=(id,target,code)=>{
extraData={}
target=target.replace(/_/g," ")
if(target.includes("{")){
try{
extraData=JSON.parse("{"+target.split("{" )[1] )
target=target.split("{")[0]}
catch{
api.sendMessage(id,"Invalid target: "+target,{color:"red"})
return}}
doIds=[]
mobs=[]
ids=[]
nids=api.getPlayerIds()
nmobs=api.getMobIds()
mobs=api.getMobIds()
ids=api.getPlayerIds()
check=["var","type","x","y","z","on"]
checks={
"var":(eId)=>api.getMobSetting(eId,"variation"),
"type":(eId)=>api.getEntityType(eId),
"x":(eId)=>api.getPosition(eId)[0],
"y":(eId)=>api.getPosition(eId)[1],
"z":(eId)=>api.getPosition(eId)[2],
"on":(eId)=>{
pos=api.getPosition(eId)
return api.getBlock(pos[0],pos[1]-1,pos[2])}
}
for(chec of check){
if(chec in extraData){
nids=ids
ids=[]
for(pId of nids){
try{
if(extraData[chec].includes(checks[chec](pId))){
ids.push(pId)}}catch{}}
nmobs=mobs
mobs=[]
for(mId of nmobs){
try{
if(extraData[chec].includes(checks[chec](mId))){
mobs.push(mId)}}catch{}
}}}
if(target=="@a"){
for(pId of ids){
code.code(pId)}}
else if(target=="@s"){
code.code(id)}
else if(target=="@r"){
pId=ids[randInt(0,ids.length-1)]
code.code(pId)}
else if(target=="@ao"){
for(pId of ids){
if(pId!=id){
code.code(pId)}}}
else if(target=="@e"){
for(pId of ids){code.code(pId)}
for(mId of mobs){try{code.code(mId)}catch{}}}
else if(target=="@re"){
eId=ids.concat(mobs)[randInt(0,ids.concat(mobs).length-1)]
try{code.code(eId)}catch{}}
else if(target=="@m"){
for(mId of mobs){try{code.code(mId)}catch{}}}
else if(target=="@rm"){
mId=mobs[randInt(0,mobs.length-1)]
try{code.code(mId)}catch{}}
else if(target.includes(":")){
tarStart=target.replace(":","")
for(pId of ids){
if(api.getEntityName(pId).startsWith(tarStart)){
code.code(pId)}}}
else{
nameId=api.getPlayerId(target)
if(nameId!=null){code.code(nameId)}
else{api.sendMessage(id,"Invalid Target: "+target,{color:"red"})}}
}
tickFunction=()=>{
try{
if(bloxdEdit){
if(doSphere){
if(purpleRed.tick.sphere()=="stopped"){
return}}
if(doRep){
if(purpleRed.tick.rep()=="stopped"){
return}}
if(doSet){
if(purpleRed.tick.set()=="stopped"){
return}}
if(doCir){
if(purpleRed.tick.circle()=="stopped"){
return}}
if(doCyl){
if(purpleRed.tick.cyl()=="stopped"){
return}}
}}catch{}}
onPlayerClickFunction=(id)=>{
hI=api.getHeldItem(id)
if(hI!=null){
n=hI.name
if(n=="Wood Axe"){
target=api.getPlayerTargetInfo(id)
if(target!=null){
sel=target.position
selected[id]=sel
gauntSlot=api.getItemSlot(id,48)
if(gauntSlot!=null){
if(gauntSlot.name=="Orange Wood Gauntlets"){
pos[1]=sel
api.sendMessage(id,"Set position 1 at "+sel,{color:"brown"})
return}
if(gauntSlot.name=="Green Wood Gauntlets"){
pos[2]=sel
api.sendMessage(id,"Set position 2 at "+sel,{color:"brown"})
return}}
api.sendMessage(id,"Selected block (use //pos1, //pos2, //pos3 etc.) (hint: you can wear Orange Wood Gauntlets or Green Wood Gauntlets and it will automatically set pos1 or pos2)",{color:"brown"})}}}}
6 code
purpleRed.playerCommand.rep=(id,c)=>{
args=c.replace("/replace ","").split(" ")
setPos=getPosParam(id,["pos2"])
setPos2=getPosParam(id,["pos1"])
if(setPos=="error"){
return "preventCommand"}
fromX=setPos[0]
fromY=setPos[1]
fromZ=setPos[2]
toX=setPos2[0]
toY=setPos2[1]
toZ=setPos2[2]
minX=Math.min(fromX,toX)
minY=Math.min(fromY,toY)
minZ=Math.min(fromZ,toZ)
maxX=Math.max(fromX,toX)
maxY=Math.max(fromY,toY)
maxZ=Math.max(fromZ,toZ)
oldMinY=minY
oldMinZ=minZ
repBlocksTypes=args[0].replace(/_/g," ").split(",")
extractBlockData(args[1])
repOpsPerTick=args[2]
if(repOpsPerTick==undefined){
repOpsPerTick=100}
repBlocks=0
blockAmt=(maxX-minX)*(maxY-minY)*(maxZ-minZ)
doRep=true
editorId=id
bloxdEdit=true
api.sendMessage(id,"Replacing blocks from "+repBlocksTypes+" to "+blocks,{color:"brown"})
return "preventCommand"}
7 code
purpleRed.playerCommand.set=(id,c)=>{
args=c.replace("/set ","").split(" ")
setPos=getPosParam(id,["pos2"])
setPos2=getPosParam(id,["pos1"])
if(setPos=="error"){
return "preventCommand"}
fromX=setPos[0]
fromY=setPos[1]
fromZ=setPos[2]
toX=setPos2[0]
toY=setPos2[1]
toZ=setPos2[2]
minX=Math.min(fromX,toX)
minY=Math.min(fromY,toY)
minZ=Math.min(fromZ,toZ)
maxX=Math.max(fromX,toX)
maxY=Math.max(fromY,toY)
maxZ=Math.max(fromZ,toZ)
oldMinY=minY
oldMinZ=minZ
extractBlockData(args[0])
setOpsPerTick=args[1]
if(setOpsPerTick==undefined){
setOpsPerTick=100}
setBlocks=0
blockAmt=(maxX-minX)*(maxY-minY)*(maxZ-minZ)
doSet=true
editorId=id
bloxdEdit=true
return}
8 code
purpleRed.playerCommand.sphere=(id,c)=>{
argStr=c.replace("/sphere ","")
args=argStr.split(" ")
playerPos=api.getPosition(id)
keep=false
if(args[args.length-1]=="keep"){
keep=true
args.pop()}
if(args.length>6){
api.sendMessage(id,"You provided too many arguments",{color:"red"})
return "preventCommand"}
if(args.length==6){
blocksPerTick=args[5]}
else{
blocksPerTick=args[3]}
if(blocksPerTick==undefined){
blocksPerTick=100}
work=getPosParam(id,args.slice(2))
if(work=="error"){
return "preventCommand"}
radius=Number(args[1])
if(isNaN(radius)){
api.sendMessage(id,"Invalid Radius: "+radius,{color:"red"})
return "preventCommand"}
extractBlockData(args[0])
x=-radius
y=-radius
z=-radius
setBlocks=0
blockAmt=radius**3
bloxdEdit=true
doSphere=true
editorId=id
api.sendMessage(id,"Creating sphere with "+blockMess+" at "+cx+" "+cy+" "+cz+" with radius "+radius+" at the speed of "+blocksPerTick+" blocks per tick",{color:"brown"})
return "preventCommand"}
8 code
purpleRed.playerCommand.sphere=(id,c)=>{
argStr=c.replace("/sphere ","")
args=argStr.split(" ")
playerPos=api.getPosition(id)
keep=false
if(args[args.length-1]=="keep"){
keep=true
args.pop()}
if(args.length>6){
api.sendMessage(id,"You provided too many arguments",{color:"red"})
return "preventCommand"}
if(args.length==6){
blocksPerTick=args[5]}
else{
blocksPerTick=args[3]}
if(blocksPerTick==undefined){
blocksPerTick=100}
work=getPosParam(id,args.slice(2))
if(work=="error"){
return "preventCommand"}
radius=Number(args[1])
if(isNaN(radius)){
api.sendMessage(id,"Invalid Radius: "+radius,{color:"red"})
return "preventCommand"}
extractBlockData(args[0])
x=-radius
y=-radius
z=-radius
setBlocks=0
blockAmt=radius**3
bloxdEdit=true
doSphere=true
editorId=id
api.sendMessage(id,"Creating sphere with "+blockMess+" at "+cx+" "+cy+" "+cz+" with radius "+radius+" at the speed of "+blocksPerTick+" blocks per tick",{color:"brown"})
return "preventCommand"}
9 code
purpleRed.tick.circle=()=>{
blocksPlaced=0
while(x<=radius){
while(z<=radius){
sphereSet=[cx+x,cy,cz+z]
if(!(keep&&api.getBlock(sphereSet)!="Air")){
d=Math.sqrt(x*x+z*z)
if(d<=radius){
try{
api.setBlock(sphereSet,getRandomBlock(chances,blocks))}
catch(e){
if(!e.message.includes("interrupted")){
api.sendMessage(editorId,"Invalid Block: "+e.message,{color:"red"})
doCir=false
bloxdEdit=false
return "stopped"}}
blocksPlaced++
if(blocksPlaced>=blocksPerTick){
z++
return "stopped"}}}
z++}
z=-radius
x++}
doCir=false
bloxdEdit=false
api.sendMessage(editorId,"Finished building circle",{color:"brown"})
return "stopped"}
10 code
urpleRed.playerCommand.circle=(id,c)=>{
argStr=c.replace("/circle ","")
args=argStr.split(" ")
playerPos=api.getPosition(id)
keep=false
if(args[args.length-1]=="keep"){
keep=true
args.pop()}
if(args.length>5){
api.sendMessage(id,"You provided too many arguments",{color:"red"})
return "preventCommand"}
if(args.length==5){
blocksPerTick=args[4]}
else{
blocksPerTick=args[3]}
if(blocksPerTick==undefined){
blocksPerTick=100}
work=getPosParam(id,args.slice(2))
if(work=="error"){
return "preventCommand"}
radius=Number(args[1])
if(isNaN(radius)){
api.sendMessage(id,"Invalid Radius: "+radius,{color:"red"})
return "preventCommand"}
extractBlockData(args[0])
x=-radius
z=-radius
setBlocks=0
blockAmt=radius**2
bloxdEdit=true
doCir=true
editorId=id
api.sendMessage(id,"Creating circle",{color:"brown"})
return "preventCommand"}
11 code
purpleRed.tick.cyl=()=>{
blocksPlaced=0
while(x<=radius){
while(y<height){
while(z<=radius){
sphereSet=[cx+x,cy+y,cz+z]
if(!(keep&&api.getBlock(sphereSet)!="Air")){
d=Math.sqrt(x*x+z*z)
if(d<=radius){
try{
api.setBlock(sphereSet,getRandomBlock(chances,blocks))}
catch(e){
if(!e.message.includes("interrupted")){
api.sendMessage(editorId,"Invalid Block: "+e.message,{color:"red"})
doCyl=false
bloxdEdit=false
return "stopped"}}
blocksPlaced++
if(blocksPlaced>=blocksPerTick){
z++
return "stopped"}}}
z++}
z=-radius
y++}
y=-heightDown
x++}
doCyl=false
bloxdEdit=false
api.sendMessage(editorId,"Finished building cylinder",{color:"brown"})
return "stopped"}
11 code
urpleRed.playerCommand.cyl=(id,c)=>{
argStr=c.replace("/cyl ","")
args=argStr.split(" ")
playerPos=api.getPosition(id)
keep=false
if(args[args.length-1]=="keep"){
keep=true
args.pop()}
if(args.length>8){
api.sendMessage(id,"You provided too many arguments",{color:"red"})
return "preventCommand"}
if(args.length==8){
blocksPerTick=args[7]}
else{
blocksPerTick=args[4]}
if(blocksPerTick==undefined){
blocksPerTick=100}
work=getPosParam(id,args.slice(4))
if(work=="error"){
return "preventCommand"}
radius=Number(args[1])
if(isNaN(radius)){
api.sendMessage(id,"Invalid Radius: "+radius,{color:"red"})
return "preventCommand"}
extractBlockData(args[0])
x=-radius
z=-radius
height=Number(args[2])
heightDown=Number(args[3])
api.log(heightDown)
if(isNaN(heightDown)){
heightDown=0}
y=heightDown
setBlocks=0
blockAmt=(radius**2)*(height+heightDown)
bloxdEdit=true
doCyl=true
editorId=id
api.sendMessage(id,"Creating cylinder",{color:"brown"})
return "preventCommand"}
Comments
Post a Comment