Git Product home page Git Product logo

Comments (2)

Ghabry avatar Ghabry commented on August 23, 2024 1

I hacked now together some basic javascript for this and bound it to C++ via QuickJS. Highly experimental.

With the following "event code" which is valid Javascript

$msg("Javascript!!1");

$showpic("Punkt").id(1).x(0).y(180);

for (let i = 0; i <= 360; ++i) {
	$movepic().id(1).x(i / 360 * 320).y(Math.sin(to_rad(i)) * 120 + 120);
	$wait(0);
}

Generated event code:

Screenshot_20210202_214525-fs8

I generate the following event which shows a Sinus curve: (sorry for the flicker)

simplescreenrecorder-2021-02-02_21.29.58.mp4

from editor.

Ghabry avatar Ghabry commented on August 23, 2024

I also had this in my mind.

My idea would be using a Javascript engine that is used as a macro-language to emit event code. The Editor executes it to generate the event commands.

Semantic (reserved variable prefixes):

  • $ Event code (Appears as event command)
  • _ constant stuff (evaluated during compile time)

Example:

for (let i = 0; i < 3; ++i) {
  $V(i, '=', i*2);
}
$C("---");
for (let i = 1; i < 3; ++i) {
  $V(i, '+', $V[i]);
$C("+++");
let val = 100;
$V(5, '=', 100 + _db.monsters[2].attack); // OK. DB is Constant expression
$V(5, '=', $game.party.actor[1].level); // OK. Fetches party actor 1 level at runtime

This is evaluated while typing. Functions prefixed with $ appear in event code.
This would emit:

@CtrlVariable(V1 = 0)
@CtrlVariable(V1 = 2)
@CtrlVariable(V1 = 4)
@Comment(---)
@CtrlVariable(V1 + V1)
@CtrlVariable(V2 + V2)
@Comment(+++)
@CtrlVariable(V5 = 140) <- Evaluated at compile time, monster attack in DB was 40
@CtrlVariable(V1 = Actor 1 Level)

Errors:

$V(5, '=', 100 + $game.party.actor[1].level); // Error $game is not constant
let val = $V[3] // Error $V is not a constant

from editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.