Sign in to follow this  
--- -.-

[Solved] How to get rid of character's text on examine?

Recommended Posts

--- -.-    3853

Hello, I have a question if someone can help that'd be great :D!

So, basically I'd like to know is there a way to remove/erode away the text above the character's head when they talk faster than default speed or even better to be able to remove/erode away it instantly?

I looked through "talker.lua" & "followtext.lua" but I don't really understand them.. In talker.lua there was something "self.duration = duration" which maybe means how long the text will stay, but I have no idea how to use it :(...

Also, is there a way to change the color of speech text for a specific character? I didn't see anything like that in talker.lua either..

 

EDIT: I see in talker.lua in function " local function sayfn(self, script, nobroadcast, colour) " there's something called " self.widget:Kill() " I think that's how to make the text go away, but does anyone know how I could use it :)?

 

Thanks very much for reading my question & have a wonderful day/night :D!!

Edited by SuperDavid

Share this post


Link to post
Share on other sites
--- -.-    3853

By speech text  I don't mean like the character talking I mean like...

text.jpg

 

"inst.components.talker:ShutUp()" Makes the character stop making talk sounds, but doesn't remove that text faster..

I just want to be able to remove that text manually because I feel it's awkward to have that text last for 5 seconds when the character just said "Ow" :)!

Share this post


Link to post
Share on other sites
Serpens    553

Ah, I thought it would also remove text.


The Say function in the talker component looks like this:
function Talker:Say(script, time, noanim, force, nobroadcast, colour)
So did you try:
inst.components.talker:Say("Ah",0.5) ? Not sure, but I would expect that "time" is the display time.

Share this post


Link to post
Share on other sites
--- -.-    3853

Thank you Serpens :)!

 

So, I did how you said it might work & this is my code now

Spoiler

local function Attacked(inst, data)

local sane_words = { "Ow!!", "Ugh!!", "Ack!!", "Ngh!!" }

local insane_words = { "RrArRhHh!!!", "GrArRgHh!!!", "GhRrAaHh!!!", "GgUuHhRr!!!" }

local gelid_words = { "...", "...!", "Ow...", "Ow...!" }

	if inst.gelid_mode == nil then
		inst.components.hunger:DoDelta(-data.damage * .3)
		inst:DoTaskInTime(.08, function(inst) inst.components.talker:ShutUp() end)
		
		if inst.components.sanity:IsSane() then
			inst.components.sanity:DoDelta(-data.damage * .3)
			inst.components.talker:Say(sane_words[math.random(1,4)], .5)

		elseif not inst.components.sanity:IsSane() then
			inst.components.talker:Say(insane_words[math.random(1,4)], .5)
		end
	end

	if inst.gelid_mode == true then
		inst.components.hunger:DoDelta(-data.damage * .15)
		inst:DoTaskInTime(.08, function(inst) inst.components.talker:ShutUp() end)
	
		if inst.components.sanity:IsSane() then
			inst.components.talker:Say(gelid_words[math.random(1,4)], .5)

		elseif not inst.components.sanity:IsSane() then
			inst.components.talker:Say(insane_words[math.random(1,4)], .5)
		end
	end
	
end

 

so my talker it's like "  inst.components.talker:Say(sane_words[math.random(1,4)], .5)  "

& look how fast the text goes (this is on world with no caves), I don't think it's because it's .5 cause I tried 2 & it still went super fast!

wat.gif

And on a world with caves enabled nothing changed no matter how low or high the number was! But still thanks so much for your help man :D!!!!!

Share this post


Link to post
Share on other sites
Serpens    553

I just tested this in my quest mod I'm currently working on, and it worked without problems.
The number is the time in seconds. So 0.5 is showing it 0.5 seconds. I tested 0.5 and 100.

Maybe try removing the ShupUp code? 0.08 seconds would fit to the image, so I guess ShutUp is also removing the text, like I thought ;)

Share this post


Link to post
Share on other sites
--- -.-    3853

Okay, so I removed the shutup code & in world without caves it lasted 1 second all good :D!! 

And it's weird since the shutup code only seems to remove text when the text is given a duration, hahaha.

Also, on world with caves enabled it lasted like default text which's like 3-5 seconds..basically it did no effect in world with caves, maybe you know how fix that :)? It's fine if you don't & thanks again for your help man :D!!!

 

Share this post


Link to post
Share on other sites
Serpens    553
1 minute ago, SuperDavid said:

Ah, I see :). Thank you very much for your help Serpens :D!!

the only thing I can imagine, that you could try to put the say command somewhere, where it is executed from client AND server, not only from server.

Share this post


Link to post
Share on other sites
PanAzej    2015

You could edit the talker component itself with a PostInit, it'd look something like this:

local function TalkerPostInit( talker )
	local _oldSay = talker.Say
	talker.Say = function( self, script, time, noanim, force, nobroadcast, colour )
		if self.inst and self.inst.prefab == "prefab_name" and some_variable_that_makes_the_character_not_talk then
			return
		else
			_oldSay(self, script, time, noanim, force, nobroadcast, colour)
		end	
	end
end
AddComponentPostInit("talker", TalkerPostInit)

 

Edited by PanAzej
Edited 10000 times. I'm pretty sure now it should work. Probably.

Share this post


Link to post
Share on other sites
--- -.-    3853
On 3/14/2017 at 2:41 AM, PanAzej said:

You could edit the talker component itself with a PostInit, it'd look something like this:

I just wanna say your code is amazing, it makes the character completely mute in both speech & text, exactly what I needed :D!!!!! Thanks so, so much @PanAzej :D!!!!

Share this post


Link to post
Share on other sites
Serpens    553

@SuperDavid
Did you already find out, how the "colour" must look like to give the text colour?
Is it a table with 3 values between 0 and 1 , like it is for SetColour?

According to your screenshot you found that out already :)

Edited by Serpens

Share this post


Link to post
Share on other sites
Serpens    553
3 minutes ago, SuperDavid said:

@Serpens

Actually, I didn't... That text is from the chat which changes all text to a different color :dispirited:...

If you know that would be so helpful dude :eagerness:!!

I found it in the lucy prefab:
inst.components.talker.colour = Vector3(.9, .4, .4)

Share this post


Link to post
Share on other sites
Serpens    553

The colour within the Say() function works a bit different, took me an hour to find out how..
in the Say() function the colour has to be {0.9,0.4,0.4,1}. So no Vector and a fourth value for transparent.

edit:
for everyone who wonders:
The numbers are RGBA values. You can find out your colour eg. online with RGB converter or similiar. RGB has values from 0 to 255. To find out which number to use divide your number by 255. So if you want R=255 and others 0, use 1, 0, 0.

Edited by Serpens

Share this post


Link to post
Share on other sites
Serpens    553

like the "duration", also the colour does not work for clients, only server. To solve this there are two ways I think:
Call the Say() function (or talker.colour) somewhere, where it is executed for server and client.
Or use "netvars" to tell the client about  RGB values.
Instead of the colour entry in Say() function, I decided to use the talker.colour value:

First code block in modmain.
Second code block there, were I want to change the colour.

local function OnDirtyEventQuestRGB(inst) -- function called for client, when rgb value is changed for a questgiver
    inst.components.talker.colour = GLOBAL.Vector3(inst["mynetvarQuestsR"]:value()/255, inst["mynetvarQuestsG"]:value()/255, inst["mynetvarQuestsB"]:value()/255)
end

AddPrefabPostInit("pigking",function(inst)
    if inst.components.talker==nil then
        inst:AddComponent("talker")
    end
    inst.components.talker.offset = GLOBAL.Vector3(0, -500, 0) -- default is Vector3(0, -400, 0)
    inst.components.talker.fontsize = 40 -- 35 ist default
    inst.components.talker.colour = GLOBAL.Vector3(1, 1, 1) 
    

    inst["mynetvarQuestsR"] = GLOBAL.net_byte(inst.GUID, "QuestsRNetStuff", "DirtyEventQuestsR") 
    inst["mynetvarQuestsR"]:set(255)
    inst["mynetvarQuestsG"] = GLOBAL.net_byte(inst.GUID, "QuestsGNetStuff", "DirtyEventQuestsG") 
    inst["mynetvarQuestsG"]:set(255)
    inst["mynetvarQuestsB"] = GLOBAL.net_byte(inst.GUID, "QuestsBNetStuff", "DirtyEventQuestsB") 
    inst["mynetvarQuestsB"]:set(255)
    inst:ListenForEvent("DirtyEventQuestsR", OnDirtyEventQuestRGB)
    inst:ListenForEvent("DirtyEventQuestsG", OnDirtyEventQuestRGB)
    inst:ListenForEvent("DirtyEventQuestsB", OnDirtyEventQuestRGB)
end)
self.inst.components.talker.colour = Vector3(0, 1, 0) 
self.inst["mynetvarQuestsR"]:set(0)
self.inst["mynetvarQuestsG"]:set(255)
self.inst["mynetvarQuestsB"]:set(0)
Edited by Serpens

Share this post


Link to post
Share on other sites
--- -.-    3853

So, 

using " inst.components.talker.colour = Vector3(.9, .4, .4) " doesn't work for clients? Sorry, I'm just confused which code would I use to change the character's text color, hahaha..

Share this post


Link to post
Share on other sites
Serpens    553
53 minutes ago, SuperDavid said:

So, 

using " inst.components.talker.colour = Vector3(.9, .4, .4) " doesn't work for clients? Sorry, I'm just confused which code would I use to change the character's text color, hahaha..

it depends on where you write that line.
If you put it somewhere where it is executed for clients and server, this and the say() function will work for both.
But I'm changing colour within a component and most components only exist for servers. That's why the colour change only work for servers in my case.

Share this post


Link to post
Share on other sites
RadiantRoma    386
On 3/15/2017 at 8:15 AM, SuperDavid said:

I just wanna say your code is amazing, it makes the character completely mute in both speech & text, exactly what I needed :D!!!!! Thanks so, so much @PanAzej :D!!!!

would you mind sharing with me the code you ended up with? I'm not sure what variable to put for "some_variable_that_makes_the_character_not_talk". And this would go into the character's prefab, or modmain?

Share this post


Link to post
Share on other sites
--- -.-    3853

Well, you'd put this in modmain.lua

Spoiler

local function TalkerPostInit( talker )
	local _oldSay = talker.Say
	talker.Say = function( self, script, time, noanim, force, nobroadcast, colour )
		if self.inst and self.inst.prefab == "adam" and self.inst.kill_text == true then
			return
		else
			_oldSay(self, script, time, noanim, force, nobroadcast, colour)
		end	
	end
end
AddComponentPostInit("talker", TalkerPostInit)

 

then with that whenever you want your character to shut up you'd put "inst.kill_text = true" & he would stop talking, I think!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this