Scripts / how can I make my npc talk

Author
Message
probluebox123
9
Years of Service
User Offline
Joined: 26th May 2015
Location:
Posted: 27th May 2015 15:04
Hi, everyone, Iv been trying to find out how I can make my npc talk, just the basics like hello for what can I do for you, just like in the 2d rpg games where that text is displayed on the bottom of the screen. Thanks you.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th May 2015 15:56
shop_keeper.lua


change the 200 to larger number to increase the range at which the text appears
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
spudnick
14
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 28th May 2015 15:38
Aw that is a nice little scrip thank you
PM
Bradaus
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 8th Aug 2014
Location:
Posted: 8th Jun 2015 17:04
is there a way to make the character (when approached by the player) to play an audio file?
Win7 Ultimate 64bit, i7 , 32GB RAM Gskill, SSD, GTX 680, Logitech G19
TheSourceCode
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 8th Jun 2015 17:17 Edited at: 8th Jun 2015 17:18
Quote: "is there a way to make the character (when approached by the player) to play an audio file?"


If you place down a sound zone and go to its properties panel, and change the sound (which is located at the bottom) and select your audio file where you had it last, the audio should trigger after stepping on the sound zone..

Hope this helps!
PM
Bradaus
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 8th Aug 2014
Location:
Posted: 9th Jun 2015 11:24
Cheers TheSourceCode, I have been doing that and it works well. Only problem with using the sound zone is I can only get it to play once.
Win7 Ultimate 64bit, i7 , 32GB RAM Gskill, SSD, GTX 680, Logitech G19
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 9th Jun 2015 22:35
Or you could use this (just updated smallg's code above) attached to the NPC:



Place the sound file (.wav or .ogg) in audiobank folder and point to it in the characters property - Sound1 field (not Soundset).
Bradaus
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 8th Aug 2014
Location:
Posted: 13th Jun 2015 15:07
Hi cybernescence,

I tried your code however I keep getting the following message when loading the game:

No function called shop_keeper_main_main

I created the .lua file and called it shopkeeper_main then set the audio file in the sound1 field. Is there something else I should be doing.

Cheers,

Brad
Win7 Ultimate 64bit, i7 , 32GB RAM Gskill, SSD, GTX 680, Logitech G19
TheSourceCode
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 13th Jun 2015 15:56 Edited at: 13th Jun 2015 15:57
Bradus, try making it 'shop_keeper'.

Hope I could help!

-TheSourceCode
PM
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 13th Jun 2015 17:10
Hi,

here's the script as an attachment.

Cheers.

Attachments

Login to view attachments
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 13th Jun 2015 18:38
Hey cybernescence for multiply audio files what methods do you recommended? Are we limited to just the one soundset1? or can you use soundset2 and so on?
i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce 420 GT
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 13th Jun 2015 19:45
For sounds attached to entities it looks like we're constrained to two.

For character entities (ischaracter = 1 in the fpe), the first "slot" in the fpe (e.g. soundset = Male) is used to reference an audiobank\character folder, in this example 'male' - so files\audiobank\character\male. In this folder there are sub folders, e.g. onAggro, OnAlert and within these folders are many sound files 0.wav, 1.wav, 2.wav.

Within a lua script for a character, can use the command SetCharacterSound(e,"male"). This tells the engine to look at the folder "files\audiobank\character\male" for the next character sound commands used in the script, so PlayCharacterSound(e,"onAlert") will look into " files\audiobank\character\male\onAlert" folder and pick one of the sounds in there at random to play (one of 0.wav, 1.wav, 2.wav etc). So PlayCharacterSound(e,"onAggro") will do the same but pick one of the sound files from the "OnAggro" folder at random to play.

So you could set up a new folder called, say, "beast" with the same folder structure as for "male" above and place new sounds in the subfolders as you need. Then it would be SetCharacterSound(e,"beast") in lua followed by PlayCharacterSound(e,"onAlert") to play one of the sounds in the 'onAlert' folder that is below the 'beast' folder.

It probably makes more sense if you look at the folder structure
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 16th Jun 2015 00:18
I started using that recently for a couple characters. Though have no idea how to get more than 2 sound files to play for non-characters. For instance like an intercom talking back to the player or things like that.
i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce 420 GT
Bradaus
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 8th Aug 2014
Location:
Posted: 21st Jun 2015 11:52
Thanks for all the help. I have been playing around some more and trying to learn as much lua as possible. I have made some mods to the shop keeper script however I wanted the text to appear in paragraph form. At the moment the text just goes off the screen.

How do I prevent this and make the text appear in paragraph form?
More tutorials and freebies on my website
Win7 Ultimate 64bit, i7 , 32GB RAM Gskill, SSD, GTX 680, Logitech G19
Bradaus
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 8th Aug 2014
Location:
Posted: 21st Jun 2015 12:49
Ok just played around a little more and this seems to work:

TextCenterOnX(50,90,3,"First line of text here")
TextCenterOnX(50,93,3,"Second line of text here")

I have no idea what the numbers at the start mean (50,90,3, and the second line 50,93,3,).

I assume the start of this script: TextCenterOnX is telling it to center the text on screen. However what do the numbers mean?
More tutorials and freebies on my website
Win7 Ultimate 64bit, i7 , 32GB RAM Gskill, SSD, GTX 680, Logitech G19
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Jun 2015 18:06
the first number is the 'x' % of the screen (horizontal) so 0, is left border, 50 is center & 100 is far right.
the second number is y, its the same but 'y' % (vertical)
and the third is the size of the text

life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Bradaus
GameGuru TGC Backer
10
Years of Service
User Offline
Joined: 8th Aug 2014
Location:
Posted: 24th Jun 2015 08:09
thanks smallg. That makes sense and helps me a lot.
More tutorials and freebies on my website
Win7 Ultimate 64bit, i7 , 32GB RAM Gskill, SSD, GTX 680, Logitech G19

Login to post a reply

Server time is: 2024-12-22 01:39:45
Your offset time is: 2024-12-22 01:39:45