Scripts / conversations panel with text

Author
Message
software_bundle
5
Years of Service
User Offline
Joined: 30th Jun 2018
Location:
Posted: 10th Jul 2018 18:52
Hello, i trys now for 3 days to figure it out how i can finish this script and i hope somebody can help me. I just want that if i come to a npc i press E and a Panel goes on and i can read what the NPC says and if i press E again i need that the Panel close. I have try myself i get the planel open and can read the text but i need to press all time E, that means i holding the E button and can read it. But thats not i want. I hope somebody can help me to figure it out. Thank you

CODE :

local PlayerDist_near = 100;
local PlayerDist_far = 100;
local sat = {}

PlayerDist = GetPlayerDistance(e)
if PlayerDist <= PlayerDist_near then
Prompt ( "Press E to talk" )
if g_KeyPressE == 1 then

Panel(25,40,75,60)
TextCenterOnXColor(50,45,1, "Hello" ,100,255,100)
PromptTextSize(4)
end
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 10th Jul 2018 19:09
Is that the whole script?

You'll need some sort of 'latch' variable to make sure the text and panel stay showing when you let go of the key.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Jul 2018 19:09 Edited at: 10th Jul 2018 19:11


i'm assuming not as he said it works and he has some code to sit the character down too but as it's not included here i just encased it in a working script anyway, hopefully he can figure out how to get the sitting code back in
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
software_bundle
5
Years of Service
User Offline
Joined: 30th Jun 2018
Location:
Posted: 10th Jul 2018 19:19 Edited at: 10th Jul 2018 22:16
Yes sry i have forget the sitting part, i have think its not nessesary, sry :

local PlayerDist_near = 100;
local PlayerDist_far = 100;
local sat = {}


function ai_sit_init(e)
sat[e] = 1
end

function ai_sit_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist = PlayerDist_near then
Prompt ( "Press E to talk" )
if g_KeyPressE == 1 then

Panel(35,70,25,30)
TextCenterOn( "Hello")


end

end

if sat[e] = 1 and g_Entity[e]['animating'] == 0 then
StartTimer(e)
SetAnimationFrames(e,3800)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
sat[e] = 0

elseif PlayerDist > PlayerDist_far and sat[e] == 2 then
LookAtPlayer(e);
sat[e] = 1
end
end
PM
software_bundle
5
Years of Service
User Offline
Joined: 30th Jun 2018
Location:
Posted: 10th Jul 2018 19:35 Edited at: 10th Jul 2018 19:53
smallg no idea how i can make that to a working script..i starts with lua 3 days ago Have try to use you script alone, but it dosnt work...
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 11th Jul 2018 00:17
does it give any error? looks ok to me but i didn't run it so it's possible there's a mistake
save it as talking_npc.lua
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
software_bundle
5
Years of Service
User Offline
Joined: 30th Jun 2018
Location:
Posted: 11th Jul 2018 07:42
Ahh ok, i try it later iam home, thank you a lot for you time
PM

Login to post a reply

Server time is: 2024-04-24 04:13:27
Your offset time is: 2024-04-24 04:13:27