ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:    
Ambiera Forum > CopperCube > Programming and Scripting
dialogue - get lines of text from text file
Author Text

blackwater
Registered User
Quote
2017-08-10 22:42:20

I need to get help to understand how to load specific lines of dialouge from a text file. (and remember that I am a total javascript noob!).
Yes, I've managed to load text from a file and show the whole text.
BUT, I need to be able to choose specific lines.

I could be satisfied for now with something easy, like this nr 1 example below. Or a more sophisticated version, see nr 2, below.


1) EASY VERSION
Lets say the dialogue file looks something like this (but say it has 300 lines instead of 4, as below):

Player: Excuse me, do you know the way to Simsilam
Wizard: Oh yes, it's that way
Player: Are you sure?
Wizard: I'll show you

Lets assume I only need line 3 "Are you sure?" to show up in a 2D dialogue box. And then the following line 4 in another 2D box - how to do this in a simple but usable way?

I scanned the forum and found a really old entry from 2011. It seems to me that the text could be divided up with this example, but it gets me nowhere as I am not at programmer:
http://www.ambiera.com/forum.php...


2) MORE SOPHISTICATED
Ideally, I would like to have something where you can choose answers and depending on your choice, you get a specific answer, like this:

"Hi! Welcome to Coppercube! Is this your first visit?",
responses:
1 "Yes, I just arrived"
2 "No, I've been here before"

So, if you choose nr 2 you get:
"Ok, cool, what have you learned so far?!"
Or, if you select nr 1:
"Interesting! How did you get here?"

Etc.

This javascript found on Github does these thigs, which would be awesome to have, perhaps it could be made into a behaviour for Coppercube?

https://github.com/scottbw/dialo...

I was not able to install it via the windows command "DOS" window (it gives me errors)
But the documentation sure on Github looks promising.
If anybody feels like making this thing usable and more user friendly for CC, (or something similar) I would be much delighted!

Also, i found this, which is interesting, but still I am not a programmer, so this is really a jungle for me to resolve:
https://gamedev.stackexchange.co...


techno-valley
Registered User
Quote
2017-08-12 11:59:51

I propose to use reference numbers for the dialog conversation and you go directly through the line.

I would advise to split all dialog into smaller files as well

then you target reading the file as a text file by going to the line number and the correct filename.


blackwater
Registered User
Quote
2017-08-16 21:57:49

Yes, something like that - could somebody provide a few lines of code to show a working example in how to get a specific line of text from a external text file?


blackwater
Registered User
Quote
2017-08-28 12:58:38

This script - a modest one or a more advanced, is a bit crucial to me, so if somebody could make a few lines of code (or many) - I am willing to buy it. (Could be put up for sale on: http://www.marshtownmadness.com


just_in_case
Registered User
Quote
2017-08-29 08:05:13

Well let me try this, am pretty sure that i have a solution to this....


just_in_case
Registered User
Quote
2017-08-29 09:16:30

Done it

created an action which will display the line from a text file on a 2d overlay....

just specify the no of line you want to be displayed as a dialogue.
and it will appear on the overlay when the action is executed...

and for the sophisticated way you can use variables and my action together to achieve this...

for example your game says


"Hi! Welcome to Coppercube! Is this your first visit?",
responses:
1 "Yes, I just arrived"
2 "No, I've been here before"

if the player opt for 1st option then you can use the action to be executed an select the line from the file you wanted to display.

like

"Interesting! How did you get here?"

which can be line no 32 in your text file. just specify the no 32 in the action and it will be displayed on the overlay.

so that way you can do the dialogue conversation.
i will upload the file to MTM soon ..

but if you need the script urgent...
you can also contact me here angelonghost@gmail.com


Zoo
Guest
Quote
2017-08-29 09:39:46

Cool!


just_in_case
Registered User
Quote
2017-08-29 10:47:09

Here is the sample Exe file to download to see the functioning of the script..

Try editing the text in dialogue.txt file included in the archive to whatever you like and it will appear on the sample exe .. on the basis of line..

and you can click on the one of the responses to get the predefined answer..

link:-https://drive.google.com/file/d/...


blackwater
Registered User
Quote
2017-08-29 21:28:19

And like magic, you did it! Wonderful to see! I am excited to try it for real later on!!
But no hurry. Make it fully functional and let us know when it's available and why not sell it if you put a lot of work into it - I'll gladly pay and in the meantime give you a big virtual hug!


just_in_case
Registered User
Quote
2017-08-30 06:15:50

There was a bug there... And i removed it... Now adding new lines to the.txt file won't affect the game results..


Zoo
Guest
Quote
2017-08-30 06:55:28

yea sell it on MTM


pmax
Registered User
Quote
2017-08-30 10:47:08

I tried to create a simple plugin to create dialogs in the game.
I attach the scene file and the JS plugin.
It is not based on external files.




It's easy to use.
First of all, a global variable named 'globalvaranswer' is to be created,
Then the commands I think are intuitive.

Question = enter the question to be displayed.
Answer 1-2-3 = are the three answers to be displayed.
Showquestion = assign the object '2D Overlay1' to make the text appear.
Showanswer 1-2-3 = as above assign the object '2D Overlay1' to make the text appear.
Varglobal = assign the '2D overlay1' object that tests the global variable.
Corectanswer = enter the value 1 or 2 or 3 according to the given answer, the right answer.
Newaction = if the answer is correct starts the new action.

Download
https://www.dropbox.com/s/9r089g...

PS: translation through Google.


Zoo
Guest
Quote
2017-08-30 16:11:05

Hi, I uploaded it to MTM


just_in_case
Registered User
Quote
2017-09-01 10:30:22

Uploaded the Action to read a specific line from an external file to MTM now you can buy the action from there.

link to MTM product page :- https://marshtownmadness.com/act...


Zoo
Guest
Quote
2017-09-01 12:48:43

Hello, the transaction has been approved... please message me personally if something went wrong


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2015 Nikolaus Gebhardt, Ambiera e.U.