nodesnim icon indicating copy to clipboard operation
nodesnim copied to clipboard

Add scripting support

Open Ethosa opened this issue 4 years ago • 6 comments

Maybe it will be a good feature to use Python as a scripting language for scenes. 🤔

Ethosa avatar Oct 11 '21 16:10 Ethosa

What? Why not Nim? Are you yanking our (project lurkers) chain? Some other projects have used the VM for live scene and creative programming if that's your intention.

If you're looking at broader project adoption, then maybe just export the interface through something like https://github.com/treeform/genny?

quantimnot avatar Oct 11 '21 22:10 quantimnot

@quantimnot, I came across it: nimscript

And it: image

Maybe this would be a good option?

Ethosa avatar Oct 13 '21 13:10 Ethosa

nimscript is a module that just uses the Nim VM and implements stuff for actual file scripting and building convenience. I'm referring to using the VM directly in the same manner as this cool project by @dsrw: https://github.com/dsrw/enu/blob/main/src/engine/engine.nim. Here is a presentation he gave for NimConf 2021: https://youtu.be/ECJsq7BeZ8w

quantimnot avatar Oct 13 '21 16:10 quantimnot

@quantimnot, I tried to do something similar, it seems to work...

https://github.com/Ethosa/nodesnim/commit/4bd60100a290d624e60c9a1824b17b11a573ff25#diff-fa731b6fc0fcf751f578c8847de7d08d29c674bc1dcf9bb70e2dbe173c61daee

  • scripts.nim sublime_text_araDrMBj2x
  • test.nim sublime_text_DyBoWcFMP3
  • output sublime_text_2IcHqlVdKv

Ethosa avatar Oct 14 '21 15:10 Ethosa

Excellent!

There is another game library that I watch called paranim by @oakes. He created an opengl-rendered embedded Vim module that he uses for an editor: https://github.com/paranim/paravim Maybe you could use that.

You may want to checkout his clever rule engine too: https://github.com/paranim/pararules

quantimnot avatar Oct 14 '21 18:10 quantimnot

The problem with the interaction of Nodesnim objects in scripts: Error: undeclared identifier: 'Vector2Obj'

  • script.nim
    proc sum*(vec2: Vector2Obj): float =
      return 12
    
  • main.nim
    var compiled = compileScript("script.nim")
    
  • configRef:
    let std = AbsoluteDir(getHomeDir() / ".nimble" / "lib")
    # Search .nimble/lib folder 👀
    cfg.libpath = std
    cfg.searchPaths.add(cfg.libpath)
    cfg.searchPaths.add(AbsoluteDir($std / "pure"))
    cfg.searchPaths.add(AbsoluteDir($std / "pure" / "collections"))
    cfg.searchPaths.add(AbsoluteDir($std / "core"))
    cfg.searchPaths.add(AbsoluteDir($std / "impure"))
    cfg.searchPaths.add(AbsoluteDir($std / "std"))
    cfg.implicitIncludes.add(getCurrentDir() / "scripts_api.nim")
    

Ethosa avatar Oct 15 '21 10:10 Ethosa