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

Choosing a scripting language #19379

Open
hrydgard opened this issue Jul 31, 2024 · 8 comments
Open

Choosing a scripting language #19379

hrydgard opened this issue Jul 31, 2024 · 8 comments
Milestone

Comments

@hrydgard
Copy link
Owner

hrydgard commented Jul 31, 2024

I think we've reached the point now when we really need to add a proper scripting language.

The following uses are obvious, but there may be more:

  • Cleanly patching game bugs without using cheats or the function replacement mechanism. Needed for Grand Theft Auto: Vice City Stories "White Lies" mission bug #13200 and more.
  • A more usable cheat system than CwCheat
  • Easier alternatives to prx plugins for game modding and adding right-stick input etc
  • Scriptable control over rendering (to replace bad-looking bloom effects, and similar)

It's just pretty hard to choose. We've discussed this previously in #15626 , but didn't reach any conclusion. So let's list the option:

  • Lua. This is a weird little language with 1-based indexing, but it's flexible, tiny and easy to integrate. There are multiple implementations like luajit and Roblox's variant that has some potentially useful extensions. These are popular and well maintained, and Lua is well known in the game modding community.
  • Javascript. We want to stay lean and mean, so pulling in V8 is not an option. However, there are some embeddable javascript implementations:
    • quickjs - this is not Windows-compatible unfortunately so need to use a fork or do some porting effort. Sporadically maintained, which is slightly worrying but on the other hand, I don't expect to need to upgrade the js engine often once it's in.
    • duktape - Similar to quickjs, more windows-compatible, even more sporadically maintained, it seems

Other alternatives:

  • angelscript . not sure how easy to integrate, but the use of straight C types and the C++-like syntax might be good things.

Any other ideas?

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jul 31, 2024

Honestly the reason why everyone know lua in the modding community is because it was popularized by games like for example WOW and many others then became adapted to cheat engine where it's used for everything from custom searches that standard CE UI might not include up to paid trainer stuff.

IMO there are two most important factors:

  • dependency on third party stuff being as close to 0 as possible for end users, for example we need python to build PPSSPP, but having a scripting system depending on end user having to install it would be bad,
  • PPSSPP specific functions, it doesn't matter much what scripting language we get, important is what PPSSPP specific stuff we will be able to do with it, which preferably should be open for updates to increase it's power like cwcheat which got rumble and shader specific cheats that most people don't know are a thing.

Within those two any scripting language will be fine, they aren't that hard nor different from each other, just need a wiki page with ppsspp specific syntax and like a one simple example like "Hello world!", everything else will be easy to find over the net.

Writing a right analog support for example isn't just remapping keys like some plugins do, but having to find where game translates input to effect in-game like camera movement and then make it react to analog stick. A lot of that work would be the same with scripting system as it's with cwcheat/asm script injection, however much simpler if we didn't had to read value of analog from PSP input and write asm function to translate it to usable values to do what we want, but directly read analog value, write all the math in high level and just inject what we want where we want.
Also being able to write a some simple GUI to make tweaks available also for end users without telling them to hex edit stuff and maybe some easy hotkeys, maybe even some texture support for GUI to for example allow for pretty HP bars in games which never had HP displayed etc..

@iota97
Copy link
Contributor

iota97 commented Aug 1, 2024

While I don't really like Lua as a language I would prefer it over a not well maintained JS. The last thing I want are bugs in the interpreter tbh.

That being said if the JS library is solid enough I kinda like the idea of having some metaprogramming stuff like decorators and so on. That could be useful to make some complicated and repetitive stuff hidden to the user, or just to specify when a function should be called. Not sure if this is possible with Lua tbh.

Python I have a bad feeling about Android/iOS support. But beside that I share the same feeling about JS.

@Nabile-Rahmani
Copy link
Contributor

Nabile-Rahmani commented Aug 2, 2024

Lua is pretty nice, but here's a shot in the dark, which somewhat sidesteps the question: would WebAssembly be viable ?

If it's easy and light enough to embed and has the ability for any supported language to produce a binary to execute, this could be nice.

I've heard good things about it, but never embedded it.

@NABN00B
Copy link
Contributor

NABN00B commented Aug 6, 2024

Does it need to be a full-feature general purpose language? I would favor something simple that people with little-to-no real development experience can easily pick up and learn on the fly.

@Nemoumbra
Copy link
Contributor

There are 2 things I can say...

  1. All hail to Python
  2. Scriptable Debugger using an embedded Python 3 interpreter #13804

@hrydgard
Copy link
Owner Author

hrydgard commented Aug 7, 2024

Python is very heavy and slow, and I'm not confident it'll build on all our supported platforms, I wouldn't want to break Switch for example even though it's not very actively updated.

I'm currently leaning towards lua / luau due to it being well maintained and very easy to embed, and guaranteed to compile anywhere due to its simplicity.

I want to enable live-editing and add a development console that you can use to poke around in memory with, so something like WebAssembly would require an additional compiler from a textual language, making it less interesting.

@Nemoumbra
Copy link
Contributor

I want to enable live-editing and add a development console that you can use to poke around in memory with

What does live-editing mean?

Next... I remember you saying this: #17661 (comment)
Is that the same console you mean here?

@hrydgard
Copy link
Owner Author

hrydgard commented Aug 8, 2024

Live-editing means editing various scripts that can affect games without restarting the game or PPSSPP.

And yeah, it would be a convenient way to implement such a console.

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

6 participants