在我的函数命令()中有一个名为result4
的变量我还有一个函数copy_to_clipboard(id),它使用Id结果复制纹理中的文本。但是,我希望此函数从command()函数复制var result4。我该怎么做:
<button class="button" onclick="command();copy_to_clipboard('html');">Submit</button><br><br>
<script>
document.getElementById('submit').onclick = command;
function command() {
if (document.getElementById('essentials').checked) {
initiation = "minecraft:";
} else {
initiation = "";
}
if (document.getElementById('glow').checked) {
glow = "glowstone";
} else {
glow = "glass";
}
var x = document.getElementById("form");
var block = x.elements["block"].value;;
var type = x.elements["type"].value;
var replace_block = '"stone';
var replace_type = 'Damage:0s';
var replace_initiation = "minecraft:";
var replace_glowstone = "glowstone";
var filter1 = new RegExp(replace_block, 'g');
var filter2 = new RegExp(replace_type, 'g');
var filter3 = new RegExp(replace_glowstone, 'g');
var filter4 = new RegExp(replace_initiation, 'g');
var command =
`/summon falling_block ~ ~1 ~ {
Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/fill ~1 ~-1 ~1 ~-1 ~53 ~-1 air" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:0,Command:"/fill ~1 ~ ~1 ~-1 ~53 ~-1 air" } ,Passengers:[{ id:falling_block,Block:repeating_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.063 ~-1.9981 ~0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.063 ~-1.9982 ~-0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.063 ~-1.9983 ~-0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.063 ~-1.9984 ~0.063 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~ ~-1.998 ~ /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.3 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.113 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.074 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.261 ~-0.579 ~-0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[135f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.261 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.074 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.113 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.3 ~-0.579 ~0.06 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[315f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~-0.302 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~-0.115 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~0.072 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.059 ~-0.579 ~0.259 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[45f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~-0.260 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~-0.073 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~0.114 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.060 ~-0.579 ~0.301 /summon armor_stand ~ ~ ~ {Small:1b,Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[225f],ArmorItems:[{},{},{},{}],HandItems:[{id:\\"stone\\",Damage:0s,Count:1b},{}],CustomName:\\"Chest\\",DisabledSlots:2039583,Pose:{RightArm:[345f,0f,0f]}}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2203 ~-1.495 ~0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2206 ~-1.495 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2209 ~-1.432 ~0.155 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.2212 ~-1.432 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.495 ~0.2203 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.495 ~0.2206
/summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.432 ~0.2209 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.432 ~0.2212 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[90f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2203 ~-1.495 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2206 ~-1.495 ~0.155 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2209 ~-1.432 ~-0.156 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.2212 ~-1.432 ~0.155 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[180f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.495 ~-0.2206 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.495 ~-0.2203 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.156 ~-1.432 ~-0.2212 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.155 ~-1.432 ~-0.2209 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, Rotation:[270f],Small:1b,ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~ ~-1 ~ /setblock ~ ~ ~ glowstone 0" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.1881 ~-2.8751 ~0.1881 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.1883 ~-2.8753 ~-0.1883 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~-0.1885 ~-2.8755 ~0.1885 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Chest] ~0.1887 ~-2.8757 ~-0.1887 /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b, ArmorItems:[{},{},{},{id:\\"stone\\",Damage:0s,Count:1b}],HandItems:[{},{}],CustomName:\\"Chest\\",DisabledSlots:2039583}" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/minecraft:tp @e[type=Creeper,name=Chest] ~ -100 ~" } ,Passengers:[{ id:falling_block,Block:repeating_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/execute @e[type=Creeper,name=Remove] ~ ~ ~ /minecraft:kill @e[type=armor_stand,r=3,name=Chest]" } ,Passengers:[{ id:falling_block,Block:chain_command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/minecraft:tp @e[type=Creeper,name=Remove] ~ -100 ~" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/give @p minecraft:spawn_egg 1 51 {HideFlags:33,display:{Name:\\"Create Chest\\"},ench:[{id:1,lvl:0}],EntityTag:{id:\\"Creeper\\",CustomName:\\"Chest\\", ActiveEffects:[{Id:14,Amplifier:0,Duration:100,ShowParticles:0b}]}}" } ,Passengers:[{ id:falling_block,Block:command_block,Data:1,Time:1,TileEntityData:{ auto:1,Command:"/give @p minecraft:spawn_egg 1 51 {HideFlags:33,display:{Name:\\"Remove Chest\\"},ench:[{id:1,lvl:0}],EntityTag:{id:\\"Creeper\\",CustomName:\\"Remove\\", ActiveEffects:[{Id:14,Amplifier:0,Duration:100,ShowParticles:0b}]}}" } }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] }] } `;
var result1 = command.replace(filter1, '"' + block);
var result2 = result1.replace(filter2, 'Damage:' + type + 's');
var result3 = result2.replace(filter3, glow);
var result4 = result3.replace(filter4, initiation);
document.getElementById("result").value = result4;
}
function copy_to_clipboard(id) {
document.getElementById('result').select();
document.execCommand('copy');
}
</script>
<textarea id="result" rows="0" cols="0"></textarea><br>
答案 0 :(得分:0)
要复制result4
,您必须做三件事:
textarea
并将其放入body
。result4
设置为其值并选择它。execCommand
复制它,然后删除textarea
。<强>代码:强>
(将此代码放在'命令'函数内)
/* Create a temporary 'textarea' element. */
var temp = document.createElement("textarea");
/* Put the textarea to the body. */
document.body.appendChild(temp);
/* Set 'result4' as its value. */
temp.value = result4;
/* Select the textarea's content. */
temp.select();
/* Copy the selected text to the clipboard. */
document.execCommand("copy");
/* Delete the textarea. */
document.body.removeChild(temp);
<强>段:强>
function command () {
/* Your previous code... */
var result4 = "result4";
/* ---------- Solution ---------- */
/* Create a temporary 'textarea' element. */
var temp = document.createElement("textarea");
/* Put the textarea to the body. */
document.body.appendChild(temp);
/* Set 'result4' as its value. */
temp.value = result4;
/* Select the textarea's content. */
temp.select();
/* Copy the selected text to the clipboard. */
document.execCommand("copy");
/* Delete the textarea. */
document.body.removeChild(temp);
}
<!----- HTML ----->
<button class="button" onclick="command()">Submit</button>