Skip to content

Commit

Permalink
Remove reliance on cc.pretty to allow for older CC versions
Browse files Browse the repository at this point in the history
  • Loading branch information
JSH32 committed Dec 22, 2022
1 parent 88a3d7a commit d5a9129
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:19-alpine

WORKDIR /usr/src/app
COPY package*.json ./
Expand Down
13 changes: 10 additions & 3 deletions client/client/mineboy.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local imgquant = require 'mineboy_deps/imgquant'
local bson = require 'mineboy_deps/bson'
local config = require 'mineboy_config'
local pretty = require 'cc.pretty'

-- Pretty color logging
local log = {
Expand Down Expand Up @@ -303,8 +302,16 @@ while true do
--- Select a game and send a query to play the game
log.info('Getting games list from server')
local gameList = bson.decode(http.get(config.httpUrl .. '/listGames').readAll())
log.info('Retrieved ' .. tableLen(gameList) .. ' games: ', true)
pretty.pretty_print(gameList)
log.info('Retrieved ' .. tableLen(gameList) .. ' games: {', true)

write('\n')
for k, v in pairs(gameList) do
term.setTextColor(colors.red)
write(' ' .. k)
term.setTextColor(colors.lightGray)
write(' - ' .. v .. '\n')
end
write("}\n")

local index
while true do
Expand Down
18 changes: 9 additions & 9 deletions client/controller/mineboy_controller.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local pretty = require "cc.pretty"

-- Key map, the left side is the keys you press on keyboard.
-- These can be changed to any keys on this list https://computercraft.info/wiki/Keys_(API)
local keyMap = {
Expand Down Expand Up @@ -41,20 +39,22 @@ local function showUi()
print('[MineBoy Controller]')
term.setBackgroundColor(colors.black)

local keyMapReadable = {}
for key, consoleKey in pairs(keyMap) do
keyMapReadable[keys.getName(key)] = consoleKey
end

term.setTextColor(colors.cyan)
write('\nComputer ID: ')
term.setTextColor(colors.lightGray)
print(computerId)

term.setTextColor(colors.cyan)
write('Key Map: ')
write('Key Map: {\n')
term.setTextColor(colors.lightGray)
pretty.pretty_print(keyMapReadable)

for key, consoleKey in pairs(keyMap) do
term.setTextColor(colors.red)
write(' ' .. keys.getName(key))
term.setTextColor(colors.lightGray)
write(' - ' .. consoleKey .. '\n')
end
write('}\n')

term.setBackgroundColor(colors.cyan)
local w, h = term.getSize()
Expand Down

0 comments on commit d5a9129

Please sign in to comment.