Skip to content
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

0.20, stub, windows -> cannot open file: engine #44

Closed
travisstaloch opened this issue Jul 10, 2019 · 15 comments
Closed

0.20, stub, windows -> cannot open file: engine #44

travisstaloch opened this issue Jul 10, 2019 · 15 comments

Comments

@travisstaloch
Copy link

travisstaloch commented Jul 10, 2019

I installed godot 3.0 and followed the godot-nim Getting Started docs. I have an existing nim 0.20.0 and nimble. Trying to build the stub, there were errors. Using nimble install https://github.com/aguspiza/godot-nim#head and requires "https://github.com/aguspiza/godot-nim#head" in stub.nimble fixed many of the errors.

I forked that repo and got through the remaining error and even got rid of warnings which were mostly caused by changes to NimNode after 0.18. The remaining error involved removing the {.immediate.} pragma from the macro gdobj in godotmacros.nim(630). I also forked the stub with my change.

I'm now getting the error:

godot-nim-stub\src\fpscounter.nim(5, 8) Error: cannot open file: engine

Any ideas or suggestions? Do I just need to be on 0.18? I saw a comment above godotmacros.nim(630)

# immediate macros are deprecated, but `untyped` doesn't make it immediate,
# as the warning and the documentation claim.

Could this be causing the error I'm seeing? I don't need to have the godot_headers somewhere and pass/include to nim compiler do I? Hoping there is someway to use 0.20 as choosenim is broken on windows afaik.

@zetashift
Copy link
Contributor

You could try the version described here; #42 which is located at: https://github.com/bluenote10/godot-nim/tree/attempt_fixes_for_0.19

Or indeed use 0.18 with choosenim, which works on Windows 10(I can tell because I'm currently using choosenim on a 64bit laptop).

@rafallus
Copy link
Contributor

I made a new PR (#45) based on #42. You can use my fork and give it a try. Test is needed!!

@travisstaloch
Copy link
Author

travisstaloch commented Jul 10, 2019

@DwanaG if I use your branch with:

# stub.nimble
requires "https://github.com/DwanaG/godot-nim#attempt_fixes_for_0.19"

I get the same error as with my patch:

...\godot-nim-stub\src\fpscounter.nim(5, 8) Error: cannot open file: engine

@zetashift when I use:

# stub.nimble
requires "https://github.com/bluenote10/godot-nim#attempt_fixes_for_0.19"

I get:

...\githubcom_bluenote10godotnim_#attempt_fixes_for_0.19\godot\nim\godotnim.nim(347, 3) Error: type mismatch: got <string> but expected 'NimNode = ref NimNodeObj'

@rafallus
Copy link
Contributor

...\godot-nim-stub\src\fpscounter.nim(5, 8) Error: cannot open file: engine

It seems that Nim cannot find the _godotapi/engine.nim file. Does the _godotapi folder is generated when you compile the project?

@travisstaloch
Copy link
Author

Yes, I see the _godotapi folder (godot-nim-stub\_godotapi) with only one file in it, api.json.

@rafallus
Copy link
Contributor

Could you start from a clean project? Delete the _godotapi and .nimcache folders and also nakefile.exe and try again.

@travisstaloch
Copy link
Author

travisstaloch commented Jul 11, 2019

That worked, generating all of the .nim files in the _godotapi folder. Now there is an error:

...\\godot-nim-stub\\src\\fpscounter.nim(7, 7) template/generic instantiation of gdobj from here ...\\godot-nim-stub\\src\\fpscounter.nim(11, 15) Error: type mismatch: got <bool> but expected one of: proc setProcess(self: Node; enable: bool)

gdobj FPSCounter of Label:
  var lastFPS: float32

  method ready*() =
    setProcess(true) #<<< here

@rafallus
Copy link
Contributor

rafallus commented Jul 11, 2019

Previous versions of the bindings used the this:self pragma, which made things easier. Now, that is deprecated and methods must be called explicitly with self. Please check the comment on my PR #45 to see how it's working now. I can't find a way to make it work the way it used to.
In your example, you should use

self.setProcess(true)

@travisstaloch
Copy link
Author

I was able to get it to build by using self.setProcess(true) and also updating the mainpanel.nim file with similar:

# fpscounter.nim
gdobj FPSCounter of Label:
  var lastFPS: float32

  method ready*() =
    self.setProcess(true)

#mainpanel.nim
gdobj MainPanel of Panel:
  method ready*() =
    self.setProcessInput(true)

  method input*(event: InputEvent) =
    if event of InputEventMouseButton:
      let ev = event as InputEventMouseButton
      if ev.buttonIndex == BUTTON_LEFT:
        self.getTree().setInputAsHandled()
        let scene = load("res://scene.tscn") as PackedScene
        self.getTree().root.addChild(scene.instance())
        self.queueFree()

@travisstaloch
Copy link
Author

It works! Thank you so much for your help. Now, being a godot newb, I just need to understand how to actually make use this from godot...

@travisstaloch
Copy link
Author

Actually, nevermind... just launching godot from the godot-nim-stub folder brings the game right up...

@travisstaloch
Copy link
Author

Should I make a PR for godot-nim-stub with these changes?

@rafallus
Copy link
Contributor

Would be nice. But that's the way it should be done if using my branch. Otherwise the way it is now is cleaner. If you make a PR, probably will be merged only if my PR is merged.

@zetashift
Copy link
Contributor

@travisstaloch you can try using: https://github.com/zetashift/godotnim-samples this as a guideline, dodgethenim is a Nim version of the your first game godot version. Ofcourse you need to add self everywhere

@travisstaloch
Copy link
Author

Ok, I made a PR in case it ever gets merged. Thanks again for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants