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

Level declaration syntax #12

Open
phiresky opened this issue Oct 24, 2014 · 6 comments
Open

Level declaration syntax #12

phiresky opened this issue Oct 24, 2014 · 6 comments
Labels

Comments

@phiresky
Copy link
Collaborator

Currently the levels are declared in a kind of DSL. I'm not sure if there is a better way / different syntax.

Also this means that the RunScript/InitScript parts have a different syntax because they are C.

The syntax of script and static things should be joined. Maybe put the static things back into normal C, not parsed extra?

Or maybe the other way around, preparse the C to make it more readable and easily allow things like Block Type aliases.

@phiresky
Copy link
Collaborator Author

I guess the best way would be to remove the lambda function parsing and executing as an array and instead preparse the declaration from e.g.

Cell (4 4 60) Goal to ChangeCell(4,4,60,GOAL);
and then pass the whole thing as a single init function for each room into TCC. Thoughts, @cnlohr?

@cnlohr
Copy link
Owner

cnlohr commented Oct 24, 2014

I am always a fan of c function-ifying things, and I do prefer the ChangeCell(4,4,60,GOAL); syntax - but this is only a mild preference! You have a much deeper understanding of these language constructs than I do, and have no reason to question your judgment on these sorts of things!!!

This is all that comes to mind:

(1) We could do our own preprocessor on the TCC to add language features not in TCC. For this sort of thing, lambda functions would be extremely useful.

(2) The only reasons I was/am using TCC are: (a) Binding to the rest of the engine is trivial - it is very easy to export a vast array of useful functions. (b) Object orientation doesn't really matter when it comes to a very flat environment. It's just an array of blocks. (c) It does not increase compile time. (d) Simply saving the file can reload-in-place. --- So, don't completely abandon the idea of using a scriptier thing.

@phiresky
Copy link
Collaborator Author

I just realized that using a syntax like Cell (4 4 60) Goal would give problems when having a loop and doing Cell (4 4 60 + i) Goal. I like it without commas but like it is it would definitely not work for non-static things.

  1. I'm still not sure about how to do this. I'd like a more clean syntax than pure C for declaring levels, but I'd also like the level scripts to have the same syntax as the rest.
  2. Yes.. ChaiScript also had very simple binding, but it's probably not the best choice. Maybe some more common language like lua but that seems to be more work. I think we can just keep it tcc for now (except if there are problems with windows/etc)

Maybe a better approach would be to first write a ingame/external level editor, that would make these things less important. but I don't think I have the energy for that right now ;)

@cnlohr
Copy link
Owner

cnlohr commented Oct 24, 2014

I've compiled TCC manually for a number of platforms, I may be able to compile libtcc1.a into the project.

Actually, I'm going to have access to a Windows computer soon, so I can mess around on there.

Someone else on youtube asked about the level editor, and I don't think it would be that hard. I'll make an issue for that and think about doing it over the next few days.

@erinzm
Copy link

erinzm commented Jan 1, 2015

Lua is nice, that's pretty simple to interface.
Maybe a better approach to loading levels would be to have a levels/ folder with multiple level scripts?

@cnlohr
Copy link
Owner

cnlohr commented Jan 5, 2015

I have tried doing the LUA thing, but it never really panned out for me. If you want to take a stab at it again, I would be up for poking with that branch.

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

No branches or pull requests

3 participants