Computer Science Canada

[Module] Custom Text

Author:  Raknarg [ Sun Mar 25, 2012 4:10 pm ]
Post subject:  [Module] Custom Text

I've been very annoyed by that fact that I can't use get in offscreenonly mode (or at least not that I'm aware of; tell me if otherwise), so I created a module to do just that. Just import it, and call the fuction Get. There's some info in the file itself, if you want to look more into it. Just note that it exits when you click enter resulting with whatever's on screen, and also exits when you click the escape button, resulting in nothing. The idea for that was to create an option to "go back"; if the function resulted in nothing, then dont continue.

Also yes, I know the input is much glitchier than regular input; so sue me. I did as well as I could, just type slower Razz

Here's a quick example:
Turing:

import "Custom Text.tu"
var word : string := CustomText.Get (50, 200, 200, 12, 4, Font.New ("Arial:10"), brightblue, "Player1: ")


After you click enter or escape, word will now be whatever you typed.

Author:  Dreadnought [ Sun Mar 25, 2012 4:33 pm ]
Post subject:  Re: [Module] Custom Text

Raknarg wrote:
I've been very annoyed by that fact that I can't use get in offscreenonly mode

You can give this a try!
Turing:
View.Set ("offscreenonly")
put "Please Type something!"
View.Update

var test : string := ""
loop
    var ch : char := getchar ()
   
    if ch = "\n" then
        put ""
        exit
    elsif not (ch = KEY_BACKSPACE and length (test) = 0) then
        test += ch
        locate (2, 1)
        put test ..
        View.Update
    end if
end loop

put "You typed: ", test
View.Update


Should work like get.

Author:  Raknarg [ Sun Mar 25, 2012 5:03 pm ]
Post subject:  RE:[Module] Custom Text

haha fine Razz
But this way you can use customized text, with different fonts and colours and such and still use a get function fine.

Can you do that as well without this?


: