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

Janet Support #2069

Closed
wants to merge 4 commits into from
Closed

Janet Support #2069

wants to merge 4 commits into from

Conversation

iacore
Copy link
Contributor

@iacore iacore commented Jan 2, 2023

No description provided.

assert(tic != NULL);

JANET_FN_S_tic(btn)
janet_fixarity(argc, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear this param is optional, not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not in the doc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree it's unclear.

btn([id]) -> pressed

The [] means the argument is optional. If no specific button is passed I believe the entire state of the button register (bitfield) is returned. (you can read the source to confirm)

I'm speaking largely of Lua, it might be useful to check and see if this has been handled correctly across all runtimes.

Copy link
Collaborator

@joshgoebel joshgoebel Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, btn and btnp have the same-ish behavior for 0 arguments:

https://github.com/nesbox/TIC-80/blob/main/src/api/lua.c#L601

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs updated.

Copy link
Contributor Author

@iacore iacore Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btn() seem to always return true for me in the Lua version.

Co-authored-by: Josh Goebel <me@joshgoebel.com>
@AlecTroemel
Copy link
Contributor

@locriacyber cool to see this MR, I actually spent some time on this same thing a while ago (branch here for comparison https://github.com/AlecTroemel/TIC-80/tree/charlotte_janet_support). I'd love to help get this MR ready however possible! some questions

  • Do syntax errors contain line numbers & other info like relevant function names? I could never get that sorted
  • You have an opinion on the tic80 function names that collide with the janet standard library functions? Specifically print and map?

@iacore
Copy link
Contributor Author

iacore commented Jan 10, 2023

Thanks for telling me. Seems like your work is further ahead.

  • Janet prints error to stderr. It's hard coded in. Syntax error is considered compile-time error.
  • runtime error is raised as signal
  • I recommend making it a module, so the user can choose between (import tic80) or (use tic80)

@iacore iacore closed this Jan 10, 2023
@AlecTroemel AlecTroemel mentioned this pull request Jan 11, 2023
3 tasks
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

Successfully merging this pull request may close these issues.

3 participants