sd_Text Reference

If you have any questions, suggestions, or problems for sd_Text please email me at shadowdarke@hotmail.com or post a message at http://shadowdarke.byond.com/forum/forum.cgi?forum=libraries

(Arguments in italics are optional)


Contents

Updates
version 9
version 8
version 7
version 6
version 5
version 4
global procs
sd_Text proc
sd_OverlayText proc
sd_WordBalloon proc
sd_ImprovedWordBalloon proc
sd_BalloonText proc
sd_MapFrame proc
sd_OverlayFrame proc
sd_FontIndex proc
sd_RegisterFont proc
sd_Input proc
client procs
sd_ScreenHeight proc
sd_ScreenWidth proc
sd_TextWindow datum
read only vars (sd_TextWindow)
read/write vars (sd_TextWindow)
procs (sd_TextWindow)
New proc (sd_TextWindow)
Update proc (sd_TextWindow)
Append proc (sd_TextWindow)
AtomImage proc (sd_TextWindow)
Unframe proc (sd_TextWindow)
atom
var
sd_BalloonTails
movable
sd_BalloonTail movable atom
vars (sd_BalloonTail)
sd_OwnerMoved proc (sd_BalloonTail)


Updates

Version 9

back to Contents

Version 8

back to Contents

Version 7

back to Contents

Version 6

back to Contents

Version 5

back to Contents

Version 4

sd_Text released on BYONDscape.

back to Contents

sd_Text proc

See also:
sd_OverlayText proc
Format:
sd_Text(To, Text as text, Loc, Layer, line, offset, charset)
Arguments:
To:
person or list of people who will see the text images
Text:
text to display
Loc:
atom or list of atoms to display the Text on.
If Loc is a turf, text will automatically display on turfs to the right of Loc.
If Loc is a list, text will display on the atoms in the list with Loc[1] as the left edge and Loc[Loc.len] as the right edge.
Layer
graphics layer on which to display text
Default: Layer = FLY_LAYER
line
Which row to display the text on
0 = bottom half of the turf
!0 = top half of the turf
Default: line = 0
offset
initial offset (0-3) within the turf.
0 = far left       3 = far right
Default: offset = 0
charset
Icon file that contains the character font.
Examine the included 'charset.dmi' for the format.
Default: charset = 'charset.dmi'
Returns:
list of the images created
sd_Text draws text as a series of images on atoms. Since the text is stored as images, it can be displayed to your choice of clients and left invisible to others.
back to Contents

sd_OverlayText proc

See also:
sd_Text proc
Format:
sd_OverlayText(Text as text, Loc, Layer, line, offset, charset)
Arguments:
Text
text to display
Loc
atom or list of atoms to display the Text on.
Layer
graphics layer on which to display text
Default: Layer = FLY_LAYER
line
Which row to display the text on
0 = bottom half of the turf
!0 = top half of the turf
Default: line = 0
offset
initial offset (0-3) within the turf.
0 = far left       3 = far right
Default: offset = 0
charset
Icon file that contains the character font. The icon must have icon_states for each character.
Examine the included 'charset.dmi' for the format.
Default: charset = 'charset.dmi'
OverlayText draws text as overlays on atoms, this allows everyone to see the text.
back to Contents

sd_WordBalloon proc

See also:
sd_BalloonText proc
sd_BalloonTail movable atom
Format:
sd_WordBalloon(To, Text as text, atom/Owner, layer, delay, charset, balloon, rigid, fixedwidth, maxheight)
Arguments:
To
list of clients to display the WordBalloon to
Text
text to display in the balloon
Owner
the atom the balloon should point to
Default: Owner = usr
layer
graphics layer to draw the word balloon on
Default: layer = FLY_LAYER
delay
number of ticks to leave the balloon before removing it. If delay is 0 or less, the balloon will persist indefinately.
Default: delay = 150 (15 seconds)
charset
icon file that contains the character font. See the sd_Text entry for details.
Default: charset = 'charset.dmi'
balloon
icon that contains the balloon graphics. The balloon should have all the icon_states for frame icons used by sd_MapFrame (below) in addition to these two:
"dtail" = a tail that points DOWN between the balloon and the speaker.
"utail" = a tail that points UP between the balloon and the speaker.
Default: balloon = 'balloon50.dmi'
rigid
determines whether the balloon tail will slide along the edge of the balloon or if it is stuck rigidly in place.
0 = sliding tail
1 = rigid tail
Default: rigid = 0
fixedwidth
If fixedwidth is not set, the word balloon will scale in both width and height to fit as much text as possible into the fewest icons.

If fixedwidth is set (not zero), the word balloon is forced to be as many icons wide as the value of fixedwidth. (fixedwidth 2 yeaild a word balloon 2 icons wide.) The word balloon will automatically wrap long words to the next line. Balloon width should be 2 or greater for use with the standard balloon icons included with the sd_Text library.
Default: fixedwidth = 0 (autoscale)

maxheight
If fixedwidth is set, maxheight determines the maximum height of the word balloon in icons. maxheight has no effect if fixedwidth is not set.
Default: maxheight = 4
Returns:
The sd_BalloonTail created for the new Word Balloon.
sd_WordBalloon creates a mobile word balloon that will move to follow the Owner. The important balloon data is stored in an sd_BalloonTail and the sd_BalloonTail is stored in the Owner atom's sd_BalloonTails list.
back to Contents

sd_ImprovedWordBalloon proc

See also:
sd_WordBalloon proc
sd_BalloonText proc
Format:
sd_ImprovedWordBalloon(Text as text, atom/Owner, layer, delay, charset, balloon)
Arguments:
Text
text to display in the balloon
Owner
the atom the balloon should point to
Default: Owner = usr
layer
graphics layer to draw the word balloon on
Default: layer = FLY_LAYER
delay
number of ticks to leave the balloon before removing it. If delay is 0 or less, the balloon will persist indefinately.
Default: delay = 150 (15 seconds)
charset
icon file that contains the character font. See the sd_Text entry for details.
Default: charset = 'charset.dmi'
balloon
icon that contains the balloon graphics. The balloon should have all the icon_states for frame icons used by sd_MapFrame (below) in addition to these two:
"dtail" = a tail that points DOWN between the balloon and the speaker.
"utail" = a tail that points UP between the balloon and the speaker.
Default: balloon = 'balloon50.dmi'
sd_ImprovedWordBalloon creates a mobile word balloon using the pixel offset vars. The sd_ImprovedWordBalloon takes less processor power when you move, and allows you to see the entire word balloon regardless of opaque obstructions.
back to Contents

sd_BalloonText proc

See also:
sd_WordBalloon proc
Format:
sd_BalloonText(Text as text, turf/Loc, delay, charset, balloon)
Arguments:
Text
text to display inside the balloon
Loc
the turf the balloon should point to
delay
number of ticks to leave the balloon before removing it.
Default: delay = 150 (15 seconds)
charset
icon file that contains the character font. See the sd_Text entry for details.
Default: charset = 'charset.dmi'
balloon
icon that contains the balloon graphics. The balloon should have all the icon_states for frame icons used by sd_MapFrame in addition to these two:
"dtail" = a tail that points DOWN between the balloon and the speaker.
"utail" = a tail that points UP between the balloon and the speaker.
Default: balloon = 'balloon50.dmi'
sd_BalloonText is an early form of sd_WordBalloon from the MapText library that creates immobile word balloons on turf's only. It is left in sd_Text library to ease conversion of programs from MapText to sd_Text. I strongly recommend using sd_WordBalloon.
sd_BalloonText combines sd_MapFrame and sd_Text to create word balloons visible to each mob within view() of Loc.
back to Contents

sd_MapFrame proc

See also:
sd_OverlayFrame proc
Format:
sd_MapFrame(To, Left, Right, Top, Bottom, Z, Layer, frame)
Arguments:
To
person or list of people who will see the images
Left
x coordinate of the left side of the box.
Right
x coordinate of the right side of the box.
Top
y coordinate of the top of the box.
Bottom
y coordinate of the bottom side of the box.
Z
z coordinate of the box.
Layer
graphics layer on which to display text
Default: Layer = FLY_LAYER
frame
the icon that contains the box graphics. A frame icon should have the following icon_states:
		tl   tm   tr	See the included 'frame.dmi' and
		cl   cm   cr	'balloon50.dmi' files for examples.
		bl   bm   br
		
Default: frame = 'balloon50.dmi'
Returns:

list of the images created
sd_MapFrame draws a box as images on map turfs.
back to Contents

sd_OverlayFrame proc

See also:
sd_MapFrame proc
Format:
sd_OverlayFrame(Left, Right, Top, Bottom, Z, Layer, frame)
Arguments:
Left
x coordinate of the left side of the box.
Right
x coordinate of the right side of the box.
Top
y coordinate of the top of the box.
Bottom
y coordinate of the bottom side of the box.
Z
z coordinate of the box.
Layer
graphics layer on which to display text
Default: Layer = FLY_LAYER
frame
the icon that contains the box graphics. A frame icon should have the following icon_states:
		tl   tm   tr	See the included 'frame.dmi' and
		cl   cm   cr	'balloon50.dmi' files for examples.
		bl   bm   br
		
Default: frame = 'balloon50.dmi'
sd_OverlayFrame draws a box as overlays on map turfs, this allows
everyone to see the box.
back to Contents

sd_FontIndex proc

See also:
sd_RegisterFont proc
Format:
sd_FontIndex(Font as icon)
Arguments:
Font
The font icon.

Each character to be displayed by the font must have an icon_state named for that character. For example, the letter "A" should be in an icon_state labeled "A". Icon_state "a" must be a separate icon_state if it is to be displayed.

Characters should fit within the lower left corner of the icon, from 1-8 horizontally and 1-16 vertically.

The font should also contain a blank unlabeled icon_state to display a blank space for characters not included in the font.

See the charset.dmi for an example.

Returns:

Index number for a font in sd_FontRegistry.
sd_FontIndex returns the sd_FontRegistry index of a font. If the font is not found, it will be added to the registry.
back to Contents

sd_RegisterFont proc

See also:
sd_FontIndex proc
Format:
sd_RegisterFont(Font as icon)
Arguments:

Font
The font icon. See sd_FontIndex() for imformation on font icons.
sd_RegisterFont stores a font into the sd_FontRegistry so it may be accessed quickly by the text functions.

sd_RegisterFont is called automatically by the sd_Text procs if a font is not registered. You don't need to use it unless you want to pre-register a font before drawing text.

back to Contents

sd_Input proc

See also:
sd_TextWindow datum
Format:
sd_Input(atom/Client, list/List, X, Y, width, height, Selections, frame, Layer, charset, windowicon, scrollicon)
Arguments:

Client
The mob or client of the player to be queried.
Default: Client = usr
List
List of text and/or atoms that may be selected.
X
The X coordinate of the left side of the input window.
Default: X = 1
Y
The Y coordinate of the bottom side of the input window.
Default: Y = 1
width
The width (in icon tiles) of the input window.
Default: width = Client.sd_ScreenWidth()
height
The height (in icon tiles) of the input window.
Default: height = 3
Selections
The number of selections the sd_Input must wait for.
Default: Selections = 1
frame
Determines if this window has a frame around the outside
0 = no frame
1 = frame only where it overlaps the default view
2 = complete frame
text = frame only where it overlaps the default view, then Unframe(text). See sd_TextWindow.Unframe()
Default: frame = 1
Layer
graphics layer on which to display text
Default: Layer = FLY_LAYER
charset
Icon file that contains the character font.
See sd_FontIndex for details on the font icon.
Default: charset = 'charset.dmi'
windowicon
Icon file that contains the window icon.
Default: windowicon = 'window50.dmi'
scrollicon
Icon file that contains the scroll arrows.
Default: scrollicon = 'scrollarrows.dmi'
Returns:

If selections = 1 (default), returns the text or atom selected. Otherwise, sd_Input returns a list of all the selected text and/or atoms.
sd_Input displays a list of options in a text window on the client screen and lets the client select one or more items from the list.

sd_Input requires a mouse.

back to Contents

sd_ScreenHeight proc (client)

See also:
sd_ScreenWidth proc (client)
Format:
sd_ScreenHeight()
Returns:

The height, in tiles, of client.view
This proc returns the height of client.view, no matter if view is numeric or text.
back to Contents

sd_ScreenWidth proc (client)

See also:
sd_ScreenHeight proc (client)
Format:
client.sd_ScreenWidth()
Returns:

The width, in tiles, of client.view
This proc returns the width of client.view, no matter if view is numeric or text.
back to Contents

sd_TextWindow datum

See also:
read only vars (sd_TextWindow)
read/write vars (sd_TextWindow)
procs (sd_TextWindow)
The sd_TextWindow draws and maintains a client screen box for displaying scrolling text and/or atoms.
back to Contents

read only vars (sd_TextWindow)

See also:
sd_TextWindow datum
read/write vars (sd_TextWindow)
procs (sd_TextWindow)
These vars provide information about an sd_TextWindow, but should never be overwritten manually or the window may not function properly.
client/Client
The client this window belongs to
X
Left boundry of the window
Y
Bottom boundry of the window
Layer
layer of the window display
height
height of the window
width
width of the window
Lines
List of text and/or atoms displayed in the window
back to Contents

read/write vars (sd_TextWindow)

See also:
sd_TextWindow datum
read only vars (sd_TextWindow)
procs (sd_TextWindow)
These vars may be changed manually.
offset
offset in the Lines list to the top line currently displayed in the window. If you change offset, you should call Update() the window to display the change.
maxlines
maximum number of lines allowed in Lines. When maxlines is exceeded, the oldest line will be deleted. Setting maxlines less than Lines.len will not decrease the curretn number of lines, but will prevent it from increasing.
Default value: maxlines = 255
highlight
If set, the window will highlight and select lines if they are clicked.
select
List of selected line numbers. Selected lines are displayed with a highlight.

back to Contents

procs (sd_TextWindow)

See also:
sd_TextWindow datum
read only vars (sd_TextWindow)
read/write vars (sd_TextWindow)
Built in sd_TextWindow procs:
sd_TextWindow/proc
New proc (sd_TextWindow)
Append proc (sd_TextWindow)
AtomImage proc (sd_TextWindow)
Unframe proc (sd_TextWindow)
Update proc (sd_TextWindow)
back to Contents

New proc (sd_TextWindow)

See also:
sd_TextWindow datum
Format:
New(atom/Client, X, Y, width, height, wordwrap, scroll, frame, highlight, maxlines, Layer, windowicon, scrollicon)
Arguments:
Client
The mob or client of the player to be queried.
Default: Client = usr
X
The X coordinate of the left side of the input window.
Default: X = 1
Y
The Y coordinate of the bottom side of the input window.
Default: Y = 1
width
The width (in icon tiles) of the input window.
Default: width = Client.sd_ScreenWidth()
height
The height (in icon tiles) of the input window.
Default: height = 3
wordwrap
if set, lines longer than the window width will wrap to the next line
scroll
If 0, this window will not have scroll arrows.
Default: scroll = 1
frame
Determines if this window has a frame around the outside
0 = no frame
1 = framed only where it overlaps the default view
2 = complete frame
Default: frame = 1
highlight
If set, the window will highlight and select lines if they are clicked.
Default: highlight = 0
maxlines
maximum nuber of lines allowed.
Default: maxlines = 255
Layer
graphics layer on which to display text
Default: Layer = FLY_LAYER
windowicon
Icon file that contains the window icon.
Default: windowicon = 'window.dmi'
scrollicon
Icon file that contains the scroll arrows.
Default: scrollicon = 'scrollarrows.dmi'
called when you create a new sd_TextWindow
back to Contents

Update proc (sd_TextWindow)

See also:
sd_TextWindow datum
AtomImage proc (sd_TextWindow)
Format:
Update()
Updates the window display.
back to Contents

Append proc (sd_TextWindow)

See also:
sd_TextWindow datum
Format:
Append(Line, charset, update)
Arguments:
Line
Text or atom to append to the end of the window display. Atoms will display the icon, the name, and the suffix.
charset
Font used to display this item.
Default: charset = 'charset.dmi'
update
If set, the window will automatically update to display the new line.
Add a line of text or an atom to the window.
back to Contents

AtomImage proc (sd_TextWindow)

See also:
sd_TextWindow datum
Update proc (sd_TextWindow)
Format:
AtomImage(atom/A, atom/movable/M)
Arguments:
atom/A
The original atom being displayed
atom/movable/M
The sd_TextWindow display atom for A
Default Action:
none
AtomImage() provides a hook in sd_TextWindow/Update() allowing the program to further customize the display of atom within an sd_TextWindow.

Example:

sd_TextWindow/AtomImage(atom/A, atom/movable/M)
	M.name = A.name 
	// name the window display the same as the original atom 
	if(istype(A,/obj/numbered)) // if A is a numbered obj
		var/obj/numbered/N = A // give it an alias
		// convert the number to text for sd_OverlayText
		var/Text = num2text(N.number)
		// put the text on the upper right of the icon
		sd_OverlayText(Text, M, Layer, 1, 4-lentext(Text))
back to Contents

Unframe proc (sd_TextWindow)

See also:
sd_TextWindow datum
Format:
Unframe(part as text)
Arguments:
part
part of the frame to remove.
Valid parts are:
null - remove the entire frame

"bl" - bottom left corner of the frame
"bm" - bottom middle of the frame (all the bottom except the corners)
"br" - bottom right corner of the frame
"cl" - center left of the frame (all the left except the corners)
"cr" - center right of the frame (all the right except the corners)
"tl" - top left corner of the frame
"tm" - top middle of the frame (all the top except the corners)
"tr" - top right corner of the frame

"b" - bottom of the frame (includes bl,bm & br)
"l" - left of the frame (includes bl,cl & tl)
"r" - right of the frame (includes br,cr & tr)
"t" - top of the frame (includes tl,tm & tr)
remove all or part of the window frame.
back to Contents

sd_BalloonTails var (atom)

See also:
sd_BalloonTail movable atom
sd_BalloonTails is a list of all the BalloonTails attached to the atom.
back to Contents

sd_BalloonTail movable atom

See also:
sd_BalloonTails var (atom)
vars (sd_BalloonTail)
sd_OwnerMoved proc (sd_BalloonTail)
sd_BalloonTail corresponds to the tail of a word balloon. It keeps track of all the other parts of the word balloon and keeps it linked to the attached atom. When the tail is deleted, it destroys the rest of the word balloon automatically.
back to Contents

vars (sd_BalloonTail)

See also:
sd_BalloonTail movable atom
list/Balloon[]
list of movable atoms that make up this balloon
above
Keeps track of whether the balloon is above or below the owner.
1 = above the owner
-1 = below the owner
height
height (in tiles) of the balloon
width
width (in tiles) of the balloon
rigid
If 0, the tail will slide along the edge of the balloon, only moving the balloon if the tail moves beyond the edge. If 1, the balloon moves each time the Owner moves.
image/Image
image on the tail
back to Contents

sd_OwnerMoved proc (sd_BalloonTail)

See also:
sd_BalloonTail movable atom
Format:
sd_OwnerMoved(atom/movable/Owner)
Arguments:
atom/movable/Owner
Atom the WordBalloon is following.
sd_OwnerMoved is called automatically whenever the owner of the sd_BalloonTail calls the Move() proc. It updates the position of the tail and word balloon, changing the orientation of the balloon as necessary to keep it within the world boundries.
back to Contents