Jump to content




[Lua][Question]Color


  • You cannot reply to this topic
3 replies to this topic

#1 Spongy141

  • Members
  • 526 posts
  • Location'Merica

Posted 13 April 2013 - 04:46 PM

Now I already now how to change the color of text in CC-Lua, but I know Lua is a little different. Well I'm making this "Personal Assistant" thingy on my iPod with a app called "TouchLua", and well it does what its title suggests, its my assistant, lol, well its written fully in regular Lua, not CC-Lua, but let me get to the real problem, so I wanted to know how you would mimic "term.setTextColor(colors.<a Color>)" into regular Lua. And "term.setCursorPos(<coords>)".

#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 13 April 2013 - 05:55 PM

There is no such thing in regular Lua. Unless your app provides a way of GUI interaction then I am afraid you are stuck with a text-based system. There are several Lua GUI bindings such as wxLua for a full-blown installation of Lua on a computer (oftentimes they are operating system specific), but unfortunately I do not know of any for an IOS device; Implementation would probably be fiendishly difficult.

Edit: If the app does provide some sort of visual interaction, you will most likely be able to find it by cycling through the _G environment table like so:
for i,v in pairs(_G) do
  print(i..": "..type(v))
end

You'll probably have to look through a lot of global variables/functions/tables, but hey you might find something useful in the process.

#3 Spongy141

  • Members
  • 526 posts
  • Location'Merica

Posted 13 April 2013 - 06:25 PM

 Bubba, on 13 April 2013 - 05:55 PM, said:

There is no such thing in regular Lua. Unless your app provides a way of GUI interaction then I am afraid you are stuck with a text-based system. There are several Lua GUI bindings such as wxLua for a full-blown installation of Lua on a computer (oftentimes they are operating system specific), but unfortunately I do not know of any for an IOS device; Implementation would probably be fiendishly difficult.

Edit: If the app does provide some sort of visual interaction, you will most likely be able to find it by cycling through the _G environment table like so:
for i,v in pairs(_G) do
  print(i..": "..type(v))
end

You'll probably have to look through a lot of global variables/functions/tables, but hey you might find something useful in the process.
Well thanks anyways.

#4 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 13 April 2013 - 09:18 PM

iOS runs on Unix or something, IIRC, so you should be able to do something like this:

print("\033[31;0m<your text here>") -- Print some red text.

This is ANSI escape code, which works with basically everything except for the Windows commandline.
You can learn more about it here:
http://en.wikipedia....NSI_escape_code

The colour-range is very limited, though, unless you're using xterm-256, which supports full RGB text.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users