diff --git a/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/DisplayLinkPeripheral.java b/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/DisplayLinkPeripheral.java index 2d1c9d29b..cf23be73e 100644 --- a/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/DisplayLinkPeripheral.java +++ b/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/DisplayLinkPeripheral.java @@ -1,5 +1,7 @@ package com.simibubi.create.compat.computercraft.implementation.peripherals; +import java.nio.charset.StandardCharsets; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.jetbrains.annotations.NotNull; @@ -8,7 +10,11 @@ import com.simibubi.create.content.redstone.displayLink.DisplayLinkBlockEntity; import com.simibubi.create.content.redstone.displayLink.DisplayLinkContext; import com.simibubi.create.content.redstone.displayLink.target.DisplayTargetStats; +import dan200.computercraft.api.lua.IArguments; +import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; +import dan200.computercraft.api.lua.LuaValues; +import dan200.computercraft.api.lua.ObjectLuaTable; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; @@ -52,6 +58,28 @@ public class DisplayLinkPeripheral extends SyncedPeripheral map) { + ObjectLuaTable table = new ObjectLuaTable(map); + bytes = new byte[table.length()]; + for (int i = 0; i < bytes.length; i++) { + bytes[i] = (byte) (table.getInt(i + 1) & 0xff); + } + } else { + throw LuaValues.badArgumentOf(args, 0, "string or table"); + } + writeImpl(new String(bytes, StandardCharsets.UTF_8)); + } + + protected final void writeImpl(String text) { ListTag tag = blockEntity.getSourceConfig().getList(TAG_KEY, Tag.TAG_STRING); int x = cursorX.get();