diff --git a/src/generated/resources/data/computercraft/loot_tables/blocks/computer_advanced.json b/src/generated/resources/data/computercraft/loot_tables/blocks/computer_advanced.json index 74fb9c725..6ca0e4761 100644 --- a/src/generated/resources/data/computercraft/loot_tables/blocks/computer_advanced.json +++ b/src/generated/resources/data/computercraft/loot_tables/blocks/computer_advanced.json @@ -17,6 +17,9 @@ { "condition": "computercraft:block_named" }, + { + "condition": "computercraft:has_id" + }, { "condition": "minecraft:inverted", "term": { diff --git a/src/generated/resources/data/computercraft/loot_tables/blocks/computer_normal.json b/src/generated/resources/data/computercraft/loot_tables/blocks/computer_normal.json index 74fb9c725..6ca0e4761 100644 --- a/src/generated/resources/data/computercraft/loot_tables/blocks/computer_normal.json +++ b/src/generated/resources/data/computercraft/loot_tables/blocks/computer_normal.json @@ -17,6 +17,9 @@ { "condition": "computercraft:block_named" }, + { + "condition": "computercraft:has_id" + }, { "condition": "minecraft:inverted", "term": { diff --git a/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_advanced.json b/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_advanced.json index 74fb9c725..6ca0e4761 100644 --- a/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_advanced.json +++ b/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_advanced.json @@ -17,6 +17,9 @@ { "condition": "computercraft:block_named" }, + { + "condition": "computercraft:has_id" + }, { "condition": "minecraft:inverted", "term": { diff --git a/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_normal.json b/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_normal.json index 74fb9c725..6ca0e4761 100644 --- a/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_normal.json +++ b/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_normal.json @@ -17,6 +17,9 @@ { "condition": "computercraft:block_named" }, + { + "condition": "computercraft:has_id" + }, { "condition": "minecraft:inverted", "term": { diff --git a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java index 9582baada..720748e8f 100644 --- a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java +++ b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java @@ -46,10 +46,9 @@ public final class FixedWidthFontRenderer return (float) ((rgb[0] + rgb[1] + rgb[2]) / 3); } - private static int getColour( char c ) + private static int getColour( char c, Colour def ) { - int i = "0123456789abcdef".indexOf( c ); - return i < 0 ? 0 : 15 - i; + return 15 - Terminal.getColour( c, def ); } private static void drawChar( Matrix4f transform, IVertexBuilder buffer, float x, float y, int index, float r, float g, float b ) @@ -83,7 +82,7 @@ public final class FixedWidthFontRenderer private static void drawQuad( Matrix4f transform, IVertexBuilder buffer, float x, float y, float width, float height, Palette palette, boolean greyscale, char colourIndex ) { - double[] colour = palette.getColour( getColour( colourIndex ) ); + double[] colour = palette.getColour( getColour( colourIndex, Colour.BLACK ) ); float r, g, b; if( greyscale ) { @@ -151,7 +150,7 @@ public final class FixedWidthFontRenderer for( int i = 0; i < text.length(); i++ ) { - double[] colour = palette.getColour( 15 - "0123456789abcdef".indexOf( textColour.charAt( i ) ) ); + double[] colour = palette.getColour( getColour( textColour.charAt( i ), Colour.BLACK ) ); float r, g, b; if( greyscale ) { diff --git a/src/main/java/dan200/computercraft/core/terminal/Terminal.java b/src/main/java/dan200/computercraft/core/terminal/Terminal.java index 54503a02f..6f8f6b921 100644 --- a/src/main/java/dan200/computercraft/core/terminal/Terminal.java +++ b/src/main/java/dan200/computercraft/core/terminal/Terminal.java @@ -5,18 +5,20 @@ */ package dan200.computercraft.core.terminal; +import dan200.computercraft.shared.util.Colour; import dan200.computercraft.shared.util.Palette; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; public class Terminal { private static final String base16 = "0123456789abcdef"; - private int m_cursorX; - private int m_cursorY; - private boolean m_cursorBlink; - private int m_cursorColour; - private int m_cursorBackgroundColour; + private int m_cursorX = 0; + private int m_cursorY = 0; + private boolean m_cursorBlink = false; + private int m_cursorColour = 0; + private int m_cursorBackgroundColour = 15; private int m_width; private int m_height; @@ -25,9 +27,9 @@ public class Terminal private TextBuffer[] m_textColour; private TextBuffer[] m_backgroundColour; - private final Palette m_palette; + private final Palette m_palette = new Palette(); - private boolean m_changed; + private boolean m_changed = false; private final Runnable onChanged; public Terminal( int width, int height ) @@ -41,9 +43,6 @@ public class Terminal m_height = height; onChanged = changedCallback; - m_cursorColour = 0; - m_cursorBackgroundColour = 15; - m_text = new TextBuffer[m_height]; m_textColour = new TextBuffer[m_height]; m_backgroundColour = new TextBuffer[m_height]; @@ -53,14 +52,6 @@ public class Terminal m_textColour[i] = new TextBuffer( base16.charAt( m_cursorColour ), m_width ); m_backgroundColour[i] = new TextBuffer( base16.charAt( m_cursorBackgroundColour ), m_width ); } - - m_cursorX = 0; - m_cursorY = 0; - m_cursorBlink = false; - - m_changed = false; - - m_palette = new Palette(); } public synchronized void reset() @@ -323,6 +314,62 @@ public class Terminal m_changed = false; } + public synchronized void write( PacketBuffer buffer ) + { + buffer.writeInt( m_cursorX ); + buffer.writeInt( m_cursorY ); + buffer.writeBoolean( m_cursorBlink ); + buffer.writeByte( m_cursorBackgroundColour << 4 | m_cursorColour ); + + for( int y = 0; y < m_height; y++ ) + { + TextBuffer text = m_text[y]; + TextBuffer textColour = m_textColour[y]; + TextBuffer backColour = m_backgroundColour[y]; + + for( int x = 0; x < m_width; x++ ) + { + buffer.writeByte( text.charAt( x ) & 0xFF ); + buffer.writeByte( getColour( + backColour.charAt( x ), Colour.BLACK ) << 4 | + getColour( textColour.charAt( x ), Colour.WHITE ) + ); + } + } + + m_palette.write( buffer ); + } + + public synchronized void read( PacketBuffer buffer ) + { + m_cursorX = buffer.readInt(); + m_cursorY = buffer.readInt(); + m_cursorBlink = buffer.readBoolean(); + + byte cursorColour = buffer.readByte(); + m_cursorBackgroundColour = (cursorColour >> 4) & 0xF; + m_cursorColour = cursorColour & 0xF; + + for( int y = 0; y < m_height; y++ ) + { + TextBuffer text = m_text[y]; + TextBuffer textColour = m_textColour[y]; + TextBuffer backColour = m_backgroundColour[y]; + + for( int x = 0; x < m_width; x++ ) + { + text.setChar( x, (char) (buffer.readByte() & 0xFF) ); + + byte colour = buffer.readByte(); + backColour.setChar( x, base16.charAt( (colour >> 4) & 0xF ) ); + textColour.setChar( x, base16.charAt( colour & 0xF ) ); + } + } + + m_palette.read( buffer ); + setChanged(); + } + public synchronized CompoundNBT writeToNBT( CompoundNBT nbt ) { nbt.putInt( "term_cursorX", m_cursorX ); @@ -336,10 +383,8 @@ public class Terminal nbt.putString( "term_textColour_" + n, m_textColour[n].toString() ); nbt.putString( "term_textBgColour_" + n, m_backgroundColour[n].toString() ); } - if( m_palette != null ) - { - m_palette.writeToNBT( nbt ); - } + + m_palette.writeToNBT( nbt ); return nbt; } @@ -369,10 +414,15 @@ public class Terminal m_backgroundColour[n].write( nbt.getString( "term_textBgColour_" + n ) ); } } - if( m_palette != null ) - { - m_palette.readFromNBT( nbt ); - } + + m_palette.readFromNBT( nbt ); setChanged(); } + + public static int getColour( char c, Colour def ) + { + if( c >= '0' && c <= '9' ) return c - '0'; + if( c >= 'a' && c <= 'f' ) return c - 'a' + 10; + return 15 - def.ordinal(); + } } diff --git a/src/main/java/dan200/computercraft/data/LootTables.java b/src/main/java/dan200/computercraft/data/LootTables.java index 57854429a..416516b1b 100644 --- a/src/main/java/dan200/computercraft/data/LootTables.java +++ b/src/main/java/dan200/computercraft/data/LootTables.java @@ -8,6 +8,7 @@ package dan200.computercraft.data; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.data.BlockNamedEntityLootCondition; +import dan200.computercraft.shared.data.HasComputerIdLootCondition; import dan200.computercraft.shared.data.PlayerCreativeLootCondition; import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon; import net.minecraft.block.Block; @@ -73,6 +74,7 @@ public class LootTables extends LootTableProvider .addEntry( DynamicLootEntry.func_216162_a( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) ) .acceptCondition( Alternative.builder( BlockNamedEntityLootCondition.builder(), + HasComputerIdLootCondition.builder(), PlayerCreativeLootCondition.builder().inverted() ) ) ).build() ); diff --git a/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java b/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java index 6d8007820..2ce762435 100644 --- a/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java +++ b/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java @@ -6,7 +6,9 @@ package dan200.computercraft.shared.common; import dan200.computercraft.core.terminal.Terminal; +import io.netty.buffer.Unpooled; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; public class ClientTerminal implements ITerminal { @@ -53,7 +55,7 @@ public class ClientTerminal implements ITerminal { CompoundNBT terminal = nbt.getCompound( "terminal" ); resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) ); - m_terminal.readFromNBT( terminal ); + m_terminal.read( new PacketBuffer( Unpooled.wrappedBuffer( terminal.getByteArray( "term_contents" ) ) ) ); } else { diff --git a/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java b/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java index 3766bedf5..2b7d153a6 100644 --- a/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java +++ b/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java @@ -5,8 +5,12 @@ */ package dan200.computercraft.shared.common; +import dan200.computercraft.ComputerCraft; import dan200.computercraft.core.terminal.Terminal; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; import java.util.concurrent.atomic.AtomicBoolean; @@ -83,17 +87,28 @@ public class ServerTerminal implements ITerminal return m_colour; } - // Networking stuff - public void writeDescription( CompoundNBT nbt ) { nbt.putBoolean( "colour", m_colour ); if( m_terminal != null ) { + // We have a 10 byte header (2 integer positions, then blinking and current colours), followed by the + // contents and palette. + // Yes, this serialisation code is terrible, but we need to serialise to NBT in order to work with monitors + // (or rather tile entity serialisation). + final int length = 10 + (2 * m_terminal.getWidth() * m_terminal.getHeight()) + (16 * 3); + ByteBuf buffer = Unpooled.buffer( length ); + m_terminal.write( new PacketBuffer( buffer ) ); + + if( buffer.writableBytes() != 0 ) + { + ComputerCraft.log.warn( "Should have written {} bytes, but have {} ({} remaining).", length, buffer.writerIndex(), buffer.writableBytes() ); + } + CompoundNBT terminal = new CompoundNBT(); terminal.putInt( "term_width", m_terminal.getWidth() ); terminal.putInt( "term_height", m_terminal.getHeight() ); - m_terminal.writeToNBT( terminal ); + terminal.putByteArray( "term_contents", buffer.array() ); nbt.put( "terminal", terminal ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ComputerItemFactory.java b/src/main/java/dan200/computercraft/shared/computer/items/ComputerItemFactory.java index c3a3437c3..9cf4465e7 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ComputerItemFactory.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ComputerItemFactory.java @@ -19,9 +19,7 @@ public final class ComputerItemFactory @Nonnull public static ItemStack create( TileComputer tile ) { - String label = tile.getLabel(); - int id = label != null ? tile.getComputerID() : -1; - return create( id, label, tile.getFamily() ); + return create( tile.getComputerID(), tile.getLabel(), tile.getFamily() ); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java index f93c7498a..3ac904dc8 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java @@ -37,7 +37,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte @Override public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List list, @Nonnull ITooltipFlag options ) { - if( options.isAdvanced() ) + if( options.isAdvanced() || getLabel( stack ) == null ) { int id = getComputerID( stack ); if( id >= 0 ) diff --git a/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java b/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java new file mode 100644 index 000000000..4da10a15c --- /dev/null +++ b/src/main/java/dan200/computercraft/shared/data/HasComputerIdLootCondition.java @@ -0,0 +1,48 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ +package dan200.computercraft.shared.data; + +import dan200.computercraft.shared.computer.blocks.IComputerTile; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.world.storage.loot.LootParameter; +import net.minecraft.world.storage.loot.LootParameters; +import net.minecraft.world.storage.loot.conditions.ILootCondition; + +import javax.annotation.Nonnull; +import java.util.Collections; +import java.util.Set; + +/** + * A loot condition which checks if the tile entity has has a non-0 ID. + */ +public final class HasComputerIdLootCondition implements ILootCondition +{ + public static final HasComputerIdLootCondition INSTANCE = new HasComputerIdLootCondition(); + + private HasComputerIdLootCondition() + { + } + + @Override + public boolean test( LootContext lootContext ) + { + TileEntity tile = lootContext.get( LootParameters.BLOCK_ENTITY ); + return tile instanceof IComputerTile && ((IComputerTile) tile).getComputerID() >= 0; + } + + @Nonnull + @Override + public Set> getRequiredParameters() + { + return Collections.singleton( LootParameters.BLOCK_ENTITY ); + } + + public static IBuilder builder() + { + return () -> INSTANCE; + } +} diff --git a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java index 19562fb6e..bdc5318ed 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java @@ -184,7 +184,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I @Override public void addInformation( @Nonnull ItemStack stack, @Nullable World world, List list, ITooltipFlag flag ) { - if( flag.isAdvanced() ) + if( flag.isAdvanced() || getLabel( stack ) == null ) { int id = getComputerID( stack ); if( id >= 0 ) diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index 6a1981402..d22234ee9 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -19,6 +19,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer; import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.data.BlockNamedEntityLootCondition; import dan200.computercraft.shared.data.ConstantLootConditionSerializer; +import dan200.computercraft.shared.data.HasComputerIdLootCondition; import dan200.computercraft.shared.data.PlayerCreativeLootCondition; import dan200.computercraft.shared.media.items.RecordMedia; import dan200.computercraft.shared.network.NetworkHandler; @@ -79,6 +80,12 @@ public final class ComputerCraftProxyCommon PlayerCreativeLootCondition.class, PlayerCreativeLootCondition.INSTANCE ) ); + + LootConditionManager.registerCondition( ConstantLootConditionSerializer.of( + new ResourceLocation( ComputerCraft.MOD_ID, "has_id" ), + HasComputerIdLootCondition.class, + HasComputerIdLootCondition.INSTANCE + ) ); } private static void registerProviders() diff --git a/src/main/java/dan200/computercraft/shared/turtle/items/TurtleItemFactory.java b/src/main/java/dan200/computercraft/shared/turtle/items/TurtleItemFactory.java index 470668890..8370e7066 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/items/TurtleItemFactory.java +++ b/src/main/java/dan200/computercraft/shared/turtle/items/TurtleItemFactory.java @@ -6,6 +6,7 @@ package dan200.computercraft.shared.turtle.items; import dan200.computercraft.ComputerCraft; +import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.shared.computer.core.ComputerFamily; @@ -22,18 +23,13 @@ public final class TurtleItemFactory @Nonnull public static ItemStack create( ITurtleTile turtle ) { - ITurtleUpgrade leftUpgrade = turtle.getAccess().getUpgrade( TurtleSide.LEFT ); - ITurtleUpgrade rightUpgrade = turtle.getAccess().getUpgrade( TurtleSide.RIGHT ); + ITurtleAccess access = turtle.getAccess(); - String label = turtle.getLabel(); - if( label == null ) - { - return create( -1, null, turtle.getColour(), turtle.getFamily(), leftUpgrade, rightUpgrade, 0, turtle.getOverlay() ); - } - - int id = turtle.getComputerID(); - int fuelLevel = turtle.getAccess().getFuelLevel(); - return create( id, label, turtle.getColour(), turtle.getFamily(), leftUpgrade, rightUpgrade, fuelLevel, turtle.getOverlay() ); + return create( + turtle.getComputerID(), turtle.getLabel(), turtle.getColour(), turtle.getFamily(), + access.getUpgrade( TurtleSide.LEFT ), access.getUpgrade( TurtleSide.RIGHT ), + access.getFuelLevel(), turtle.getOverlay() + ); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/util/Palette.java b/src/main/java/dan200/computercraft/shared/util/Palette.java index 2758a6d11..bf4fc89f4 100644 --- a/src/main/java/dan200/computercraft/shared/util/Palette.java +++ b/src/main/java/dan200/computercraft/shared/util/Palette.java @@ -6,6 +6,7 @@ package dan200.computercraft.shared.util; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; public class Palette { @@ -78,6 +79,22 @@ public class Palette }; } + public void write( PacketBuffer buffer ) + { + for( double[] colour : colours ) + { + for( double channel : colour ) buffer.writeByte( (int) (channel * 0xFF) & 0xFF ); + } + } + + public void read( PacketBuffer buffer ) + { + for( double[] colour : colours ) + { + for( int i = 0; i < colour.length; i++ ) colour[i] = buffer.readByte() * 255; + } + } + public CompoundNBT writeToNBT( CompoundNBT nbt ) { int[] rgb8 = new int[colours.length]; diff --git a/src/main/resources/assets/computercraft/lang/da_dk.json b/src/main/resources/assets/computercraft/lang/da_dk.json new file mode 100644 index 000000000..fa2465308 --- /dev/null +++ b/src/main/resources/assets/computercraft/lang/da_dk.json @@ -0,0 +1,55 @@ +{ + + "block.computercraft.computer_normal": "Computer", + "block.computercraft.computer_advanced": "Avanceret Computer", + "block.computercraft.computer_command": "Kommandocomputer", + + "block.computercraft.disk_drive": "Diskdrev", + "block.computercraft.printer": "Printer", + "block.computercraft.speaker": "Højttaler", + + "block.computercraft.monitor_normal": "Skærm", + "block.computercraft.monitor_advanced": "Avanceret Skærm", + + "block.computercraft.wireless_modem_normal": "Trådløst Modem", + "block.computercraft.wireless_modem_advanced": "Endermodem", + + "block.computercraft.wired_modem": "Kablet Modem", + "block.computercraft.cable": "Netværkskabel", + + "block.computercraft.turtle_normal": "Turtle", + "block.computercraft.turtle_normal.upgraded": "%s Turtle", + "block.computercraft.turtle_normal.upgraded_twice": "%s %s Turtle", + + "block.computercraft.turtle_advanced": "Avanceret Turtle", + "block.computercraft.turtle_advanced.upgraded": "Avanceret %s Turtle", + "block.computercraft.turtle_advanced.upgraded_twice": "Avanceret %s %s Turtle", + + "item.computercraft.disk": "Floppydisk", + "item.computercraft.treasure_disk": "Floppydisk", + "item.computercraft.printed_page": "Printet Side", + "item.computercraft.printed_pages": "Printede Sider", + "item.computercraft.printed_book": "Printet Bog", + + "item.computercraft.pocket_computer_normal": "Lommecomputer", + "item.computercraft.pocket_computer_normal.upgraded": "%s Lommecomputer", + "item.computercraft.pocket_computer_advanced": "Avanceret Lommecomputer", + "item.computercraft.pocket_computer_advanced.upgraded": "Avanceret %s Lommecomputer", + + "upgrade.minecraft.diamond_sword.adjective": "Kæmpende", + "upgrade.minecraft.diamond_shovel.adjective": "Gravende", + "upgrade.minecraft.diamond_pickaxe.adjective": "Brydende", + "upgrade.minecraft.diamond_axe.adjective": "Fældende", + "upgrade.minecraft.diamond_hoe.adjective": "Dyrkende", + "upgrade.minecraft.crafting_table.adjective": "Fremstillende", + "upgrade.computercraft.wireless_modem_normal.adjective": "Trådløs", + "upgrade.computercraft.wireless_modem_advanced.adjective": "Endertrådløs", + "upgrade.computercraft.speaker.adjective": "Larmende", + + "chat.computercraft.wired_modem.peripheral_connected": "Perifer enhed \"%s\" koblet til netværk", + "chat.computercraft.wired_modem.peripheral_disconnected": "Perifer enhed \"%s\" koblet fra netværk", + + "gui.computercraft.tooltip.copy": "Kopier til udklipsholder", + "gui.computercraft.tooltip.computer_id": "Computer-ID: %s", + "gui.computercraft.tooltip.disk_id": "Disk-ID: %s" +} diff --git a/src/main/resources/assets/computercraft/lang/da_dk.lang b/src/main/resources/assets/computercraft/lang/da_dk.lang deleted file mode 100644 index 3da64d2a4..000000000 --- a/src/main/resources/assets/computercraft/lang/da_dk.lang +++ /dev/null @@ -1,48 +0,0 @@ -tile.computercraft:computer.name=Computer -tile.computercraft:advanced_computer.name=Avanceret Computer -tile.computercraft:drive.name=Diskdrev -tile.computercraft:printer.name=Printer -tile.computercraft:monitor.name=Skærm -tile.computercraft:advanced_monitor.name=Avanceret Skærm -tile.computercraft:wireless_modem.name=Trådløst Modem -tile.computercraft:wired_modem.name=Kablet Modem -tile.computercraft:cable.name=Netværkskabel -tile.computercraft:command_computer.name=Kommandocomputer -tile.computercraft:advanced_modem.name=Endermodem -tile.computercraft:speaker.name=Højttaler - -tile.computercraft:turtle.name=Turtle -tile.computercraft:turtle.upgraded.name=%s Turtle -tile.computercraft:turtle.upgraded_twice.name=%s %s Turtle -tile.computercraft:advanced_turtle.name=Avanceret Turtle -tile.computercraft:advanced_turtle.upgraded.name=Avanceret %s Turtle -tile.computercraft:advanced_turtle.upgraded_twice.name=Avanceret %s %s Turtle - -item.computercraft:disk.name=Floppydisk -item.computercraft:treasure_disk.name=Floppydisk -item.computercraft:page.name=Printet Side -item.computercraft:pages.name=Printede Sider -item.computercraft:book.name=Printet Bog - -item.computercraft:pocket_computer.name=Lommecomputer -item.computercraft:pocket_computer.upgraded.name=%s Lommecomputer -item.computercraft:advanced_pocket_computer.name=Avanceret Lommecomputer -item.computercraft:advanced_pocket_computer.upgraded.name=Avanceret %s Lommecomputer - -upgrade.minecraft:diamond_sword.adjective=Kæmpende -upgrade.minecraft:diamond_shovel.adjective=Gravende -upgrade.minecraft:diamond_pickaxe.adjective=Brydende -upgrade.minecraft:diamond_axe.adjective=Fældende -upgrade.minecraft:diamond_hoe.adjective=Dyrkende -upgrade.computercraft:wireless_modem.adjective=Trådløs -upgrade.minecraft:crafting_table.adjective=Fremstillende -upgrade.computercraft:advanced_modem.adjective=Endertrådløs -upgrade.computercraft:speaker.adjective=Larmende - -chat.computercraft.wired_modem.peripheral_connected=Perifer enhed "%s" koblet til netværk -chat.computercraft.wired_modem.peripheral_disconnected=Perifer enhed "%s" koblet fra netværk - -# Misc tooltips -gui.computercraft.tooltip.copy=Kopier til udklipsholder -gui.computercraft.tooltip.computer_id=(Computer-ID: %s) -gui.computercraft.tooltip.disk_id=(Disk-ID: %s) diff --git a/src/main/resources/assets/computercraft/lang/de_de.json b/src/main/resources/assets/computercraft/lang/de_de.json index 14a8ae879..596438a14 100644 --- a/src/main/resources/assets/computercraft/lang/de_de.json +++ b/src/main/resources/assets/computercraft/lang/de_de.json @@ -141,8 +141,8 @@ "tracking_field.computercraft.coroutines_dead.name": "Koroutinen gelöscht", "gui.computercraft.tooltip.copy": "In die Zwischenablage kopieren", - "gui.computercraft.tooltip.computer_id": "(Computer ID: %s)", - "gui.computercraft.tooltip.disk_id": "(Disketten ID: %s)", + "gui.computercraft.tooltip.computer_id": "Computer ID: %s", + "gui.computercraft.tooltip.disk_id": "Disketten ID: %s", "gui.computercraft.config.computer_space_limit": "Speicherplatz von Computern (bytes)", "gui.computercraft.config.floppy_space_limit": "Speicherplatz von Disketten (bytes)", diff --git a/src/main/resources/assets/computercraft/lang/en_us.json b/src/main/resources/assets/computercraft/lang/en_us.json index 22a5d1167..53514aa93 100644 --- a/src/main/resources/assets/computercraft/lang/en_us.json +++ b/src/main/resources/assets/computercraft/lang/en_us.json @@ -143,8 +143,8 @@ "tracking_field.computercraft.coroutines_dead.name": "Coroutines disposed", "gui.computercraft.tooltip.copy": "Copy to clipboard", - "gui.computercraft.tooltip.computer_id": "(Computer ID: %s)", - "gui.computercraft.tooltip.disk_id": "(Disk ID: %s)", + "gui.computercraft.tooltip.computer_id": "Computer ID: %s", + "gui.computercraft.tooltip.disk_id": "Disk ID: %s", "gui.computercraft.config.computer_space_limit": "Computer space limit (bytes)", "gui.computercraft.config.floppy_space_limit": "Floppy Disk space limit (bytes)", diff --git a/src/main/resources/assets/computercraft/lang/ko_kr.json b/src/main/resources/assets/computercraft/lang/ko_kr.json new file mode 100644 index 000000000..c3056c726 --- /dev/null +++ b/src/main/resources/assets/computercraft/lang/ko_kr.json @@ -0,0 +1,185 @@ +{ + "itemGroup.computercraft": "컴퓨터크래프트", + + "block.computercraft.computer_normal": "컴퓨터", + "block.computercraft.computer_advanced": "고급 컴퓨터", + "block.computercraft.computer_command": "명령 컴퓨터", + + "block.computercraft.disk_drive": "디스크 드라이브", + "block.computercraft.printer": "프린터", + "block.computercraft.speaker": "스피커", + + "block.computercraft.monitor_normal": "모니터", + "block.computercraft.monitor_advanced": "고급 모니터", + + "block.computercraft.wireless_modem_normal": "무선 모뎀", + "block.computercraft.wireless_modem_advanced": "엔더 모뎀", + + "block.computercraft.wired_modem": "유선 모뎀", + "block.computercraft.cable": "네트워크 케이블", + + "block.computercraft.turtle_normal": "터틀", + "block.computercraft.turtle_normal.upgraded": "%s 터틀", + "block.computercraft.turtle_normal.upgraded_twice": "%s %s 터틀", + + "block.computercraft.turtle_advanced": "고급 터틀", + "block.computercraft.turtle_advanced.upgraded": "고급 %s 터틀", + "block.computercraft.turtle_advanced.upgraded_twice": "고급 %s %s 터틀", + + "item.computercraft.disk": "플로피 디스크", + "item.computercraft.treasure_disk": "플로피 디스크", + "item.computercraft.printed_page": "인쇄된 페이지", + "item.computercraft.printed_pages": "인쇄된 페이지 모음", + "item.computercraft.printed_book": "인쇄된 책", + + "item.computercraft.pocket_computer_normal": "포켓 컴퓨터", + "item.computercraft.pocket_computer_normal.upgraded": "%s 포켓 컴퓨터", + "item.computercraft.pocket_computer_advanced": "고급 포켓 컴퓨터", + "item.computercraft.pocket_computer_advanced.upgraded": "고급 %s 포켓 컴퓨터", + + "upgrade.minecraft.diamond_sword.adjective": "난투", + "upgrade.minecraft.diamond_shovel.adjective": "굴착", + "upgrade.minecraft.diamond_pickaxe.adjective": "채굴", + "upgrade.minecraft.diamond_axe.adjective": "벌목", + "upgrade.minecraft.diamond_hoe.adjective": "농업", + "upgrade.minecraft.crafting_table.adjective": "조합", + "upgrade.computercraft.wireless_modem_normal.adjective": "무선", + "upgrade.computercraft.wireless_modem_advanced.adjective": "엔더", + "upgrade.computercraft.speaker.adjective": "소음", + + "chat.computercraft.wired_modem.peripheral_connected": "주변 \"%s\"이 네트워크에 연결되었습니다.", + "chat.computercraft.wired_modem.peripheral_disconnected": "주변 \"%s\"이 네트워크로부터 분리되었습니다.", + + "commands.computercraft.synopsis": "컴퓨터를 제어하기 위한 다양한 명령어", + "commands.computercraft.desc": "/computercraft 명령어는 컴퓨터를 제어하고 상호작용하기 위한 다양한 디버깅 및 관리자 도구를 제공합니다.", + + "commands.computercraft.help.synopsis": "특정 명령어에 대한 도움말을 제공하기", + "commands.computercraft.help.desc": "", + "commands.computercraft.help.no_children": "%s에는 하위 명령어가 없습니다.", + "commands.computercraft.help.no_command": "'%s'라는 명령어가 없습니다.", + + "commands.computercraft.dump.synopsis": "컴퓨터의 상태를 보여주기", + "commands.computercraft.dump.desc": "모든 시스템의 상태 또는 한 시스템에 대한 특정 정보를 표시합니다. 컴퓨터의 인스턴스 ID(예: 123)나 컴퓨터 ID(예: #123) 또는 라벨(예: \"@My Computer\")을 지정할 수 있습니다.", + "commands.computercraft.dump.action": "이 컴퓨터에 대한 추가 정보를 봅니다.", + + "commands.computercraft.shutdown.synopsis": "시스템을 원격으로 종료하기", + "commands.computercraft.shutdown.desc": "나열된 시스템 또는 지정된 시스템이 없는 경우 모두 종료합니다. 컴퓨터의 인스턴스 ID(예: 123)나 컴퓨터 ID(예: #123) 또는 라벨(예: \"@My Computer\")을 지정할 수 있습니다.", + "commands.computercraft.shutdown.done": "%s/%s 컴퓨터 시스템 종료", + + "commands.computercraft.turn_on.synopsis": "시스템을 원격으로 실행하기", + "commands.computercraft.turn_on.desc": "나열된 컴퓨터를 실행합니다. 컴퓨터의 인스턴스 ID(예: 123)나 컴퓨터 ID(예: #123) 또는 라벨(예: \"@My Computer\")을 지정할 수 있습니다.", + "commands.computercraft.turn_on.done": "%s/%s 컴퓨터 시스템 실행", + + "commands.computercraft.tp.synopsis": "특정 컴퓨터로 순간이동하기", + "commands.computercraft.tp.desc": "컴퓨터의 위치로 순간이동합니다. 컴퓨터의 인스턴스 ID(예: 123) 또는 컴퓨터 ID(예: #123)를 지정할 수 있습니다.", + "commands.computercraft.tp.action": "이 컴퓨터로 순간이동하기", + "commands.computercraft.tp.not_there": "월드에서 컴퓨터를 위치시킬 수 없습니다.", + + "commands.computercraft.view.synopsis": "컴퓨터의 터미널을 보기", + "commands.computercraft.view.desc": "컴퓨터의 원격 제어를 허용하는 컴퓨터의 터미널을 엽니다. 이것은 터틀의 인벤토리에 대한 접근을 제공하지 않습니다. 컴퓨터의 인스턴스 ID(예: 123) 또는 컴퓨터 ID(예: #123)를 지정할 수 있습니다.", + "commands.computercraft.view.action": "이 컴퓨터를 봅니다.", + "commands.computercraft.view.not_player": "비플레이어한테 터미널을 열 수 없습니다.", + + "commands.computercraft.track.synopsis": "컴퓨터의 실행 시간을 추적하기", + "commands.computercraft.track.desc": "컴퓨터가 실행되는 기간과 처리되는 이벤트 수를 추적합니다. 이는 /forge 트랙과 유사한 방법으로 정보를 제공하며 지연 로그에 유용할 수 있습니다.", + + "commands.computercraft.track.start.synopsis": "모든 컴퓨터의 추적을 시작하기", + "commands.computercraft.track.start.desc": "모든 컴퓨터의 이벤트 및 실행 시간 추적을 시작합니다. 이는 이전 실행의 결과를 폐기할 것입니다.", + "commands.computercraft.track.start.stop": "%s을(를) 실행하여 추적을 중지하고 결과를 확인합니다.", + + "commands.computercraft.track.stop.synopsis": "모든 컴퓨터의 추적을 중지하기", + "commands.computercraft.track.stop.desc": "모든 컴퓨터의 이벤트 및 실행 시간 추적을 중지합니다.", + "commands.computercraft.track.stop.action": "추적을 중지하려면 클릭하세요.", + "commands.computercraft.track.stop.not_enabled": "현재 추적하는 컴퓨터가 없습니다.", + + "commands.computercraft.track.dump.synopsis": "최신 추적 결과를 덤프하기", + "commands.computercraft.track.dump.desc": "최신 컴퓨터 추적의 결과를 덤프합니다.", + "commands.computercraft.track.dump.no_timings": "사용가능한 시간이 없습니다.", + "commands.computercraft.track.dump.computer": "컴퓨터", + + "commands.computercraft.reload.synopsis": "컴퓨터크래프트 구성파일을 리로드하기", + "commands.computercraft.reload.desc": "컴퓨터크래프트 구성파일을 리로드합니다.", + "commands.computercraft.reload.done": "리로드된 구성", + + "commands.computercraft.queue.synopsis": "computer_command 이벤트를 명령 컴퓨터에 보내기", + "commands.computercraft.queue.desc": "computer_command 이벤트를 명령 컴퓨터로 전송하여 추가 인수를 전달합니다. 이는 대부분 지도 제작자를 위해 설계되었으며, 보다 컴퓨터 친화적인 버전의 /trigger 역할을 합니다. 어떤 플레이어든 명령을 실행할 수 있으며, 이는 텍스트 구성 요소의 클릭 이벤트를 통해 수행될 가능성이 가장 높습니다.", + + "commands.computercraft.generic.no_position": "", + "commands.computercraft.generic.position": "%s, %s, %s", + "commands.computercraft.generic.yes": "Y", + "commands.computercraft.generic.no": "N", + "commands.computercraft.generic.exception": "처리되지 않은 예외 (%s)", + "commands.computercraft.generic.additional_rows": "%d개의 추가 행...", + + "argument.computercraft.computer.no_matching": "'%s'와 일치하는 컴퓨터가 없습니다.", + "argument.computercraft.computer.many_matching": "'%s'와 일치하는 여러 컴퓨터 (인스턴스 %s)", + + "tracking_field.computercraft.tasks.name": "작업", + "tracking_field.computercraft.total.name": "전체 시간", + "tracking_field.computercraft.average.name": "평균 시간", + "tracking_field.computercraft.max.name": "최대 시간", + + "tracking_field.computercraft.server_count.name": "서버 작업 수", + "tracking_field.computercraft.server_time.name": "서버 작업 시간", + + "tracking_field.computercraft.peripheral.name": "주변 호출", + "tracking_field.computercraft.fs.name": "파일시스템 작업", + "tracking_field.computercraft.turtle.name": "터틀 작업", + + "tracking_field.computercraft.http.name": "HTTP 요청", + "tracking_field.computercraft.http_upload.name": "HTTP 업로드", + "tracking_field.computercraft.http_download.name": "HTTT 다운로드", + + "tracking_field.computercraft.websocket_incoming.name": "웹소켓 수신", + "tracking_field.computercraft.websocket_outgoing.name": "웹소켓 송신", + + "tracking_field.computercraft.coroutines_created.name": "코루틴 생성됨", + "tracking_field.computercraft.coroutines_dead.name": "코루틴 처리됨", + + "gui.computercraft.tooltip.copy": "클립보드에 복사", + "gui.computercraft.tooltip.computer_id": "컴퓨터 ID: %s", + "gui.computercraft.tooltip.disk_id": "디스크 ID: %s", + + "gui.computercraft.config.computer_space_limit": "컴퓨터 공간 제한 (바이트)", + "gui.computercraft.config.floppy_space_limit": "플로피 디스크 공간 제한 (바이트)", + "gui.computercraft.config.maximum_open_files": "컴퓨터당 최대 파일 열기", + "gui.computercraft.config.disable_lua51_features": "Lua 5.1 기능 미사용", + "gui.computercraft.config.default_computer_settings": "기본 컴퓨터 설정", + "gui.computercraft.config.debug_enabled": "디버그 라이브러리 사용", + "gui.computercraft.config.log_computer_errors": "컴퓨터 오류 로그", + + "gui.computercraft.config.execution": "실행", + "gui.computercraft.config.execution.computer_threads": "컴퓨터 쓰레드", + "gui.computercraft.config.execution.max_main_global_time": "전역 시간 당 서버 제한", + "gui.computercraft.config.execution.max_main_computer_time": "컴퓨터 시간 당 서버 제한", + + "gui.computercraft.config.http": "HTTP", + "gui.computercraft.config.http.enabled": "HTTP API 사용하기", + "gui.computercraft.config.http.websocket_enabled": "웹소켓 사용", + + "gui.computercraft.config.http.timeout": "타임아웃", + "gui.computercraft.config.http.max_requests": "최대 동시 요청 수", + "gui.computercraft.config.http.max_download": "최대 응답 크기", + "gui.computercraft.config.http.max_upload": "최대 요청 크기", + "gui.computercraft.config.http.max_websockets": "최대 동시 웹소켓 수", + "gui.computercraft.config.http.max_websocket_message": "최대 웹 포켓 메시지 크기", + + "gui.computercraft.config.peripheral": "주변", + "gui.computercraft.config.peripheral.command_block_enabled": "명령 블록 주변 장치 사용", + "gui.computercraft.config.peripheral.modem_range": "모뎀 범위(기본값)", + "gui.computercraft.config.peripheral.modem_high_altitude_range": "모뎀 범위(높은 고도)", + "gui.computercraft.config.peripheral.modem_range_during_storm": "모뎀 범위(나쁜 날씨)", + "gui.computercraft.config.peripheral.modem_high_altitude_range_during_storm": "모뎀 범위(높은 고도, 나쁜 날씨)", + "gui.computercraft.config.peripheral.max_notes_per_tick": "컴퓨터가 한 번에 재생할 수 있는 최대 소리 수", + + "gui.computercraft.config.turtle": "터틀", + "gui.computercraft.config.turtle.need_fuel": "연료 사용", + "gui.computercraft.config.turtle.normal_fuel_limit": "터틀 연료 제한", + "gui.computercraft.config.turtle.advanced_fuel_limit": "고급 터틀 연료 제한", + "gui.computercraft.config.turtle.obey_block_protection": "터틀이 블록 보호에 따르기", + "gui.computercraft.config.turtle.can_push": "터틀이 엔티티 밀어내기", + "gui.computercraft.config.turtle.disabled_actions": "터틀 액션 미사용", + + "gui.computercraft.config.http.allowed_domains": "허용된 도메인", + "gui.computercraft.config.http.blocked_domains": "차단된 도메인" +} diff --git a/src/main/resources/assets/computercraft/lang/ko_kr.lang b/src/main/resources/assets/computercraft/lang/ko_kr.lang deleted file mode 100644 index 784bb4b31..000000000 --- a/src/main/resources/assets/computercraft/lang/ko_kr.lang +++ /dev/null @@ -1,195 +0,0 @@ -itemGroup.computercraft=컴퓨터크래프트 - -tile.computercraft:computer.name=컴퓨터 -tile.computercraft:advanced_computer.name=고급 컴퓨터 -tile.computercraft:drive.name=디스크 드라이브 -tile.computercraft:printer.name=프린터 -tile.computercraft:monitor.name=모니터 -tile.computercraft:advanced_monitor.name=고급 모니터 -tile.computercraft:wireless_modem.name=무선 모뎀 -tile.computercraft:wired_modem.name=유선 모뎀 -tile.computercraft:cable.name=네트워크 케이블 -tile.computercraft:command_computer.name=명령 컴퓨터 -tile.computercraft:advanced_modem.name=엔더 모뎀 -tile.computercraft:speaker.name=스피커 - -tile.computercraft:turtle.name=터틀 -tile.computercraft:turtle.upgraded.name=%s 터틀 -tile.computercraft:turtle.upgraded_twice.name=%s %s 터틀 -tile.computercraft:advanced_turtle.name=고급 터틀 -tile.computercraft:advanced_turtle.upgraded.name=고급 %s 터틀 -tile.computercraft:advanced_turtle.upgraded_twice.name=고급 %s %s 터틀 - -item.computercraft:disk.name=플로피 디스크 -item.computercraft:treasure_disk.name=플로피 디스크 -item.computercraft:page.name=인쇄된 페이지 -item.computercraft:pages.name=인쇄된 페이지 모음 -item.computercraft:book.name=인쇄된 책 - -item.computercraft:pocket_computer.name=포켓 컴퓨터 -item.computercraft:pocket_computer.upgraded.name=%s 포켓 컴퓨터 -item.computercraft:advanced_pocket_computer.name=고급 포켓 컴퓨터 -item.computercraft:advanced_pocket_computer.upgraded.name=고급 %s 포켓 컴퓨터 - -upgrade.minecraft:diamond_sword.adjective=난투 -upgrade.minecraft:diamond_shovel.adjective=굴착 -upgrade.minecraft:diamond_pickaxe.adjective=채굴 -upgrade.minecraft:diamond_axe.adjective=벌목 -upgrade.minecraft:diamond_hoe.adjective=농업 -upgrade.computercraft:wireless_modem.adjective=무선 -upgrade.minecraft:crafting_table.adjective=조합 -upgrade.computercraft:advanced_modem.adjective=엔더 -upgrade.computercraft:speaker.adjective=소음 - -chat.computercraft.wired_modem.peripheral_connected=주변 "%s"이 네트워크에 연결되었습니다. -chat.computercraft.wired_modem.peripheral_disconnected=주변 "%s"이 네트워크로부터 분리되었습니다. - -# Command descriptions, usage and any additional messages. -commands.computercraft.synopsis=컴퓨터를 제어하기 위한 다양한 명령어 -commands.computercraft.desc=/computercraft 명령어는 컴퓨터를 제어하고 상호작용하기 위한 다양한 디버깅 및 관리자 도구를 제공합니다. - -commands.computercraft.help.synopsis=특정 명령어에 대한 도움말을 제공하기 -commands.computercraft.help.desc= -commands.computercraft.help.usage=[command] -commands.computercraft.help.no_children=%s에는 하위 명령어가 없습니다. -commands.computercraft.help.no_command='%s'라는 명령어가 없습니다. - -commands.computercraft.dump.synopsis=컴퓨터의 상태를 보여주기 -commands.computercraft.dump.desc=모든 시스템의 상태 또는 한 시스템에 대한 특정 정보를 표시합니다. 컴퓨터의 인스턴스 ID(예: 123)나 컴퓨터 ID(예: #123) 또는 라벨(예: "@My Computer")을 지정할 수 있습니다. -commands.computercraft.dump.usage=[id] -commands.computercraft.dump.action=이 컴퓨터에 대한 추가 정보를 봅니다. - -commands.computercraft.shutdown.synopsis=시스템을 원격으로 종료하기 -commands.computercraft.shutdown.desc=나열된 시스템 또는 지정된 시스템이 없는 경우 모두 종료합니다. 컴퓨터의 인스턴스 ID(예: 123)나 컴퓨터 ID(예: #123) 또는 라벨(예: "@My Computer")을 지정할 수 있습니다. -commands.computercraft.shutdown.usage=[ids...] -commands.computercraft.shutdown.done=%s/%s 컴퓨터 시스템 종료 - -commands.computercraft.turn_on.synopsis=시스템을 원격으로 실행하기 -commands.computercraft.turn_on.desc=나열된 컴퓨터를 실행합니다. 컴퓨터의 인스턴스 ID(예: 123)나 컴퓨터 ID(예: #123) 또는 라벨(예: "@My Computer")을 지정할 수 있습니다. -commands.computercraft.turn_on.usage=[ids...] -commands.computercraft.turn_on.done=%s/%s 컴퓨터 시스템 실행 - -commands.computercraft.tp.synopsis=특정 컴퓨터로 순간이동하기 -commands.computercraft.tp.desc=컴퓨터의 위치로 순간이동합니다. 컴퓨터의 인스턴스 ID(예: 123) 또는 컴퓨터 ID(예: #123)를 지정할 수 있습니다. -commands.computercraft.tp.usage= -commands.computercraft.tp.action=이 컴퓨터로 순간이동하기 -commands.computercraft.tp.not_entity=비플레이어한테 터미널을 열 수 없습니다. -commands.computercraft.tp.not_there=월드에서 컴퓨터를 위치시킬 수 없습니다. - -commands.computercraft.view.synopsis=컴퓨터의 터미널을 보기 -commands.computercraft.view.desc=컴퓨터의 원격 제어를 허용하는 컴퓨터의 터미널을 엽니다. 이것은 터틀의 인벤토리에 대한 접근을 제공하지 않습니다. 컴퓨터의 인스턴스 ID(예: 123) 또는 컴퓨터 ID(예: #123)를 지정할 수 있습니다. -commands.computercraft.view.usage= -commands.computercraft.view.action=이 컴퓨터를 봅니다. -commands.computercraft.view.not_player=비플레이어한테 터미널을 열 수 없습니다. - -commands.computercraft.track.synopsis=컴퓨터의 실행 시간을 추적하기 -commands.computercraft.track.desc=컴퓨터가 실행되는 기간과 처리되는 이벤트 수를 추적합니다. 이는 /forge 트랙과 유사한 방법으로 정보를 제공하며 지연 로그에 유용할 수 있습니다. - -commands.computercraft.track.start.synopsis=모든 컴퓨터의 추적을 시작하기 -commands.computercraft.track.start.desc=모든 컴퓨터의 이벤트 및 실행 시간 추적을 시작합니다. 이는 이전 실행의 결과를 폐기할 것입니다. -commands.computercraft.track.start.usage= -commands.computercraft.track.start.stop=%s을(를) 실행하여 추적을 중지하고 결과를 확인합니다. - -commands.computercraft.track.stop.synopsis=모든 컴퓨터의 추적을 중지하기 -commands.computercraft.track.stop.desc=모든 컴퓨터의 이벤트 및 실행 시간 추적을 중지합니다. -commands.computercraft.track.stop.usage= -commands.computercraft.track.stop.action=추적을 중지하려면 클릭하세요. -commands.computercraft.track.stop.not_enabled=현재 추적하는 컴퓨터가 없습니다. - -commands.computercraft.track.dump.synopsis=최신 추적 결과를 덤프하기 -commands.computercraft.track.dump.desc=최신 컴퓨터 추적의 결과를 덤프합니다. -commands.computercraft.track.dump.usage=[kind] -commands.computercraft.track.dump.no_timings=사용가능한 시간이 없습니다. -commands.computercraft.track.dump.no_field=알 수 없는 필드 '%s' -commands.computercraft.track.dump.computer=컴퓨터 - -commands.computercraft.reload.synopsis=컴퓨터크래프트 구성파일을 리로드하기 -commands.computercraft.reload.desc=컴퓨터크래프트 구성파일을 리로드합니다. -commands.computercraft.reload.usage= -commands.computercraft.reload.done=리로드된 구성 - -commands.computercraft.queue.synopsis=computer_command 이벤트를 명령 컴퓨터에 보내기 -commands.computercraft.queue.desc=computer_command 이벤트를 명령 컴퓨터로 전송하여 추가 인수를 전달합니다. 이는 대부분 지도 제작자를 위해 설계되었으며, 보다 컴퓨터 친화적인 버전의 /trigger 역할을 합니다. 어떤 플레이어든 명령을 실행할 수 있으며, 이는 텍스트 구성 요소의 클릭 이벤트를 통해 수행될 가능성이 가장 높습니다. -commands.computercraft.queue.usage= [args...] - -commands.computercraft.generic.no_position= -commands.computercraft.generic.position=%s, %s, %s -commands.computercraft.generic.yes=Y -commands.computercraft.generic.no=N -commands.computercraft.generic.exception=처리되지 않은 예외 (%s) -commands.computercraft.generic.additional_rows=%d개의 추가 행... - -commands.computercraft.argument.no_matching='%s'와 일치하는 컴퓨터가 없습니다. -commands.computercraft.argument.many_matching='%s'와 일치하는 여러 컴퓨터 (인스턴스 %s) -commands.computercraft.argument.not_number='%s'는 숫자가 아닙니다. - -# Names for the various tracking fields. -tracking_field.computercraft.tasks.name=작업 -tracking_field.computercraft.total.name=전체 시간 -tracking_field.computercraft.average.name=평균 시간 -tracking_field.computercraft.max.name=최대 시간 - -tracking_field.computercraft.server_count.name=서버 작업 수 -tracking_field.computercraft.server_time.name=서버 작업 시간 - -tracking_field.computercraft.peripheral.name=주변 호출 -tracking_field.computercraft.fs.name=파일시스템 작업 -tracking_field.computercraft.turtle.name=터틀 작업 - -tracking_field.computercraft.http.name=HTTP 요청 -tracking_field.computercraft.http_upload.name=HTTP 업로드 -tracking_field.computercraft.http_download.name=HTTT 다운로드 - -tracking_field.computercraft.websocket_incoming.name=웹소켓 수신 -tracking_field.computercraft.websocket_outgoing.name=웹소켓 송신 - -tracking_field.computercraft.coroutines_created.name=코루틴 생성됨 -tracking_field.computercraft.coroutines_dead.name=코루틴 처리됨 - -# Misc tooltips -gui.computercraft.tooltip.copy=클립보드에 복사 -gui.computercraft.tooltip.computer_id=(컴퓨터 ID: %s) -gui.computercraft.tooltip.disk_id=(디스크 ID: %s) - -# Config options -gui.computercraft:config.computer_space_limit=컴퓨터 공간 제한 (바이트) -gui.computercraft:config.floppy_space_limit=플로피 디스크 공간 제한 (바이트) -gui.computercraft:config.maximum_open_files=컴퓨터당 최대 파일 열기 -gui.computercraft:config.disable_lua51_features=Lua 5.1 기능 미사용 -gui.computercraft:config.default_computer_settings=기본 컴퓨터 설정 -gui.computercraft:config.debug_enabled=디버그 라이브러리 사용 -gui.computercraft:config.log_computer_errors=컴퓨터 오류 로그 - -gui.computercraft:config.execution=실행 -gui.computercraft:config.execution.computer_threads=컴퓨터 쓰레드 -gui.computercraft:config.execution.max_main_global_time=전역 시간 당 서버 제한 -gui.computercraft:config.execution.max_main_computer_time=컴퓨터 시간 당 서버 제한 - -gui.computercraft:config.http=HTTP -gui.computercraft:config.http.enabled=HTTP API 사용하기 -gui.computercraft:config.http.websocket_enabled=웹소켓 사용 -gui.computercraft:config.http.allowed_domains=허용된 도메인 -gui.computercraft:config.http.blocked_domains=차단된 도메인 - -gui.computercraft:config.http.timeout=타임아웃 -gui.computercraft:config.http.max_requests=최대 동시 요청 수 -gui.computercraft:config.http.max_download=최대 응답 크기 -gui.computercraft:config.http.max_upload=최대 요청 크기 -gui.computercraft:config.http.max_websockets=최대 동시 웹소켓 수 -gui.computercraft:config.http.max_websocket_message=최대 웹 포켓 메시지 크기 - -gui.computercraft:config.peripheral=주변 -gui.computercraft:config.peripheral.command_block_enabled=명령 블록 주변 장치 사용 -gui.computercraft:config.peripheral.modem_range=모뎀 범위(기본값) -gui.computercraft:config.peripheral.modem_high_altitude_range=모뎀 범위(높은 고도) -gui.computercraft:config.peripheral.modem_range_during_storm=모뎀 범위(나쁜 날씨) -gui.computercraft:config.peripheral.modem_high_altitude_range_during_storm=모뎀 범위(높은 고도, 나쁜 날씨) -gui.computercraft:config.peripheral.max_notes_per_tick=컴퓨터가 한 번에 재생할 수 있는 최대 소리 수 - -gui.computercraft:config.turtle=터틀 -gui.computercraft:config.turtle.need_fuel=연료 사용 -gui.computercraft:config.turtle.normal_fuel_limit=터틀 연료 제한 -gui.computercraft:config.turtle.advanced_fuel_limit=고급 터틀 연료 제한 -gui.computercraft:config.turtle.obey_block_protection=터틀이 블록 보호에 따르기 -gui.computercraft:config.turtle.can_push=터틀이 엔티티 밀어내기 -gui.computercraft:config.turtle.disabled_actions=터틀 액션 미사용 diff --git a/src/main/resources/assets/computercraft/lang/zh_cn.json b/src/main/resources/assets/computercraft/lang/zh_cn.json index f96ffb713..7df723d40 100644 --- a/src/main/resources/assets/computercraft/lang/zh_cn.json +++ b/src/main/resources/assets/computercraft/lang/zh_cn.json @@ -143,8 +143,8 @@ "tracking_field.computercraft.coroutines_dead.name": "协同处理", "gui.computercraft.tooltip.copy": "复制到剪贴板", - "gui.computercraft.tooltip.computer_id": "(计算机ID: %s)", - "gui.computercraft.tooltip.disk_id": "(磁盘ID: %s)", + "gui.computercraft.tooltip.computer_id": "计算机ID: %s", + "gui.computercraft.tooltip.disk_id": "磁盘ID: %s", "gui.computercraft.config.computer_space_limit": "计算机空间限制(字节)", "gui.computercraft.config.floppy_space_limit": "软盘空间限制(字节)", diff --git a/src/main/resources/assets/computercraft/lang/zh_cn.lang b/src/main/resources/assets/computercraft/lang/zh_cn.lang deleted file mode 100644 index 56b9aa106..000000000 --- a/src/main/resources/assets/computercraft/lang/zh_cn.lang +++ /dev/null @@ -1,195 +0,0 @@ -itemGroup.computercraft=CC: Tweaked - -tile.computercraft:computer.name=计算机 -tile.computercraft:advanced_computer.name=高级计算机 -tile.computercraft:drive.name=磁盘驱动器 -tile.computercraft:printer.name=打印机 -tile.computercraft:monitor.name=显示器 -tile.computercraft:advanced_monitor.name=高级显示器 -tile.computercraft:wireless_modem.name=无线调制解调器 -tile.computercraft:wired_modem.name=有线调制解调器 -tile.computercraft:cable.name=网络电缆 -tile.computercraft:command_computer.name=命令电脑 -tile.computercraft:advanced_modem.name=末影调制解调器 -tile.computercraft:speaker.name=扬声器 - -tile.computercraft:turtle.name=海龟 -tile.computercraft:turtle.upgraded.name=%s海龟 -tile.computercraft:turtle.upgraded_twice.name=%s%s海龟 -tile.computercraft:advanced_turtle.name=高级海龟 -tile.computercraft:advanced_turtle.upgraded.name=高级%s海龟 -tile.computercraft:advanced_turtle.upgraded_twice.name=高级%s%s海龟 - -item.computercraft:disk.name=软盘 -item.computercraft:treasure_disk.name=软盘 -item.computercraft:page.name=打印纸 -item.computercraft:pages.name=打印纸 -item.computercraft:book.name=打印书 - -item.computercraft:pocket_computer.name=手提计算机 -item.computercraft:pocket_computer.upgraded.name=%s手提计算机 -item.computercraft:advanced_pocket_computer.name=高级手提计算机 -item.computercraft:advanced_pocket_computer.upgraded.name=高级%s手提计算机 - -upgrade.minecraft:diamond_sword.adjective=战斗 -upgrade.minecraft:diamond_shovel.adjective=挖掘 -upgrade.minecraft:diamond_pickaxe.adjective=采掘 -upgrade.minecraft:diamond_axe.adjective=伐木 -upgrade.minecraft:diamond_hoe.adjective=耕种 -upgrade.computercraft:wireless_modem.adjective=无线 -upgrade.minecraft:crafting_table.adjective=合成 -upgrade.computercraft:advanced_modem.adjective=末影 -upgrade.computercraft:speaker.adjective=喧闹 - -chat.computercraft.wired_modem.peripheral_connected=Peripheral "%s"连接到网络 -chat.computercraft.wired_modem.peripheral_disconnected=Peripheral "%s"与网络断开连接 - -# Command descriptions, usage and any additional messages. -commands.computercraft.synopsis=各种控制计算机的命令. -commands.computercraft.desc=/computercraft命令提供各种调试和管理工具,用于控制和与计算机交互. - -commands.computercraft.help.synopsis=为特定的命令提供帮助 -commands.computercraft.help.desc= -commands.computercraft.help.usage=[command] -commands.computercraft.help.no_children=%s没有子命令 -commands.computercraft.help.no_command=没有这样的命令'%s' - -commands.computercraft.dump.synopsis=显示计算机的状态. -commands.computercraft.dump.desc=显示所有计算机的状态或某台计算机的特定信息. 你可以指定计算机的实例id (例如. 123), 计算机id (例如. #123)或标签(例如. "@My Computer"). -commands.computercraft.dump.usage=[id] -commands.computercraft.dump.action=查看有关此计算机的更多信息 - -commands.computercraft.shutdown.synopsis=远程关闭计算机. -commands.computercraft.shutdown.desc=关闭列出的计算机或全部计算机(如果未指定). 你可以指定计算机的实例id (例如. 123), 计算机id (例如. #123)或标签(例如. "@My Computer"). -commands.computercraft.shutdown.usage=[ids...] -commands.computercraft.shutdown.done=关闭%s/%s计算机 - -commands.computercraft.turn_on.synopsis=远程打开计算机. -commands.computercraft.turn_on.desc=打开列出的计算机. 你可以指定计算机的实例id (例如. 123), 计算机id (例如. #123)或标签(例如. "@My Computer"). -commands.computercraft.turn_on.usage=[ids...] -commands.computercraft.turn_on.done=打开%s/%s计算机 - -commands.computercraft.tp.synopsis=传送到特定的计算机. -commands.computercraft.tp.desc=传送到计算机的位置. 你可以指定计算机的实例id (例如. 123)或计算机id (例如. #123). -commands.computercraft.tp.usage= -commands.computercraft.tp.action=传送到这台电脑 -commands.computercraft.tp.not_entity=无法为非玩家打开终端 -commands.computercraft.tp.not_there=无法在世界上定位电脑 - -commands.computercraft.view.synopsis=查看计算机的终端. -commands.computercraft.view.desc=打开计算机的终端,允许远程控制计算机. 这不提供对海龟库存的访问. 你可以指定计算机的实例id (例如. 123)或计算机id (例如. #123). -commands.computercraft.view.usage= -commands.computercraft.view.action=查看此计算机 -commands.computercraft.view.not_player=无法为非玩家打开终端 - -commands.computercraft.track.synopsis=跟踪计算机的执行时间. -commands.computercraft.track.desc=跟踪计算机执行的时间以及它们处理的事件数. 这以/forge track类似的方式呈现信息,可用于诊断滞后. - -commands.computercraft.track.start.synopsis=开始跟踪所有计算机 -commands.computercraft.track.start.desc=开始跟踪所有计算机的执行时间和事件计数. 这将放弃先前运行的结果. -commands.computercraft.track.start.usage= -commands.computercraft.track.start.stop=运行%s以停止跟踪并查看结果 - -commands.computercraft.track.stop.synopsis=停止跟踪所有计算机 -commands.computercraft.track.stop.desc=停止跟踪所有计算机的事件和执行时间 -commands.computercraft.track.stop.usage= -commands.computercraft.track.stop.action=点击停止跟踪 -commands.computercraft.track.stop.not_enabled=目前没有跟踪计算机 - -commands.computercraft.track.dump.synopsis=输出最新的跟踪结果 -commands.computercraft.track.dump.desc=输出计算机跟踪的最新结果. -commands.computercraft.track.dump.usage=[kind] -commands.computercraft.track.dump.no_timings=没有时间可用 -commands.computercraft.track.dump.no_field=未知字节'%s' -commands.computercraft.track.dump.computer=计算器 - -commands.computercraft.reload.synopsis=重新加载ComputerCraft配置文件 -commands.computercraft.reload.desc=重新加载ComputerCraft配置文件 -commands.computercraft.reload.usage= -commands.computercraft.reload.done=重新加载配置 - -commands.computercraft.queue.synopsis=将computer_command事件发送到命令计算机 -commands.computercraft.queue.desc=发送computer_command事件到命令计算机,并传递其他参数. 这主要是为地图制作者设计的, 作为/trigger更加计算机友好的版本. 任何玩家都可以运行命令, 这很可能是通过文本组件的点击事件完成的. -commands.computercraft.queue.usage= [args...] - -commands.computercraft.generic.no_position=<无位置> -commands.computercraft.generic.position=%s, %s, %s -commands.computercraft.generic.yes=Y -commands.computercraft.generic.no=N -commands.computercraft.generic.exception=未处理的异常(%s) -commands.computercraft.generic.additional_rows=%d额外的行… - -commands.computercraft.argument.no_matching=没有计算机匹配'%s' -commands.computercraft.argument.many_matching=多台计算机匹配'%s' (实例%s) -commands.computercraft.argument.not_number='%s'不是一个数字 - -# Names for the various tracking fields. -tracking_field.computercraft.tasks.name=任务 -tracking_field.computercraft.total.name=总计时间 -tracking_field.computercraft.average.name=平均时间 -tracking_field.computercraft.max.name=最大时间 - -tracking_field.computercraft.server_count.name=服务器任务计数 -tracking_field.computercraft.server_time.name=服务器任务时间 - -tracking_field.computercraft.peripheral.name=外围设备呼叫 -tracking_field.computercraft.fs.name=文件系统操作 -tracking_field.computercraft.turtle.name=海龟行动 - -tracking_field.computercraft.http.name=HTTP需求 -tracking_field.computercraft.http_upload.name=HTTP上传 -tracking_field.computercraft.http_download.name=HTTP下载 - -tracking_field.computercraft.websocket_incoming.name=Websocket传入 -tracking_field.computercraft.websocket_outgoing.name=Websocket传出 - -tracking_field.computercraft.coroutines_created.name=协同创建 -tracking_field.computercraft.coroutines_dead.name=协同处理 - -# Misc tooltips -gui.computercraft.tooltip.copy=复制到剪贴板 -gui.computercraft.tooltip.computer_id=(计算机ID: %s) -gui.computercraft.tooltip.disk_id=(磁盘ID: %s) - -# Config options -gui.computercraft:config.computer_space_limit=计算机空间限制(字节) -gui.computercraft:config.floppy_space_limit=软盘空间限制(字节) -gui.computercraft:config.maximum_open_files=每台计算机打开的最大文件数 -gui.computercraft:config.disable_lua51_features=禁用Lua 5.1功能 -gui.computercraft:config.default_computer_settings=默认计算机设置 -gui.computercraft:config.debug_enabled=启用debug库 -gui.computercraft:config.log_computer_errors=记录计算机错误 - -gui.computercraft:config.execution=执行 -gui.computercraft:config.execution.computer_threads=计算机线程数 -gui.computercraft:config.execution.max_main_global_time=服务器全局tick时间限制 -gui.computercraft:config.execution.max_main_computer_time=服务器计算机tick时间限制 - -gui.computercraft:config.http=HTTP -gui.computercraft:config.http.enabled=启用HTTP API -gui.computercraft:config.http.websocket_enabled=启用websockets -gui.computercraft:config.http.whitelist=HTTP白名单 -gui.computercraft:config.http.blacklist=HTTP黑名单 - -gui.computercraft:config.http.timeout=Timeout -gui.computercraft:config.http.max_requests=最大并发请求数 -gui.computercraft:config.http.max_download=最大响应数据大小 -gui.computercraft:config.http.max_upload=最大请求数据大小 -gui.computercraft:config.http.max_websockets=最大并发websockets数 -gui.computercraft:config.http.max_websocket_message=最大websockets消息大小 - -gui.computercraft:config.peripheral=外围设备 -gui.computercraft:config.peripheral.command_block_enabled=启用命令方块外设 -gui.computercraft:config.peripheral.modem_range=调制解调器范围(默认) -gui.computercraft:config.peripheral.modem_high_altitude_range=调制解调器范围(高海拔) -gui.computercraft:config.peripheral.modem_range_during_storm=调制解调器范围(恶劣天气) -gui.computercraft:config.peripheral.modem_high_altitude_range_during_storm=调制解调器范围(高海拔, 恶劣天气) -gui.computercraft:config.peripheral.max_notes_per_tick=计算机一次可以播放的最大音符数量 - -gui.computercraft:config.turtle=海龟 -gui.computercraft:config.turtle.need_fuel=启用燃料 -gui.computercraft:config.turtle.normal_fuel_limit=海龟燃料限制 -gui.computercraft:config.turtle.advanced_fuel_limit=高级海龟燃料限制 -gui.computercraft:config.turtle.obey_block_protection=海龟服从方块保护 -gui.computercraft:config.turtle.can_push=海龟可以推动实体 -gui.computercraft:config.turtle.disabled_actions=禁用海龟动作 diff --git a/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua b/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua index 53b849adc..c737a915a 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua @@ -64,24 +64,33 @@ function isPresent(name) return false end ---- Get the type of the peripheral with the given name. +--- Get the type of a wrapped peripheral, or a peripheral with the given name. -- --- @tparam string name The name of the peripheral to find. +-- @tparam string|table peripheral The name of the peripheral to find, or a +-- wrapped peripheral instance. -- @treturn string|nil The peripheral's type, or `nil` if it is not present. -function getType(name) - expect(1, name, "string") - if native.isPresent(name) then - return native.getType(name) - end - for n = 1, #sides do - local side = sides[n] - if native.getType(side) == "modem" and not native.call(side, "isWireless") and - native.call(side, "isPresentRemote", name) - then - return native.call(side, "getTypeRemote", name) +function getType(peripheral) + expect(1, peripheral, "string", "table") + if type(peripheral) == "string" then -- Peripheral name passed + if native.isPresent(peripheral) then + return native.getType(peripheral) end + for n = 1, #sides do + local side = sides[n] + if native.getType(side) == "modem" and not native.call(side, "isWireless") and + native.call(side, "isPresentRemote", peripheral) + then + return native.call(side, "getTypeRemote", peripheral) + end + end + return nil + else + local mt = getmetatable(peripheral) + if not mt or mt.__name ~= "peripheral" or type(mt.type) ~= "string" then + error("bad argument #1 (table is not a peripheral)", 2) + end + return mt.type end - return nil end --- Get all available methods for the peripheral with the given name. @@ -105,6 +114,19 @@ function getMethods(name) return nil end +--- Get the name of a peripheral wrapped with @{peripheral.wrap}. +-- +-- @tparam table peripheral The peripheral to get the name of. +-- @treturn string The name of the given peripheral. +function getName(peripheral) + expect(1, peripheral, "table") + local mt = getmetatable(peripheral) + if not mt or mt.__name ~= "peripheral" or type(mt.name) ~= "string" then + error("bad argument #1 (table is not a peripheral)", 2) + end + return mt.name +end + --- Call a method on the peripheral with the given name. -- -- @tparam string name The name of the peripheral to invoke the method on. @@ -148,7 +170,11 @@ function wrap(name) return nil end - local result = {} + local result = setmetatable({}, { + __name = "peripheral", + name = name, + type = peripheral.getType(name), + }) for _, method in ipairs(methods) do result[method] = function(...) return peripheral.call(name, method, ...) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua b/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua index 358c62bd5..3a8f3a5c0 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/rednet.lua @@ -29,7 +29,7 @@ local tReceivedMessageTimeouts = {} local tHostnames = {} --- Opens a modem with the given @{peripheral} name, allowing it to send and ---- receive messages over rednet. +-- receive messages over rednet. -- -- This will open the modem on two channels: one which has the same -- @{os.getComputerID|ID} as the computer, and another on @@ -246,7 +246,7 @@ function host(sProtocol, sHostname) end --- Stop @{rednet.host|hosting} a specific protocol, meaning it will no longer ---- respond to @{rednet.lookup} requests. +-- respond to @{rednet.lookup} requests. -- -- @tparam string sProtocol The protocol to unregister your self from. function unhost(sProtocol) diff --git a/src/main/resources/data/computercraft/lua/rom/help/peripheral.txt b/src/main/resources/data/computercraft/lua/rom/help/peripheral.txt index 2b02b0a90..333f52f51 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/peripheral.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/peripheral.txt @@ -3,6 +3,7 @@ The peripheral API is for interacting with external peripheral devices. Type "he Functions in the peripheral API: peripheral.getNames() peripheral.isPresent( name ) +peripheral.getName( peripheral ) peripheral.getType( name ) peripheral.getMethods( name ) peripheral.call( name, methodName, param1, param2, etc ) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/monitor.lua b/src/main/resources/data/computercraft/lua/rom/programs/monitor.lua index e6daed9e8..01c9d7949 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/monitor.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/monitor.lua @@ -28,7 +28,7 @@ local monitor = peripheral.wrap(sName) local previousTerm = term.redirect(monitor) local co = coroutine.create(function() - shell.run(sProgram, table.unpack(tArgs, 3)) + (shell.execute or shell.run)(sProgram, table.unpack(tArgs, 3)) end) local function resume(...) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/shell.lua b/src/main/resources/data/computercraft/lua/rom/programs/shell.lua index 474d3ecfd..843e28e71 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/shell.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/shell.lua @@ -130,8 +130,25 @@ else bgColour = colours.black end -local function run(_sCommand, ...) - local sPath = shell.resolveProgram(_sCommand) +--- Run a program with the supplied arguments. +-- +-- Unlike @{shell.run}, each argument is passed to the program verbatim. While +-- `shell.run("echo", "b c")` runs `echo` with `b` and `c`, +-- `shell.execute("echo", "b c")` runs `echo` with a single argument `b c`. +-- +-- @tparam string command The program to execute. +-- @tparam string ... Arguments to this program. +-- @treturn boolean Whether the program exited successfully. +-- @usage Run `paint my-image` from within your program: +-- +-- shell.execute("paint", "my-image") +function shell.execute(command, ...) + expect(1, command, "string") + for i = 1, select('#', ...) do + expect(i + 1, select(i, ...), "string") + end + + local sPath = shell.resolveProgram(command) if sPath ~= nil then tProgramStack[#tProgramStack + 1] = sPath if multishell then @@ -144,7 +161,7 @@ local function run(_sCommand, ...) local sDir = fs.getDir(sPath) local env = createShellEnv(sDir) - env.arg = { [0] = _sCommand, ... } + env.arg = { [0] = command, ... } local result = os.run(env, sPath, ...) tProgramStack[#tProgramStack] = nil @@ -196,11 +213,12 @@ end -- @usage Run `paint my-image` from within your program: -- -- shell.run("paint", "my-image") +-- @see shell.execute Run a program directly without parsing the arguments. function shell.run(...) local tWords = tokenise(...) local sCommand = tWords[1] if sCommand then - return run(sCommand, table.unpack(tWords, 2)) + return shell.execute(sCommand, table.unpack(tWords, 2)) end return false end diff --git a/src/test/resources/test-rom/data/dump-args.lua b/src/test/resources/test-rom/data/dump-args.lua new file mode 100644 index 000000000..3772a43ec --- /dev/null +++ b/src/test/resources/test-rom/data/dump-args.lua @@ -0,0 +1 @@ +_G.__arg = _ENV.arg diff --git a/src/test/resources/test-rom/mcfly.lua b/src/test/resources/test-rom/mcfly.lua index 81e5afb3c..5081447a6 100644 --- a/src/test/resources/test-rom/mcfly.lua +++ b/src/test/resources/test-rom/mcfly.lua @@ -47,7 +47,7 @@ local function default_stub() end --- Stub a table entry with a new value. -- --- @tparam table +-- @tparam table tbl The table whose field should be stubbed. -- @tparam string key The variable to stub -- @param[opt] value The value to stub it with. If this is a function, one can -- use the various stub expectation methods to determine what it was called diff --git a/src/test/resources/test-rom/spec/apis/peripheral_spec.lua b/src/test/resources/test-rom/spec/apis/peripheral_spec.lua index c3fb5675f..1b11c6552 100644 --- a/src/test/resources/test-rom/spec/apis/peripheral_spec.lua +++ b/src/test/resources/test-rom/spec/apis/peripheral_spec.lua @@ -8,10 +8,30 @@ describe("The peripheral library", function() end) end) + describe("peripheral.getName", function() + it("validates arguments", function() + expect.error(peripheral.getName, nil):eq("bad argument #1 (expected table, got nil)") + expect.error(peripheral.getName, {}):eq("bad argument #1 (table is not a peripheral)") + end) + + it_modem("can get the name of a wrapped peripheral", function() + expect(peripheral.getName(peripheral.wrap("top"))):eq("top") + end) + end) + describe("peripheral.getType", function() it("validates arguments", function() peripheral.getType("") - expect.error(peripheral.getType, nil):eq("bad argument #1 (expected string, got nil)") + expect.error(peripheral.getType, nil):eq("bad argument #1 (expected string or table, got nil)") + expect.error(peripheral.getType, {}):eq("bad argument #1 (table is not a peripheral)") + end) + + it_modem("can get the type of a peripheral by side", function() + expect(peripheral.getType("top")):eq("modem") + end) + + it_modem("can get the type of a wrapped peripheral", function() + expect(peripheral.getType(peripheral.wrap("top"))):eq("modem") end) end) diff --git a/src/test/resources/test-rom/spec/programs/shell_spec.lua b/src/test/resources/test-rom/spec/programs/shell_spec.lua index cb35d70f6..fae7b85d1 100644 --- a/src/test/resources/test-rom/spec/programs/shell_spec.lua +++ b/src/test/resources/test-rom/spec/programs/shell_spec.lua @@ -6,19 +6,25 @@ describe("The shell", function() end) end) - describe("shell.run", function() - it("sets the arguments", function() - local handle = fs.open("test-files/out.txt", "w") - handle.writeLine("_G.__arg = arg") - handle.close() - - shell.run("/test-files/out.txt", "arg1", "arg2") - fs.delete("test-files/out.txt") + describe("shell.execute", function() + it("parses in arguments verbatim", function() + shell.execute("/test-rom/data/dump-args", "arg1", "arg 2") local args = _G.__arg _G.__arg = nil - expect(args):same { [0] = "/test-files/out.txt", "arg1", "arg2" } + expect(args):same { [0] = "/test-rom/data/dump-args", "arg1", "arg 2" } + end) + end) + + describe("shell.run", function() + it("tokenises the arguments", function() + shell.run("/test-rom/data/dump-args", "arg1", "arg 2") + + local args = _G.__arg + _G.__arg = nil + + expect(args):same { [0] = "/test-rom/data/dump-args", "arg1", "arg", "2" } end) end) diff --git a/tools/language.lua b/tools/language.lua index 25e5a2588..2e1f56f75 100644 --- a/tools/language.lua +++ b/tools/language.lua @@ -19,10 +19,12 @@ local primary = "en_us" local secondary = { + "da_dk", "de_de", "es_es", "fr_fr", "it_it", + "ko_kr", "pt_br", "sv_se", "zh_cn",