A long time ago I had this problem with text overlapping itself when you used some entities in the game, then Rick (thanks by the way) came along and fixed this issue. This is the code right now:
Inside FPSPlayer.lua right below the default variables:
Script.DisplayTimeMax = 4000
local font1 = Font:Load("Fonts/MODERN SERIF ERODED.ttf", 20)
In the Start():
self.text = ""
Inside the UpdateWorld()
if pickInfo.entity ~= nil then
if pickInfo.entity.script ~= nil then
if pickInfo.entity.script.GetText ~= nil then
self.text = pickInfo.entity.script:GetText()
self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax
end
end
end
Under PostRender(context)
if self.text ~= "" then
context:SetBlendMode(Blend.Alpha)
context:SetFont(font1)
if self.DisplayTime > Time:GetCurrent() then
context:SetColor(255,255,255)
context:DrawText(self.text, 100, 600)
else
-- reset
self.text = ""
end
end
This is all that was required (back in 2015) to set up the player script, then we had this simple code for the entities:
Script.ObjectDescription = "" --string "Object Description"
function Script:GetText()
return self.ObjectDescription
end
function Script:Disable()--in
self.enabled=false
end
Now the only problem here is that the hand icon doesn't actually show up, so the player can't interact with it, I tried doing a Use(context) function that called the self.GetText() but that just caused the game to exit out with an error saying:
Script Error
attempt to index local 'self' (a nil value)
Line 8
So any thoughts as to how I would resolve this issue?