cipherxof / w3ts Goto Github PK
View Code? Open in Web Editor NEWTypeScript API for Warcraft III custom maps.
License: MIT License
TypeScript API for Warcraft III custom maps.
License: MIT License
Hi @cipherxof,
Do you know if there is already some kind of source mapping done with TypeScript2Lua? I'd be keen to set up an environment where runtime errors in the Lua environment are parsed through a source map that relays back to the user which TypeScript module it came from. I think this would also significantly enhance the quality of Lua debugging anyway, since currently only being able to get line numbers during runtime is not helpful, hence the complexities of things like Eikonium's DebugUtils.
I recently updated from 2.1.3 and noticed that when calling Unit.getItemInSlot()
on an empty inventory slot, the call crashes. I expect this to have something to do with the change that made this function return an instance of Item
instead of a handle.
Is this behavior intended?
The only way to circumvent this now is a try/catch block.
Line 217 in 152aae7
This should be Unit.fromEnum()
I just started messing with this and I get the following:
PS C:\Users\Rasmus\Desktop\wc3-ts-template-master> npm install
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
> [email protected] postinstall C:\Users\Rasmus\Desktop\wc3-ts-template-master
> tsc --outDir null -p node_modules/mdx-m3-viewer/tsconfig.json
node_modules/mdx-m3-viewer/src/viewer/handlers/mdx/eventobjectsnd.ts:18:9 - error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
18 if (viewer.enableAudio && scene.audioEnabled) {
~~~~~~~~~~~~~~~~~~
Found 1 error.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] postinstall: `tsc --outDir null -p node_modules/mdx-m3-viewer/tsconfig.json`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Rasmus\AppData\Roaming\npm-cache\_logs\2021-02-24T15_14_18_030Z-debug.log
I followed the guide here:
https://cipherxof.github.io/w3ts/docs/getting-started
and used the Download option. I am using the latest LTS Nodejs.
It is not clear to me how I am supposed to use the addCondition
properly.
There are two types available as the parameter:
Since I don't know what a boolexpr
is or how to create one (there is no constructor or initializer I could find), I gave the callback a try which, as the title implies, does not work.
My code looks like this and the action w/o any condition fires properly but as soon as a callback is provided it does not (regardless of the return value.
ts
// main trigger for killing missiles
const destroyMissileTrigger = new Trigger()
destroyMissileTrigger.registerAnyUnitEvent(EVENT_PLAYER_UNIT_ATTACKED)
destroyMissileTrigger.addCondition(() => true)
destroyMissileTrigger.addAction(() => {
const attacker = Unit.fromHandle(GetAttacker())
Log.Debug(`Attacking missile "${attacker.name}" killed`)
attacker.kill()
})
generated lua
local destroyMissileTrigger = __TS__New(Trigger)
destroyMissileTrigger:registerAnyUnitEvent(EVENT_PLAYER_UNIT_ATTACKED)
destroyMissileTrigger:addCondition(
function()
return true
end
)
destroyMissileTrigger:addAction(
function()
local attacker = Unit:fromHandle(
GetAttacker()
)
Log.Debug(
("Attacking missile \"" .. tostring(attacker.name)) .. "\" killed"
)
attacker:kill()
end
)
While trying to get the example code up and running using your template, I noticed I could not get any trigger action to run (it works in my other map though).
Hey, currently the CameraSetup.fromHandle()
doesn't return the correct type and makes that class useless when trying to use cameras created from variables.
public static fromHandle(handle: camerasetup): camerasetup {
return this.getObject(handle);
}
... and more
Group is missing a hasUnit function and also this function should be renamed I guess?
public GroupEnumUnitsInRangeCounted(x: number, y: number, radius: number, filter: boolexpr, countLimit: number) {
GroupEnumUnitsInRangeCounted(this.handle, x, y, radius, filter, countLimit);
}
Also I'm willing to contribute. Are there any plans to make this resource easier for contribution (create w3ts org) or should I open PRs for my changes for now?
I've realized a ton of stuff in Unit
is actually about Hero
, which might not always be needed.
Would it make sense to split it?
Hey,
I'm trying to Extend the MapPlayer class but am unable to because the constructor is set up to private. Would you be able to change it to protected instead? Then, I'd be able to extend it properly and it wouldn't change in reality it is hidden.
Hi,
Is there any reason why the constructor of Player
(https://github.com/cipherxof/w3ts/blob/master/handles/player.ts) is defined as private ? I unfortunately cannot extend the class that way. From what I saw in the codebase, most of the handle classes have public constructors.
Thanks !
PS: I can submit a PR if you want me to.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.