Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Search the Community

Showing results for tags 'text'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OpenComputers
    • Announcements
    • Feedback
    • IRC
  • Code Central
    • Support
    • Showcase
    • Tutorials
  • Addons & More
    • Addons Mods
    • Architectures
    • OpenEngineering Task Force
  • General
    • Lounge
    • Forum Games
    • Showcase
    • Servers
  • Archives
    • Public Archives

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Minecraft


GitHub


IRC


Fediverse ID


Location


Interests

Found 2 results

  1. adamzach

    How to move text?

    Hi guys, can I somehow position text (for example text generated by print) on the screen? Move it into the bottom right corner, or any position on the screen.
  2. I am having issues with a text API that I am writing and am looking for input from more experienced coders. The problem I am currently facing is with my centering method. If be used to center text to the full screen width it works great, if I am trying to center text in a smaller portion of the screen that is offset towards either edge, it fails miserably. API-in-progress below: --[[ Text utilities API by jaspercayne A collection of functions to work with text ]]-- local textTools = {} local component = require("component") local term = require("term") local text = require("text") local gpu = component.gpu local screenWidth, screenHeight = gpu.getResolution() -- Calculates appropriate amount of padding to center a string function textTools.centerText(target, fromx, tox) local calculatedPadding = ((fromx+tox)/2) + (string.len(target)/2) local centeredText = tostring(text.padLeft(target, calculatedPadding)) term.write(centeredText) end -- Aligns a string to the right of the screen function textTools.alignRight(target) local calculatedPadding = screenWidth -- string.len(target) local alignedText = tostring(text.padLeft(target, calculatedPadding)) term.write(alignedText) end -- Wraps a given string to the width of the screen function textTools.wrapToScreen(target) local wrappedText = tostring(text.wrap(target,string.len(target),screenWidth)) term.write(wrappedText) end return textTools I am certain that the main issue is from trying to pull the absolute x,y coords and derive a center point from that, but my brain just isn't putting together what the centerText function should look like... Help? Anyone?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.