Scripting and others questions

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Molina
Posts: 7
Joined: Mon Jan 15, 2018 4:25 pm

Scripting and others questions

Post by Molina »

Hi Tony, happy new year !

First of all, I want to thank you for this asset. I don't know how do you find the time to answer all questions in this forum !

I didn't purchase Dialogue System, cause.. lack of money in this end of month, but I will.

I read the tutorial, and I would be dumb, but I don't manage to script in LUA with a dialogue.

I put in a script called "Player" a public void method called "GagnerEXPTRUC() { truc = truc +1}

In Start method i put Lua.RegisterFunction("GagnerEXPTRUC", null, typeof(DialogueLua).GetMethod("GagnerEXPTRUC"));

In my scene test, I made a dialogue Database, made a tree conversation, and put in the player's answer a LUA code " GagnerEXPTRUC();". And nothing happen, my variable "truc" didn't get +1. I didn't called my fonction.
I think I didn't understand your tutorial...

My second question : I want to call GagnerEXPTRuc() only one time. If I repeat this dialogue and I chose the same answer, my variable would increase each time I chose this answer. Do you know how can I destroy this fonction for this specific conversation answer after utilization ? I want to allowed the player to read the same dialogue, but I don't want him to earn more "Truc". It's a frequent glitch in RPG !
I use unity 2017.2

An another question : I want to use a inventory asset. Do you advise S-Inventory or Inventory-Pro ?

Thank you for all, and forgive me for this questions.

Molina

NB : "Truc" mean "Something in French ! :D
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scripting and others questions

Post by Tony Li »

Hi, and Happy New Year!

A template script is in Assets / Dialogue System / Scripts / Templates:

Image

I recommend to make a copy of this template. For example, I copied the template and made this script:

Player.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class Player : MonoBehaviour
{
    public int truc = 0;

    void OnEnable() // Add the function to Lua:
    {
        Lua.RegisterFunction("GagnerEXPTRUC", this, SymbolExtensions.GetMethodInfo(() => GagnerEXPTRUC()));
    }

    void OnDisable() // Remove the function from Lua:
    {        
        Lua.UnregisterFunction("GagnerEXPTRUC");
    }

    public void GagnerEXPTRUC()
    {
        truc = truc + 1;
    }
}
Molina wrote: Mon Jan 15, 2018 4:46 pm My second question : I want to call GagnerEXPTRuc() only one time. If I repeat this dialogue and I chose the same answer, my variable would increase each time I chose this answer. Do you know how can I destroy this fonction for this specific conversation answer after utilization ? I want to allowed the player to read the same dialogue, but I don't want him to earn more "Truc". It's a frequent glitch in RPG !
In the Dialogue Editor, define a variable:

Image

Then create two paths in your conversation:

Image

Use one path (the left path) if the variable is false. In this path, set the variable true, and use your function.

Use the other path (the right path) if the variable is already true. In this path, do nothing.

Molina wrote: Mon Jan 15, 2018 4:46 pmAn another question : I want to use a inventory asset. Do you advise S-Inventory or Inventory-Pro ?
There is also Inventory Engine. It's very nice, but it doesn't have crafting or vendors. It's only inventory.

The Dialogue System supports all three inventory assets. I can't provide a recommendation, but I can say that Inventory Pro is very popular, and some Dialogue System users find S-Inventory to be easier to set up.
Molina
Posts: 7
Joined: Mon Jan 15, 2018 4:25 pm

Re: Scripting and others questions

Post by Molina »

Wow Thank you Tony. It works.

Now, I see how your asset is powerful, it's just amazing. I could build 70% of my game only with your asset and few script.

If you can't mind, I have one last question. I wonder why I have to build a new database in the begining of my project and why it's not automatic. If I understand the purpose, I could build a second dialogue database when I'm overwhelmed by conversation, OR if I want to cut my project in different chapter, OR if I want to create different sort of dialogue (such as : journal log, books and so on). It's right ?

Have a good day !

Molina
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scripting and others questions

Post by Tony Li »

Molina wrote: Tue Jan 16, 2018 6:39 amNow, I see how your asset is powerful, it's just amazing. I could build 70% of my game only with your asset and few script.
Thanks!
Molina wrote: Tue Jan 16, 2018 6:39 amIf you can't mind, I have one last question. I wonder why I have to build a new database in the begining of my project and why it's not automatic. If I understand the purpose, I could build a second dialogue database when I'm overwhelmed by conversation, OR if I want to cut my project in different chapter, OR if I want to create different sort of dialogue (such as : journal log, books and so on). It's right ?
Yes, exactly.

Most people use only one database. It's much simpler. They organize their conversations using "/", such as:
  • Village/Villager
  • Village/Mayor
  • Village/Wizard
  • Forest/Woodcutter
  • Cave/Orc Chief
  • Cave/Magic Fountain
  • etc.
If you want to use multiple databases, read: How To Use Multiple Databases.
Post Reply