lxFirebal69xl Posted February 23, 2016 Share Posted February 23, 2016 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? Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 23, 2016 Author Share Posted February 23, 2016 A day later, and I still haven't figured this one out, must be super obvious and I'm not seeing it. Quote Link to comment Share on other sites More sharing options...
Brutile Posted February 23, 2016 Share Posted February 23, 2016 You say it uses self.GetText()... Shouldn't it be self:GetText() with a : not a . Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 23, 2016 Author Share Posted February 23, 2016 You say it uses self.GetText()... Shouldn't it be self:GetText() with a : not a . I was right, it was obvious...that fixed the error popping up, but the text doesn't show up. Quote Link to comment Share on other sites More sharing options...
thehankinator Posted February 24, 2016 Share Posted February 24, 2016 I don't see anything obvious in the code you posted. Normally I start putting prints all over to figure out if the code in the area that I am looking at is even getting run. For example I'd put a print after each if check for pickInfo, then if all that is getting run, I'd put some prints in PostRender() looking at self.text. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.