1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-10 01:10:30 +00:00

Use "require" in textutils

This avoids us having to support requireless environments inside
cc.strings.

I do kinda wonder if os.loadAPI-loaded files should also have their own
shared "require", just so we're not loading 10 copies of cc.expect.
This commit is contained in:
Jonathan Coates 2024-07-24 19:30:12 +01:00
parent 4bfb9ac323
commit 63185629b7
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
3 changed files with 9 additions and 5 deletions

View File

@ -7,9 +7,13 @@
-- @module textutils -- @module textutils
-- @since 1.2 -- @since 1.2
local expect = dofile("rom/modules/main/cc/expect.lua") local pgk_env = setmetatable({}, { __index = _ENV })
pgk_env.require = dofile("rom/modules/main/cc/require.lua").make(pgk_env, "rom/modules/main")
local require = pgk_env.require
local expect = require("cc.expect")
local expect, field = expect.expect, expect.field local expect, field = expect.expect, expect.field
local wrap = dofile("rom/modules/main/cc/strings.lua").wrap local wrap = require("cc.strings").wrap
--- Slowly writes string text at current cursor position, --- Slowly writes string text at current cursor position,
-- character-by-character. -- character-by-character.

View File

@ -118,8 +118,8 @@ end
--- Expect a number to be within a specific range. --- Expect a number to be within a specific range.
-- --
-- @tparam number num The value to check. -- @tparam number num The value to check.
-- @tparam number min The minimum value, if nil then `-math.huge` is used. -- @tparam[opt=-math.huge] number min The minimum value.
-- @tparam number max The maximum value, if nil then `math.huge` is used. -- @tparam[opt=math.huge] number max The maximum value.
-- @return The given `value`. -- @return The given `value`.
-- @throws If the value is outside of the allowed range. -- @throws If the value is outside of the allowed range.
-- @since 1.96.0 -- @since 1.96.0

View File

@ -8,7 +8,7 @@
-- @since 1.95.0 -- @since 1.95.0
-- @see textutils For additional string related utilities. -- @see textutils For additional string related utilities.
local expect = (require and require("cc.expect") or dofile("rom/modules/main/cc/expect.lua")).expect local expect = require("cc.expect").expect
--[[- Wraps a block of text, so that each line fits within the given width. --[[- Wraps a block of text, so that each line fits within the given width.