-
Notifications
You must be signed in to change notification settings - Fork 51
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
Duckscript for games #89
Comments
i never tried game dev before so got no experience there. I can try to look at the tutorial link you sent, but might take me a while. thanks a lot for the advice :) |
I am trying to embed duckscript in my game and the thing I find most difficult is passing external context to my custom commands. |
@smokku you are setting the value as a member on the command struct itself? did i understand correctly? i embed duckscript inside cargo-make which provides additional command with flow info. and this is how i use that data inside the command: its a bit complex as its a struct and not some primitive, but thats why i split it to util and command using the util. in general, duckscript is more of a shell like scripting env, so never thought about using it for games and i'm not sure |
Yes, I am doing exactly that: https://github.com/smokku/soldank/blob/ac20249/client/src/engine/script.rs#L54
My use-case is I want to have commands interacting with outside state (the game state) - change configuration, spawn game objects etc.. For example, GameShell solves this by having a user provided command execution context which is then passed to executed commands. This way commands can interact with outside object without taking ownership. |
ok got it. so you want the ability to pass &mut into the context. a really simple test case code would really help me to see that we can reach a good solution, if possible. |
I've extracted my code to a bare example: https://github.com/smokku/duckscript4games/tree/master As you can see i can use
Now, let's suppose that we are not at liberty to wrap
|
sorry was a bit busy. correct me if I'm wrong but you can have only one mut borrow, so I'm not sure how you plan to have 2 command structs having the same mut borrow value. why can't you give them rc with refcell which holds the value and clone that for eqch command? meaning, in what scenario this won't work? |
I don't want to wrap the value in RefCell as I would need to Inspired both by Thanks for your code and help. :-) |
cool stuff. good luck :) |
Duckscript seems like it could be very useful as a lightweight scripting language for game development. Quite a few games (Blizzard being a notable fan of this practice) have created their own scripting languages to be tailored perfectly to their game’s unique requirements. Duckscript’s extensibility accommodates this pursuit of niche functionality.
Are there any examples of Duckscript being used as a scripting language for a game?
(If wanted, I can point you to some examples of Rust games with scripting implementations like Lua, Python and JavaScript.)
As for what might make a good example, demonstrating Ducktype scripting in bracket-lib (formerly rltk_rs) would surely get added to the Rusty Roguelike Tutorial.
There’s a rough spec and POC available for ECS-friendly scripting, though Duckscript might have an easier way in with its embeddable qualities.
The text was updated successfully, but these errors were encountered: