GithubHelp home page GithubHelp logo

vurv78 / sfhaxe Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 246 KB

Transpile typed, null safe and powerful Haxe code for StarfallEx

Home Page: https://lib.haxe.org/p/sfhaxe

License: MIT License

Haxe 95.90% Lua 1.65% Batchfile 2.45%
haxe starfallex starfall garrysmod gmod autogeneration glua gmod-lua haxelib lua

sfhaxe's Introduction

SFHaxe Haxelib License: MIT Downloads github/Vurv78

Haxe library that adds StarfallEx bindings that are autogenerated in the generator branch.

Write Starfall scripts in the same typed, null safe and powerful language that many popular programs & games like Friday Night Funkin' are written in.

Example snippet

image

What is Haxe?

See what is haxe?, and a code sample here.
Long story short, it's a language that compiles to other languages while adding a lot of neat features to extend them.

Check out some of these features here.

Features:

  • Autogenerated bindings for every Library and Type in StarfallEx.
  • IDE Documentation so you don't have to get out of your editor to find out what a function does.
  • Some support for replacing Haxe standard library with sf friendly methods.

What would you use this for?

  • If you want typed, more powerful & easier to manage code.
  • If you don't want your source code to be stolen, this works as well since the source is transpiled into unrecognizable lua.
  • If you wanted to use all of Haxe's public libraries (see lib.haxe.org), which a good portion should be compatible with SFHaxe.

Installing

  • Get Haxe (Version must be > 4.2.0)
  • Install using Haxe's package manager haxelib: haxelib install sfhaxe
  • That's it!

Using SFHaxe

Look at examples/Basic Full for a full example.

Make a Haxe project, and in your build.hxml file add:

# Optional: Delete Unused Code
--dce full

# Link to sfhaxe.
--library sfhaxe

# Example Defines
--define SERVER # Can be SERVER, CLIENT or SHARED
--define NAME=A cool chip
--define SUPERUSER
--define AUTHOR=Vurv
--define MODEL=a/model/path.mdl

# Set the Haxe path to the current directory of the hxml + /src/
--class-path src

# Tell the compiler to generate lua code at this path local to %CD%
--lua bin/outscript.lua

# Set the main class to compile from. In this case, you have a file called Main.hx in /src/ that creates class Main.
--main Main

If you want Haxe bindings for GLua to make addons instead of Starfall scripts, check out gmodhaxe. (Not made by me so can't confirm how good it is)

sfhaxe's People

Contributors

vurv78 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

sfhaxe's Issues

Missing Docs

I will (and you could) put any missing docs that SF needs here to keep track of. Missing docs could make functions unusable since the autogenerator takes returns as either void or any.

Hook Bindings

Would be cool if we could make hooks like

@:hook("Tick")
function tick() {
	Sys.println("Hi");
}

or

@Event("Tick")
function tick() {
	trace("Hi");
}

Similar to how it works in S&Box right now

I'm not to the point in Haxe skill where I could easily get it to use the hook's arguments in these events but it'd be easy syntax sugar for hook.add(...)

Make the Generator cross-target

Make a cross-target version of it, so it could be compiled to C++ / Python / JS.
The current version is meant to be used as an SF script so this is unnecessary but it'd be cool

Class extensions

Weapon / NPC / Vehicle / Player etc should inherit from the entity class

Parameter Docs

We should include the docs for each param in the generated code

Autogenerate the bindings with Actions

Would probably be a large task, see if we can run an action whenever Starfall docs update to run the hashlink code of the generator when #3 is done. Would be very nice so I don't have to generate it constantly in game myself.

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.