-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate .gdns files? #73
Comments
Sure why not? A gdns file is just text. Though you might have to shut down the editor to reload it. I'm pretty sure the editor only reloads the dll. What variables are you tweaking? |
So, if I have a
I end up changing |
So write a script to generate the gdns. That's what I did. |
Right, I'm going to do that, but I figure it would be nice if the |
Yeah I agree. :) Though I think the this would be more of a change to godot-nim-stub. You could modify the nakefile to add your own task to generate a nim, gdns, and tscn file. |
So, quick update, this is what I ended up adding to my proc genScripts() =
for srcFile in walkFiles("src/source/**/*.nim"):
let (_, fileName) = splitPath(srcFile)
let file = open(srcFile)
defer: file.close()
let classNames = collect(newSeq):
for line in file.lines:
if line =~ re"gdobj\s*(\S+)\s*": matches[0]
createDir("testScripts")
for className in classNames:
let scriptFile = open(fmt"scripts/{className}.gdns", mode = fmWrite)
defer: scriptFile.close()
scriptFile.writeLine("[gd_resource type=\"NativeScript\" load_steps=2 format=2]")
scriptFile.writeLine("")
scriptFile.writeLine("[ext_resource path=\"res://nimlib.gdnlib\" type=\"GDNativeLibrary\" id=1]")
scriptFile.writeLine("")
scriptFile.writeLine("[resource]")
scriptFile.writeLine("")
scriptFile.writeLine(&"resource_name = \"{className}\"")
scriptFile.writeLine("library = ExtResource( 1 )")
scriptFile.writeLine(&"class_name = \"{className}\"")
This requires that the |
You can also use this: https://nim-lang.github.io/Nim/strutils.html#%25%2Cstring%2CopenArray%5Bstring%5D instead of writing line by line. |
The reason I wrote it line by line was to avoid adding tabs/spaces at the beginning of the file, but I'll take a look at it. |
Spaces shouldn't be a problem. I do this in my code.
|
Hi, I just started playing around with the Godot Nim stub project, and I was wondering if there was a way to autogenerate the GDNative script files per compilation?
Right now I'm just copying the info from
FPSCounter.gdns
and tweaking the variables to fit the class file that I compile, but if I have to manually do this every time, it doesn't seem too scalable.Looking forward to hearing from you, and so far nice work!
The text was updated successfully, but these errors were encountered: