Git Product home page Git Product logo

rakugoteam / rakugo-dialogue-system Goto Github PK

View Code? Open in Web Editor NEW
215.0 5.0 7.0 2.99 MB

Inspired by Ren'Py, Rakugo is a project aiming to provide a way to make narrative-based games on Godot easily. Simplify your project, if it is a visual novel, point and click, RPG, interactive text game or many other styles and blends of styles.

Home Page: https://rakugoteam.github.io

License: MIT License

GDScript 100.00%
godot godot-engine gdscript renpy visual-novel rpg point-and-click addon dialogue-systems

rakugo-dialogue-system's People

Contributors

jeremi360 avatar matteopiovanelli-laser avatar theludovyc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rakugo-dialogue-system's Issues

New say()

Old
say(character:Variant, text:Str, parameters:Dic)

New
say(character:Variant, text:Str)

Rework Rakugo/Parser, parse_scripts(folder_path:String)

Currently if you want to parse script, you use : func parse_script(file_name:String)
It's parse a .rk file and execute it.

In Parser class, parse and execute are already split but user "can't" access it.

I propose to add or update funcs.

parse_script(file_path:String) <= parse a file and store result in dictionary (like a cache). Key it's fileName without extension.

parse_scripts(folder_path:String) <= parse all rk files in folder at path and store them.

execute_script(file_name:String) <= execute script already stored.

This also sets the stage for jumping between scripts.

Temporary characters

In Ren'Py you can define a temp character at say statement like this:

"Temporay Men" "I'm superhero Temporay Men and my power is that I end to exist when this sentence ends!"

Do not find Say in history.gd:86

It's beacause I removed Say node in Rakugo.tscn

But function exist in Rakugo

So like that
Rakugo.get_narrator()

Instead of
Rakugo.Say.get_narrator()

Fix jump()

I found that jump() not works as it should,
but it was some time ago, I need to check it again.
And fix this error.

New menu()

Old
menu(choices:Array, parameters:Dictionary)
choices["choice label", variable_to_return:Variant, parameters:Dictionary]

New
menu(choices:PoolStringArray)
choices["text", "text1", "text2", ...]

Use
var ret_menu = menu(...)
match ret_menu

Variables in RakuScript

We need variables in RakuScript, those will be:

  • global
  • saved to save file
  • used in ifs
  • used in loops

For now, its declaration will look like this:

var_name = value

Maybe we need to add var keyword to it to make it simpler, as this is the same as overriding an already existing variable.

To get/set to this variable from GDScript you just do:

var rakugo_test_var = Rakugo.get("test_var")

rakugo_test_var.set(100)

Execute a script from a label

# Instead of having this, that parse and excecute script:
Rakugo.parse_script(file_name)

# We could split this to 2 funcs:
var parsed_script = Rakugo.parse_script(file_name)
Rakugo.excute_script(parsed_script, "label_to_start_from")
# if label_to_start_from == "" then it excute script normally

Rework Character.gd

Don't extends Resource we never use it like that.

Remove visual things like :

  • color
  • show_parameters
  • show
  • hide

Remove useless things like :

  • say_parameters
  • variables
  • _get
  • _set
  • duplicate (it's StoreManager to do it)
  • apply_default

Rework :

  • get_composite_name (don't return bbcode)

Add :

  • Real constructor with _init(...)

Things to now :

  • In VnKit we can extends this class to extends possibilities of Character

Remove Settings.gd

Rakugo Core don't need to :

  • Set audio buses
  • Set window's settings

If need it use ProjectSettings

Super Say (Handle variables and characters)

Currently say just handle basic string. We can think about make better.

Handle variable and characters can do it like that

"I think [character_name] have <age> years old```

What do you think ?

New notify()

Old
notify(text:String, parameters:Dictionary)

New
notify(text:String)

Move visual part of SettingList to NVKit

Move visual part of SettingList to NVKit.
I think we can move those to script called NVSetting:

const auto_mode_delay := "addons/rakugo/auto_mode_delay"
const typing_effect_delay := "addons/rakugo/typing_effect_delay"
const skip_delay := "addons/rakugo/skip_delay"

const game_title := "application/config/name"
const main_scene := "application/run/main_scene"
const width := "display/window/size/width"
const height := "display/window/size/height"
const fullscreen := "display/window/size/fullscreen"
const maximized := "display/window/size/maximized"

Do not use Parse class directly. Do it by Rakugo singleton

Current

func _ready():
  parser = Parser.new()
	
  parser.parse_script(file_name)

func _exit_tree():
  var thread = parser.thread
	
  if thread:
    parser.stop_thread = true
		
    parser.step_semaphore.post()
		
    thread.wait_to_finish()

Futur

func _ready():
  Rakugo.parse_script(file_name)

Fix showable - they has to much controll over nodes

When ShowableManager is used by showable nodes,
it locks their visibility and alternative methods of showing nodes doesn't work with it.
It shouldn't work that way, it made it harder to mix Rakugo with other code

Support for `in` keyword in RakuScript

I think we should add support for in keyword or its alternative,
but for only easier writing if, I think that rakuscript don't need loops.

# gdscript
if true in [x, y, z]:
# is same as gdscript
if x or y or z:
# rakuscript
orif x, y, z:

# gdscript
if not (false in [x == 1, y == 2]):
# is same as gdscript
if x == 1 and y == 2:
# rakuscript
andif x == 1, y == 2:

Using Nim for GDNative stuff.

I propose to use Nim instead of C++ for GDNative parts for Rakugo, as it is more similar to Python.
There are nim-godot, but looks to be abandon.
But there is another way to use C++ inside nim, example from main page:

{.passL: "-lsfml-graphics -lsfml-system -lsfml-window".}

type
  VideoMode* {.importcpp: "sf::VideoMode".} = object
  RenderWindowObj {.importcpp: "sf::RenderWindow".} = object
  RenderWindow* = ptr RenderWindowObj
  Color* {.importcpp: "sf::Color".} = object
  Event* {.importcpp: "sf::Event".} = object

{.push cdecl, header: "<SFML/Graphics.hpp>".}
{.push importcpp.}

proc videoMode*(modeWidth, modeHeight: cuint,
                modeBitsPerPixel: cuint = 32): VideoMode
proc newRenderWindow*(mode: VideoMode, title: cstring): RenderWindow
proc pollEvent*(window: RenderWindow, event: var Event): bool
proc newColor*(red, green, blue, alpha: uint8): Color
proc clear*(window: RenderWindow, color: Color)
proc display*(window: RenderWindow)

More is here in docs:
https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma

Houston, we have a big problem !

For now project use thread

Dialogue.gd

func _ready():
	if has_method(default_starting_event):
		Rakugo.set_current_dialogue(self)
		thread = Thread.new()
		step_semaphore = Semaphore.new()
		thread.start(self, default_starting_event) <= create new thread

default_starting_event is a function name, like this one

func hello_world():
	say(null, "Hello, World !")
	
	step()
	
	say(null, "What is your name ?")

	player_name = ask("Paul")

We can see step()

func step():
	if thread and thread.is_active():
		Rakugo.step()

		step_semaphore.wait()

If we refer to doc https://docs.godotengine.org/en/stable/tutorials/performance/threads/using_multiple_threads.html#semaphores , step_semaphore.wait() need to be used in thread. I don't know if it executed in thread but "it's work".

In Godot we can't kill a thread. So to quit properly, all thread need to be finished.

We can see _exit_tree()

func _exit_tree():
	if thread:
		step_semaphore.post()
	
		thread.wait_to_finish()

But thread need to be finished, so hello_world() must be executed in whole.
So we run game, step() it's called, we want to quit, _exit_tree() is called, step_semaphore is released and go on. say(), ask(). And there we have a problem.

We can see ask()

func ask(default_answer:String):
	if thread and thread.is_alive():
		Rakugo.ask(default_answer)

		ask_yield()

		step_semaphore.wait() <= there

		return ask_return

	return null

In ask(), step_semaphore.wait() is executed. After we want to close. And in _exit_tree() we waiting with thread.wait_to_finish(). So it's never ended...

Law is "In Godot we can't kill a thread. So to quit properly, all thread need to be finished". So we can think first, add a flag in all function say(), ask(), notify(), menu(), etc... to check if a thread want to ended and do nothing. But we can add what we want in hello_world() because it's gdscript, save, pop things, make beautiful effect, etc... And them be executed !

New Save System

Remove or Update StoreManager and use dictionaries and json

Clean up Rakugo Core form code and assets that will be now in other plugins

โš ๏ธ It will broke Rakugo NV Kit that this repo will become โš ๏ธ ,
so it must be done on new repo where there is only clean Godot project with Rakugo.

So I partially separated Rakugo to different plugins such as:

  • Emojis-For-Godot
  • AdvancedText
  • Adventrue

And I didn't fully clean up the code that I transferred into these plugins from the Rakugo core.
I think there only left stuff related to AdvancedText :

  • RakugoTextLabel node and icon
  • TextParser node and icon
  • CodeEdit node and icon
  • keywords dir
  • and also all references in code to them must be removed.

Fix pause on quit

When go player want to quit, by using ESC key or close window,
then quit screen show up as it should, but for some reason game is not paused and this breaks detecting input on Yes button

RakuScript should have special key word `jumped_to` and/or `>?`

Here is how 3. would work:

# player can jump to dialogue x form dialogue z, but they didn't
if z jumped_to x: # turns false

# player can jump to dialogue x form dialogue z, and they did
if z >? x: # truns true

# player can't jump to dialogue a form dialogue d
if d jumped_to a: # turns false or even an error ?

Made ```cond()``` works also with ```match```

Is your feature request related to a problem? Please describe.
Now, cond() works only with if.
For some more complicated cases for e.g. menu()
use match will easier to use.

Describe the solution you'd like
It is probably enough for cond() to return the result of the argument passed to it, without changing it to bool.

Describe alternatives you've considered
Made new similar to cond() method just for use with match.

```cond()``` don't work whit roll back/forward

Describe the bug
When try to roll in dialogue with cond()
It works, but cond() result in always false in this case

To Reproduce
Steps to reproduce the behaviour:

  • Run some Dialogue that has more than 3 steps
  • and at least one of them uses cond()
  • Go to 3rd or more steps
  • Try few times:
  • a. Try to rollback
  • b. Try rollforward
  • See how it behaves

Expected behavior
It should roll keeping previous result of passed condition to cond().

Runtime (please complete the following information):

  • Godot version 3.4
  • Rakugo Version 3.2 RC 1

Additional context
Probably cond() result is not saved/restored when roll

Loops in RakuScript

This continuation of discussion about loops that we started in #53 :
#53 (comment)

I think we should support 2 types of loops:

# interation on collection
for item in items:
  item.do_something()
  
# iteration on int, inspired by nim-lang:
4 times:
  say "This will be said up 4 times."

Character variables / Custom Character Resource

This continuation of this: #61 (comment)

About this removing variables, those variables were used for stuff like emi.relationship,
but now when we have RakuScript it can be just RakuScript variable.
I remember that (but I can't fund issue about it) that we talk to allow to
define subvariables for characters in it just by writing character_id.variable_name = value

So I have 2 ideas about this we can do both and mix them or just one:

  1. like proposed above characters can have subvariables defined in RakuScript,
    (I think) it will be easy to add we just need to allow for . sine in variable name
    and then when parse we check if character with this id exist if not error.
    This also can be defined in blocks:
# line approuch
character ami "Ami Jones"
ami.relationship = 0

# block approuch
character emi "Emi Jones":
  relationship = 0
  sisters = [ami]

ami.sisters = [emi]
  1. Second idea that I have is to allow Custom Character Resource.
    This will work that user creates Resource type that extends our Character Resource.
    Then user choose this new script resource as ProjectSettings > Rakugo/Custom Character Resource.
    After this change, Rakugo parser when character is defined it will use _init() for script selected as Custom Character Resource.
    And it if it will have some variables, then we can overwrite them from RakuScript.

New ask()

Old
ask(default_answer:String, parameters:Dictionary)

New
ask(default_answer:String)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.