function OnStartText(text)
if text:getLink(VTextOwner):isEmpty() then
local finalPoint=game:getPoint(VGameScrollPosition)
finalPoint.x=finalPoint.x + game:getPoint(VGameWindowResolution).x/2
text:setValue(VTextPosition, finalPoint)
isNarratorText=true
narratorText=text
end
endfunction OnStopText(text)
if text:getLink(VTextOwner):isEmpty() then
isNarratorText=false
end
end
function OnMainLoop()
if isNarratorText then
if not((game:getInt(VGameScrollDirectionHorizontal)==0) and (game:getInt(VGameScrollDirectionVertical))==0) then
local finalPoint=game:getPoint(VGameScrollPosition)
finalPoint.x=finalPoint.x + game:getPoint(VGameWindowResolution).x/2
narratorText:setValue(VTextPosition, finalPoint)
end
end
end
registerEventHandler("textStarted","OnStartText")
registerEventHandler("textStopped","OnStopText")
registerEventHandler("mainLoop", "OnMainLoop")
The main loop code makes sure that the text stays in place even if the room is scrolling.
Hope you like it if you have problems with making it work or modifying it let me know. I can post some variations
Cheers SpacePaw
If you use the "GameWindowResolution" field you could make the script resolution independent, instead of hardcoding the 640px width.
If you use the "GameWindowResolution" field you could make the script resolution independent, instead of hardcoding the 640px width.
Absolutely right - modified the code above so it's universal now I'm not used to visionaire data structure yet
nice one man - saved me some time from trying to figure out how to use it from the - not so clear - syntax example.
well your script wasn't exactly clear how to use either but I've re-written it slightly & added notes to it to make it easier to understand.
pastebin - nice & color coded & all that jazzy stuff!
simple things first ...
go into the "Game" options panel & set "speaker text alignment to "centered" ... * quick note as mentioned above displayed text displays the first font found in the font list ... + unless you declare it I guess?
to use the narrator script ...
select action part > miscellaneous > display text ... add text. * if you want to be able to scroll/perform other actions then check the "show as background text" box ... + background text can not be skipped!
--[[
narrator text position script by Spacepaw
modified by AFRLme
-- * --
script type: definition
-- * --
define absolute position of speaker text!
-- * usuage * --
in the editor set: game > speaker text alignment to "centered"!
then to display text: select action part > misc > display text > add text to display!
if you want to be able to walk about & do other things while narrator text is visible then ...
check the "show as background text" box!
only downfall to background text is you can't skip it!
--]]-- * this gets & declares the x, y position of the speaker text * --
function OnStartText(text)
if text:getLink(VTextOwner):isEmpty() then
local finalPoint=game:getPoint(VGameScrollPosition)
finalPoint.x = finalPoint.x + game:getPoint(VGameWindowResolution).x / 2 -- declares game resolution x /shared by 2 to get center!
finalPoint.y = finalPoint.y + game:getPoint(VGameWindowResolution).y - 100 -- declares game resolution y (bottom) change - 100 offset to whatever you want!
text:setValue(VTextPosition, finalPoint)
isNarratorText=true
narratorText=text
print('xPos=' .. finalPoint.x .. ' yPos=' .. finalPoint.y .. ' onStart!') -- prints the x,y position values to the log!
end
end
-- * kills the loop when the text has finished displaying - I think? * --
function OnStopText(text)
if text:getLink(VTextOwner):isEmpty() then
isNarratorText=false
end
end
-- * loop to keep the displayed text in the same position on screen scroll * --
function OnMainLoop()
if isNarratorText then
if not((game:getInt(VGameScrollDirectionHorizontal)==0) and (game:getInt(VGameScrollDirectionVertical))==0) then
local finalPoint=game:getPoint(VGameScrollPosition)
finalPoint.x = finalPoint.x + game:getPoint(VGameWindowResolution).x / 2
finalPoint.y = finalPoint.y + game:getPoint(VGameWindowResolution).y - 100
narratorText:setValue(VTextPosition, finalPoint)
print('xPos=' .. finalPoint.x .. ' yPos=' .. finalPoint.y .. ' onMain!') -- prints the x,y position values to the log!
end
end
end
registerEventHandler("textStarted","OnStartText")
registerEventHandler("textStopped","OnStopText")
registerEventHandler("mainLoop", "OnMainLoop")
in the script area of the Visionaire Studio editor > create a new script & in the properties tab set the script type to "definition" (not sure what it's called in German but it's the option on the right hand side)
then copy/paste the code above into the script.
see if you can work out the rest from the attachments I added ...
this script automatically positions displayed text only (does not position displayed text by characters but I think it shouldn't be too hard to edit this to include both - will look into it sometime in the future)