-
Notifications
You must be signed in to change notification settings - Fork 0
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
Provide OOP declarations #1
Comments
Hey! Congrats on getting the first issue, and thanks for reporting this one! Totally yes! On all your points. Tried your Haxe stuff after messing with this, and didn't liked the output. I got all weird prototypes in my lua file. I started messing with typescript for the MTA:SA Lua Syntax Highlighter and... I LOVED it. The plan here is first of all get the functions sorted.. Tbh it's a fucking mess haha. Like that. Still having some trouble figuring TS out though. For example I'm not able to put the typings in a sub-directory which makes things hard atm. But yea after that's done I want to do the OOP stuff too. But the TypeScriptToLua transpiler is a bit messy (See issue I opened over there, thats also the reason why my fork exists!) |
I'll have to look into further modifying the transpiler. Since the transpiler will make this lua script: MTA.addEvent(MTA,"onClientPlayerKillMessage",true)
function onClientPlayerKillMessage(killer,weapon,wr,wg,wb,kr,kg,kb,width,resource)
if MTA.wasEventCancelled(MTA) then
return
end
outputKillMessage(source,wr,wg,wb,killer,kr,kg,kb,weapon,width,resource)
end
MTA.addEventHandler(MTA,"onClientPlayerKillMessage",MTA.getRootElement(MTA),onClientPlayerKillMessage) from this typescript: MTA.addEvent("onClientPlayerKillMessage", true)
function onClientPlayerKillMessage(killer: MTA.Player, weapon, wr, wg, wb, kr, kg, kb, width, resource) {
if (MTA.wasEventCancelled()) return;
outputKillMessage(MTA.source, wr, wg, wb, killer, kr, kg, kb, weapon, width, resource)
}
MTA.addEventHandler("onClientPlayerKillMessage", MTA.getRootElement(), onClientPlayerKillMessage); |
Okay. This is now fixed with https://github.com/Subtixx/TypescriptToLua/commit/6ec1241e041eb207a7a50e16845d14faca56831c it will now produce the expected output of: addEvent("onClientPlayerKillMessage",true)
function onClientPlayerKillMessage(killer,weapon,wr,wg,wb,kr,kg,kb,width,resource)
if wasEventCancelled() then
return
end
outputKillMessage(MTA.source,wr,wg,wb,killer,kr,kg,kb,weapon,width,resource)
end
addEventHandler("onClientPlayerKillMessage",getRootElement(),onClientPlayerKillMessage) EDIT: addEvent("onClientPlayerKillMessage",true)
function onClientPlayerKillMessage(killer,weapon,wr,wg,wb,kr,kg,kb,width,resource)
if wasEventCancelled() then
return
end
outputKillMessage(source,wr,wg,wb,killer,kr,kg,kb,weapon,width,resource)
end
addEventHandler("onClientPlayerKillMessage",getRootElement(),onClientPlayerKillMessage) |
Still work in progress but I'd do it like this: Is this what you suggested? |
Yes, exactly. |
First of all, I'm pretty excited about this project. If it works as expected and the underlying TypeScriptToLua library gets mature enough, it may even be superior to the Haxe stuff.
One suggestion though: Since TypeScript tends to be more of an object-oriented language with ES6 classes, I'd suggest you additionally provide an object-orientied API and favour it over the procedural one (e.g. by moving it to a separate namespace).
The text was updated successfully, but these errors were encountered: