First of all, is there any way to resize the textbox slices while maintaining text wrap and not screwing everything up? The script I'm currently sporting uses textbox line() to copy lines from textboxes defined in custom into a text slice. I'm not sure if that's the bet way to do it. The wrap is kinda messed up. Sometimes words go off the box a bit and I'm not sure how to prevent that.
The code is below. The keypress handler checks if a global, displayed text, is greater than -1, then calls "advance formatted text(id)" if it is.
Code: Select all
plotscript, show formatted text, id=0, begin
variable(root,box,txt,line,height)
clear string(str:set)
clear string(str:temp)
# sli:textroot is a container slice
# on the HUD slice collection
root := lookup slice(sli:textroot,HUD)
for(line,0,7) do(
textbox line(str:temp,id,line)
concatenate strings(str:set, str:temp)
$str:set+" "
if(string length(str:temp) > 0) then(
height += 1)
)
height := (string length(str:set) / 29) * 10 + 18
box := create rect(240,height)
set padding(box,4)
set parent(box, root)
txt := create text
set wrap(txt,true)
set parent(txt,box)
set slice text(txt,str:set)
clear string(str:set)
clear string(str:temp)
# This makes the keypress not allow
# movement, NPC interaction, etc.
displayed text := id
end
script, advance formatted text, id, begin
variable(root)
root := lookup slice(sli:textroot,HUD)
displayed text := -1
# the first child of root should be
# "box" from the above script
free slice(slice child(root,0))
end