UNPKG

mdx-m3-viewer

Version:

A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.

1,861 lines (1,500 loc) 528 kB
// @ts-ignore import { lua_State, lua_register, lua_pushinteger, lua_pushnumber, lua_pushstring, lua_pushlightuserdata, lua_touserdata, lua_pushboolean, lua_pushnil, lua_toboolean, LUA_REGISTRYINDEX, lua_yield } from 'fengari/src/lua'; // @ts-ignore import { luaL_checkstring, luaL_checkinteger, luaL_checknumber, luaL_ref, luaL_unref } from 'fengari/src/lauxlib'; import { JassTimer, JassGroup, JassLocation, JassForce, JassUnit, JassTrigger } from './types'; import Context from './context'; /** * constant native ConvertRace takes integer i returns race */ function ConvertRace(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.races[i]); return 1; } /** * constant native ConvertAllianceType takes integer i returns alliancetype */ function ConvertAllianceType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.allianceTypes[i]); return 1; } /** * constant native ConvertRacePref takes integer i returns racepreference */ function ConvertRacePref(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.racePrefs[i]); return 1; } /** * constant native ConvertIGameState takes integer i returns igamestate */ function ConvertIGameState(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.gameStates[i]); return 1; } /** * constant native ConvertFGameState takes integer i returns fgamestate */ function ConvertFGameState(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.gameStates[i]); return 1; } /** * constant native ConvertPlayerState takes integer i returns playerstate */ function ConvertPlayerState(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.playerStates[i]); return 1; } /** * constant native ConvertPlayerScore takes integer i returns playerscore */ function ConvertPlayerScore(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.playerScores[i]); return 1; } /** * constant native ConvertPlayerGameResult takes integer i returns playergameresult */ function ConvertPlayerGameResult(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.playerGameResults[i]); return 1; } /** * constant native ConvertUnitState takes integer i returns unitstate */ function ConvertUnitState(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.unitStates[i]); return 1; } /** * constant native ConvertAIDifficulty takes integer i returns aidifficulty */ function ConvertAIDifficulty(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.aiDifficulties[i]); return 1; } /** * constant native ConvertGameEvent takes integer i returns gameevent */ function ConvertGameEvent(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.events[i]); return 1; } /** * constant native ConvertPlayerEvent takes integer i returns playerevent */ function ConvertPlayerEvent(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.events[i]); return 1; } /** * constant native ConvertPlayerUnitEvent takes integer i returns playerunitevent */ function ConvertPlayerUnitEvent(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.events[i]); return 1; } /** * constant native ConvertWidgetEvent takes integer i returns widgetevent */ function ConvertWidgetEvent(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.events[i]); return 1; } /** * constant native ConvertDialogEvent takes integer i returns dialogevent */ function ConvertDialogEvent(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.events[i]); return 1; } /** * constant native ConvertUnitEvent takes integer i returns unitevent */ function ConvertUnitEvent(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.events[i]); return 1; } /** * constant native ConvertLimitOp takes integer i returns limitop */ function ConvertLimitOp(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.limitOps[i]); return 1; } /** * constant native ConvertUnitType takes integer i returns unittype */ function ConvertUnitType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.unitTypes[i]); return 1; } /** * constant native ConvertGameSpeed takes integer i returns gamespeed */ function ConvertGameSpeed(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.gameSpeeds[i]); return 1; } /** * constant native ConvertPlacement takes integer i returns placement */ function ConvertPlacement(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.placements[i]); return 1; } /** * constant native ConvertStartLocPrio takes integer i returns startlocprio */ function ConvertStartLocPrio(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.startLocPrios[i]); return 1; } /** * constant native ConvertGameDifficulty takes integer i returns gamedifficulty */ function ConvertGameDifficulty(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.gameDifficulties[i]); return 1; } /** * constant native ConvertGameType takes integer i returns gametype */ function ConvertGameType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.gameTypes[i]); return 1; } /** * constant native ConvertMapFlag takes integer i returns mapflag */ function ConvertMapFlag(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.mapFlags[i]); return 1; } /** * constant native ConvertMapVisibility takes integer i returns mapvisibility */ function ConvertMapVisibility(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); console.warn('ConvertMapVisibility used, but the implementation is unknown'); lua_pushnil(L); return 1; } /** * constant native ConvertMapSetting takes integer i returns mapsetting */ function ConvertMapSetting(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); console.warn('ConvertMapSetting used, but the implementation is unknown'); lua_pushnil(L); return 1; } /** * constant native ConvertMapDensity takes integer i returns mapdensity */ function ConvertMapDensity(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.mapDensities[i]); return 1; } /** * constant native ConvertMapControl takes integer i returns mapcontrol */ function ConvertMapControl(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.mapControls[i]); return 1; } /** * constant native ConvertPlayerColor takes integer i returns playercolor */ function ConvertPlayerColor(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.playerColors[i]); return 1; } /** * constant native ConvertPlayerSlotState takes integer i returns playerslotstate */ function ConvertPlayerSlotState(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.playerSlotStates[i]); return 1; } /** * constant native ConvertVolumeGroup takes integer i returns volumegroup */ function ConvertVolumeGroup(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.volumeGroups[i]); return 1; } /** * constant native ConvertCameraField takes integer i returns camerafield */ function ConvertCameraField(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.cameraFields[i]); return 1; } /** * constant native ConvertBlendMode takes integer i returns blendmode */ function ConvertBlendMode(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.blendModes[i]); return 1; } /** * constant native ConvertRarityControl takes integer i returns raritycontrol */ function ConvertRarityControl(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.rarityControls[i]); return 1; } /** * constant native ConvertTexMapFlags takes integer i returns texmapflags */ function ConvertTexMapFlags(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.texMapFlags[i]); return 1; } /** * constant native ConvertFogState takes integer i returns fogstate */ function ConvertFogState(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.fogStates[i]); return 1; } /** * constant native ConvertEffectType takes integer i returns effecttype */ function ConvertEffectType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.effectTypes[i]); return 1; } /** * constant native ConvertVersion takes integer i returns version */ function ConvertVersion(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.versions[i]); return 1; } /** * constant native ConvertItemType takes integer i returns itemtype */ function ConvertItemType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.itemTypes[i]); return 1; } /** * constant native ConvertAttackType takes integer i returns attacktype */ function ConvertAttackType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.attackTypes[i]); return 1; } /** * constant native ConvertDamageType takes integer i returns damagetype */ function ConvertDamageType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.damageTypes[i]); return 1; } /** * constant native ConvertWeaponType takes integer i returns weapontype */ function ConvertWeaponType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.weaponTypes[i]); return 1; } /** * constant native ConvertSoundType takes integer i returns soundtype */ function ConvertSoundType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.soundTypes[i]); return 1; } /** * constant native ConvertPathingType takes integer i returns pathingtype */ function ConvertPathingType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.pathingTypes[i]); return 1; } /** * constant native ConvertMouseButtonType takes integer i returns mousebuttontype */ function ConvertMouseButtonType(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushlightuserdata(L, C.constantHandles.mouseButtonTypes[i]); return 1; } /** * constant native OrderId takes string orderIdString returns integer */ function OrderId(C: Context, L: lua_State) { let orderIdString = luaL_checkstring(L, 1); console.warn('OrderId was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * constant native OrderId2String takes integer orderId returns string */ function OrderId2String(C: Context, L: lua_State) { let orderId = luaL_checkinteger(L, 1); console.warn('OrderId2String was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * constant native UnitId takes string unitIdString returns integer */ function UnitId(C: Context, L: lua_State) { let unitIdString = luaL_checkstring(L, 1); console.warn('UnitId was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * constant native UnitId2String takes integer unitId returns string */ function UnitId2String(C: Context, L: lua_State) { let unitId = luaL_checkinteger(L, 1); console.warn('UnitId2String was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * constant native AbilityId takes string abilityIdString returns integer */ function AbilityId(C: Context, L: lua_State) { let abilityIdString = luaL_checkstring(L, 1); console.warn('AbilityId was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * constant native AbilityId2String takes integer abilityId returns string */ function AbilityId2String(C: Context, L: lua_State) { let abilityId = luaL_checkinteger(L, 1); console.warn('AbilityId2String was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * constant native GetObjectName takes integer objectId returns string */ function GetObjectName(C: Context, L: lua_State) { let objectId = luaL_checkinteger(L, 1); console.warn('GetObjectName was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * constant native GetBJMaxPlayers takes nothing returns integer */ function GetBJMaxPlayers(C: Context, L: lua_State) { lua_pushinteger(L, 28); return 1; } /** * constant native GetBJPlayerNeutralVictim takes nothing returns integer */ function GetBJPlayerNeutralVictim(C: Context, L: lua_State) { lua_pushinteger(L, 24); return 1; } /** * constant native GetBJPlayerNeutralExtra takes nothing returns integer */ function GetBJPlayerNeutralExtra(C: Context, L: lua_State) { lua_pushinteger(L, 25); return 1; } /** * constant native GetBJMaxPlayerSlots takes nothing returns integer */ function GetBJMaxPlayerSlots(C: Context, L: lua_State) { lua_pushinteger(L, 24); return 1; } /** * constant native GetPlayerNeutralPassive takes nothing returns integer */ function GetPlayerNeutralPassive(C: Context, L: lua_State) { lua_pushinteger(L, 26); return 1; } /** * constant native GetPlayerNeutralAggressive takes nothing returns integer */ function GetPlayerNeutralAggressive(C: Context, L: lua_State) { lua_pushinteger(L, 27); return 1; } /** * native Deg2Rad takes real degrees returns real */ function Deg2Rad(C: Context, L: lua_State) { let degrees = luaL_checknumber(L, 1); lua_pushnumber(L, degrees * (Math.PI / 180)); return 1; } /** * native Rad2Deg takes real radians returns real */ function Rad2Deg(C: Context, L: lua_State) { let radians = luaL_checknumber(L, 1); lua_pushnumber(L, radians * (180 / Math.PI)); return 1; } /** * native Sin takes real radians returns real */ function Sin(C: Context, L: lua_State) { let radians = luaL_checknumber(L, 1); lua_pushnumber(L, Math.sin(radians)); return 1; } /** * native Cos takes real radians returns real */ function Cos(C: Context, L: lua_State) { let radians = luaL_checknumber(L, 1); lua_pushnumber(L, Math.cos(radians)); return 1; } /** * native Tan takes real radians returns real */ function Tan(C: Context, L: lua_State) { let radians = luaL_checknumber(L, 1); lua_pushnumber(L, Math.tan(radians)); return 1; } /** * native Asin takes real y returns real */ function Asin(C: Context, L: lua_State) { let y = luaL_checknumber(L, 1); lua_pushnumber(L, Math.asin(y)); return 1; } /** * native Acos takes real x returns real */ function Acos(C: Context, L: lua_State) { let x = luaL_checknumber(L, 1); lua_pushnumber(L, Math.acos(x)); return 1; } /** * native Atan takes real x returns real */ function Atan(C: Context, L: lua_State) { let x = luaL_checknumber(L, 1); lua_pushnumber(L, Math.atan(x)); return 1; } /** * native Atan2 takes real y, real x returns real */ function Atan2(C: Context, L: lua_State) { let y = luaL_checknumber(L, 1); let x = luaL_checknumber(L, 2); lua_pushnumber(L, Math.atan2(y, x)); return 1; } /** * native SquareRoot takes real x returns real */ function SquareRoot(C: Context, L: lua_State) { let x = luaL_checknumber(L, 1); lua_pushnumber(L, Math.sqrt(x)); return 1; } /** * native Pow takes real x, real power returns real */ function Pow(C: Context, L: lua_State) { let x = luaL_checknumber(L, 1); let power = luaL_checknumber(L, 2); lua_pushnumber(L, Math.pow(x, power)); return 1; } /** * native I2R takes integer i returns real */ function I2R(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); lua_pushnumber(L, i); return 1; } /** * native R2I takes real r returns integer */ function R2I(C: Context, L: lua_State) { let r = luaL_checknumber(L, 1); lua_pushinteger(L, r | 0); return 1; } /** * native I2S takes integer i returns string */ function I2S(C: Context, L: lua_State) { let i = luaL_checkinteger(L, 1); console.warn('I2S was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * native R2S takes real r returns string */ function R2S(C: Context, L: lua_State) { let r = luaL_checknumber(L, 1); console.warn('R2S was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * native R2SW takes real r, integer width, integer precision returns string */ function R2SW(C: Context, L: lua_State) { let r = luaL_checknumber(L, 1); let width = luaL_checkinteger(L, 2); let precision = luaL_checkinteger(L, 3); console.warn('R2SW was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * native S2I takes string s returns integer */ function S2I(C: Context, L: lua_State) { let s = luaL_checkstring(L, 1); console.warn('S2I was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native S2R takes string s returns real */ function S2R(C: Context, L: lua_State) { let s = luaL_checkstring(L, 1); console.warn('S2R was called but is not implemented :('); lua_pushnumber(L, 0); return 1; } /** * native GetHandleId takes handle h returns integer */ function GetHandleId(C: Context, L: lua_State) { let h = lua_touserdata(L, 1); lua_pushinteger(L, h.handleId); return 1; } /** * native SubString takes string source, integer start, integer end_ returns string */ function SubString(C: Context, L: lua_State) { let source = luaL_checkstring(L, 1); let start = luaL_checkinteger(L, 2); let end_ = luaL_checkinteger(L, 3); console.warn('SubString was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * native StringLength takes string s returns integer */ function StringLength(C: Context, L: lua_State) { let s = luaL_checkstring(L, 1); console.warn('StringLength was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native StringCase takes string source, boolean upper returns string */ function StringCase(C: Context, L: lua_State) { let source = luaL_checkstring(L, 1); let upper = lua_toboolean(L, 2); console.warn('StringCase was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * native StringHash takes string s returns integer */ function StringHash(C: Context, L: lua_State) { let s = luaL_checkstring(L, 1); console.warn('StringHash was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native GetLocalizedString takes string source returns string */ function GetLocalizedString(C: Context, L: lua_State) { let source = luaL_checkstring(L, 1); console.warn('GetLocalizedString was called but is not implemented :('); lua_pushstring(L, ''); return 1; } /** * native GetLocalizedHotkey takes string source returns integer */ function GetLocalizedHotkey(C: Context, L: lua_State) { let source = luaL_checkstring(L, 1); console.warn('GetLocalizedHotkey was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native SetMapName takes string name returns nothing */ function SetMapName(C: Context, L: lua_State) { let name = luaL_checkstring(L, 1); console.warn('SetMapName was called but is not implemented :('); return 0 } /** * native SetMapDescription takes string description returns nothing */ function SetMapDescription(C: Context, L: lua_State) { let description = luaL_checkstring(L, 1); console.warn('SetMapDescription was called but is not implemented :('); return 0 } /** * native SetTeams takes integer teamcount returns nothing */ function SetTeams(C: Context, L: lua_State) { let teamcount = luaL_checkinteger(L, 1); console.warn('SetTeams was called but is not implemented :('); return 0 } /** * native SetPlayers takes integer playercount returns nothing */ function SetPlayers(C: Context, L: lua_State) { let playercount = luaL_checkinteger(L, 1); console.warn('SetPlayers was called but is not implemented :('); return 0 } /** * native DefineStartLocation takes integer whichStartLoc, real x, real y returns nothing */ function DefineStartLocation(C: Context, L: lua_State) { let whichStartLoc = luaL_checkinteger(L, 1); let x = luaL_checknumber(L, 2); let y = luaL_checknumber(L, 3); C.startLocations[whichStartLoc] = <JassLocation>C.addHandle(new JassLocation(x, y)); return 0 } /** * native DefineStartLocationLoc takes integer whichStartLoc, location whichLocation returns nothing */ function DefineStartLocationLoc(C: Context, L: lua_State) { let whichStartLoc = luaL_checkinteger(L, 1); let whichLocation = lua_touserdata(L, 2); console.warn('DefineStartLocationLoc was called but is not implemented :('); return 0 } /** * native SetStartLocPrioCount takes integer whichStartLoc, integer prioSlotCount returns nothing */ function SetStartLocPrioCount(C: Context, L: lua_State) { let whichStartLoc = luaL_checkinteger(L, 1); let prioSlotCount = luaL_checkinteger(L, 2); console.warn('SetStartLocPrioCount was called but is not implemented :('); return 0 } /** * native SetStartLocPrio takes integer whichStartLoc, integer prioSlotIndex, integer otherStartLocIndex, startlocprio priority returns nothing */ function SetStartLocPrio(C: Context, L: lua_State) { let whichStartLoc = luaL_checkinteger(L, 1); let prioSlotIndex = luaL_checkinteger(L, 2); let otherStartLocIndex = luaL_checkinteger(L, 3); let priority = lua_touserdata(L, 4); console.warn('SetStartLocPrio was called but is not implemented :('); return 0 } /** * native GetStartLocPrioSlot takes integer whichStartLoc, integer prioSlotIndex returns integer */ function GetStartLocPrioSlot(C: Context, L: lua_State) { let whichStartLoc = luaL_checkinteger(L, 1); let prioSlotIndex = luaL_checkinteger(L, 2); console.warn('GetStartLocPrioSlot was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native GetStartLocPrio takes integer whichStartLoc, integer prioSlotIndex returns startlocprio */ function GetStartLocPrio(C: Context, L: lua_State) { let whichStartLoc = luaL_checkinteger(L, 1); let prioSlotIndex = luaL_checkinteger(L, 2); console.warn('GetStartLocPrio was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * native SetGameTypeSupported takes gametype whichGameType, boolean value returns nothing */ function SetGameTypeSupported(C: Context, L: lua_State) { let whichGameType = lua_touserdata(L, 1); let value = lua_toboolean(L, 2); console.warn('SetGameTypeSupported was called but is not implemented :('); return 0 } /** * native SetMapFlag takes mapflag whichMapFlag, boolean value returns nothing */ function SetMapFlag(C: Context, L: lua_State) { let whichMapFlag = lua_touserdata(L, 1); let value = lua_toboolean(L, 2); console.warn('SetMapFlag was called but is not implemented :('); return 0 } /** * native SetGamePlacement takes placement whichPlacementType returns nothing */ function SetGamePlacement(C: Context, L: lua_State) { let whichPlacementType = lua_touserdata(L, 1); console.warn('SetGamePlacement was called but is not implemented :('); return 0 } /** * native SetGameSpeed takes gamespeed whichspeed returns nothing */ function SetGameSpeed(C: Context, L: lua_State) { let whichspeed = lua_touserdata(L, 1); console.warn('SetGameSpeed was called but is not implemented :('); return 0 } /** * native SetGameDifficulty takes gamedifficulty whichdifficulty returns nothing */ function SetGameDifficulty(C: Context, L: lua_State) { let whichdifficulty = lua_touserdata(L, 1); console.warn('SetGameDifficulty was called but is not implemented :('); return 0 } /** * native SetResourceDensity takes mapdensity whichdensity returns nothing */ function SetResourceDensity(C: Context, L: lua_State) { let whichdensity = lua_touserdata(L, 1); console.warn('SetResourceDensity was called but is not implemented :('); return 0 } /** * native SetCreatureDensity takes mapdensity whichdensity returns nothing */ function SetCreatureDensity(C: Context, L: lua_State) { let whichdensity = lua_touserdata(L, 1); console.warn('SetCreatureDensity was called but is not implemented :('); return 0 } /** * native GetTeams takes nothing returns integer */ function GetTeams(C: Context, L: lua_State) { console.warn('GetTeams was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native GetPlayers takes nothing returns integer */ function GetPlayers(C: Context, L: lua_State) { console.warn('GetPlayers was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native IsGameTypeSupported takes gametype whichGameType returns boolean */ function IsGameTypeSupported(C: Context, L: lua_State) { let whichGameType = lua_touserdata(L, 1); console.warn('IsGameTypeSupported was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GetGameTypeSelected takes nothing returns gametype */ function GetGameTypeSelected(C: Context, L: lua_State) { console.warn('GetGameTypeSelected was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * native IsMapFlagSet takes mapflag whichMapFlag returns boolean */ function IsMapFlagSet(C: Context, L: lua_State) { let whichMapFlag = lua_touserdata(L, 1); console.warn('IsMapFlagSet was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * constant native GetGamePlacement takes nothing returns placement */ function GetGamePlacement(C: Context, L: lua_State) { console.warn('GetGamePlacement was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * constant native GetGameSpeed takes nothing returns gamespeed */ function GetGameSpeed(C: Context, L: lua_State) { console.warn('GetGameSpeed was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * constant native GetGameDifficulty takes nothing returns gamedifficulty */ function GetGameDifficulty(C: Context, L: lua_State) { console.warn('GetGameDifficulty was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * constant native GetResourceDensity takes nothing returns mapdensity */ function GetResourceDensity(C: Context, L: lua_State) { console.warn('GetResourceDensity was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * constant native GetCreatureDensity takes nothing returns mapdensity */ function GetCreatureDensity(C: Context, L: lua_State) { console.warn('GetCreatureDensity was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * constant native GetStartLocationX takes integer whichStartLocation returns real */ function GetStartLocationX(C: Context, L: lua_State) { let whichStartLocation = luaL_checkinteger(L, 1); console.warn('GetStartLocationX was called but is not implemented :('); lua_pushnumber(L, 0); return 1; } /** * constant native GetStartLocationY takes integer whichStartLocation returns real */ function GetStartLocationY(C: Context, L: lua_State) { let whichStartLocation = luaL_checkinteger(L, 1); console.warn('GetStartLocationY was called but is not implemented :('); lua_pushnumber(L, 0); return 1; } /** * constant native GetStartLocationLoc takes integer whichStartLocation returns location */ function GetStartLocationLoc(C: Context, L: lua_State) { let whichStartLocation = luaL_checkinteger(L, 1); console.warn('GetStartLocationLoc was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * native SetPlayerTeam takes player whichPlayer, integer whichTeam returns nothing */ function SetPlayerTeam(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let whichTeam = luaL_checkinteger(L, 2); console.warn('SetPlayerTeam was called but is not implemented :('); return 0 } /** * native SetPlayerStartLocation takes player whichPlayer, integer startLocIndex returns nothing */ function SetPlayerStartLocation(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let startLocIndex = luaL_checkinteger(L, 2); whichPlayer.startLocation = startLocIndex; return 0 } /** * native ForcePlayerStartLocation takes player whichPlayer, integer startLocIndex returns nothing */ function ForcePlayerStartLocation(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let startLocIndex = luaL_checkinteger(L, 2); console.warn('ForcePlayerStartLocation was called but is not implemented :('); return 0 } /** * native SetPlayerColor takes player whichPlayer, playercolor color returns nothing */ function SetPlayerColor(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let color = lua_touserdata(L, 2); whichPlayer.color = color; return 0 } /** * native SetPlayerAlliance takes player sourcePlayer, player otherPlayer, alliancetype whichAllianceSetting, boolean value returns nothing */ function SetPlayerAlliance(C: Context, L: lua_State) { let sourcePlayer = lua_touserdata(L, 1); let otherPlayer = lua_touserdata(L, 2); let whichAllianceSetting = lua_touserdata(L, 3); let value = lua_toboolean(L, 4); console.warn('SetPlayerAlliance was called but is not implemented :('); return 0 } /** * native SetPlayerTaxRate takes player sourcePlayer, player otherPlayer, playerstate whichResource, integer rate returns nothing */ function SetPlayerTaxRate(C: Context, L: lua_State) { let sourcePlayer = lua_touserdata(L, 1); let otherPlayer = lua_touserdata(L, 2); let whichResource = lua_touserdata(L, 3); let rate = luaL_checkinteger(L, 4); console.warn('SetPlayerTaxRate was called but is not implemented :('); return 0 } /** * native SetPlayerRacePreference takes player whichPlayer, racepreference whichRacePreference returns nothing */ function SetPlayerRacePreference(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let whichRacePreference = lua_touserdata(L, 2); console.warn('SetPlayerRacePreference was called but is not implemented :('); return 0 } /** * native SetPlayerRaceSelectable takes player whichPlayer, boolean value returns nothing */ function SetPlayerRaceSelectable(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let value = lua_toboolean(L, 2); whichPlayer.raceSelectable = value; return 0 } /** * native SetPlayerController takes player whichPlayer, mapcontrol controlType returns nothing */ function SetPlayerController(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let controlType = lua_touserdata(L, 2); whichPlayer.controller = controlType; return 0 } /** * native SetPlayerName takes player whichPlayer, string name returns nothing */ function SetPlayerName(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let name = luaL_checkstring(L, 2); whichPlayer.name = name; return 0 } /** * native SetPlayerOnScoreScreen takes player whichPlayer, boolean flag returns nothing */ function SetPlayerOnScoreScreen(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let flag = lua_toboolean(L, 2); console.warn('SetPlayerOnScoreScreen was called but is not implemented :('); return 0 } /** * native GetPlayerTeam takes player whichPlayer returns integer */ function GetPlayerTeam(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); console.warn('GetPlayerTeam was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native GetPlayerStartLocation takes player whichPlayer returns integer */ function GetPlayerStartLocation(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); lua_pushinteger(L, whichPlayer.startLocation); return 1; } /** * native GetPlayerColor takes player whichPlayer returns playercolor */ function GetPlayerColor(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); lua_pushlightuserdata(L, whichPlayer.color); return 1; } /** * native GetPlayerSelectable takes player whichPlayer returns boolean */ function GetPlayerSelectable(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); console.warn('GetPlayerSelectable was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GetPlayerController takes player whichPlayer returns mapcontrol */ function GetPlayerController(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); lua_pushlightuserdata(L, whichPlayer.controller); return 1; } /** * native GetPlayerSlotState takes player whichPlayer returns playerslotstate */ function GetPlayerSlotState(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); console.warn('GetPlayerSlotState was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * native GetPlayerTaxRate takes player sourcePlayer, player otherPlayer, playerstate whichResource returns integer */ function GetPlayerTaxRate(C: Context, L: lua_State) { let sourcePlayer = lua_touserdata(L, 1); let otherPlayer = lua_touserdata(L, 2); let whichResource = lua_touserdata(L, 3); console.warn('GetPlayerTaxRate was called but is not implemented :('); lua_pushinteger(L, 0); return 1; } /** * native IsPlayerRacePrefSet takes player whichPlayer, racepreference pref returns boolean */ function IsPlayerRacePrefSet(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); let pref = lua_touserdata(L, 2); console.warn('IsPlayerRacePrefSet was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GetPlayerName takes player whichPlayer returns string */ function GetPlayerName(C: Context, L: lua_State) { let whichPlayer = lua_touserdata(L, 1); lua_pushstring(L, whichPlayer.name); return 1; } /** * native CreateTimer takes nothing returns timer */ function CreateTimer(C: Context, L: lua_State) { lua_pushlightuserdata(L, C.addHandle(new JassTimer())); return 1; } /** * native DestroyTimer takes timer whichTimer returns nothing */ function DestroyTimer(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); // In case it's in the middle of running, remove it. C.timers.delete(whichTimer); C.freeHandle(whichTimer); return 0 } /** * native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing */ function TimerStart(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); let timeout = luaL_checknumber(L, 2); let periodic = lua_toboolean(L, 3); let handlerFunc = luaL_ref(L, LUA_REGISTRYINDEX); whichTimer.elapsed = 0; whichTimer.timeout = timeout; whichTimer.periodic = periodic; whichTimer.handlerFunc = handlerFunc; C.timers.add(whichTimer); return 0 } /** * native TimerGetElapsed takes timer whichTimer returns real */ function TimerGetElapsed(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); lua_pushnumber(L, whichTimer.elapsed); return 1; } /** * native TimerGetRemaining takes timer whichTimer returns real */ function TimerGetRemaining(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); lua_pushnumber(L, whichTimer.timeout - whichTimer.elapsed); return 1; } /** * native TimerGetTimeout takes timer whichTimer returns real */ function TimerGetTimeout(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); lua_pushnumber(L, whichTimer.timeout); return 1; } /** * native PauseTimer takes timer whichTimer returns nothing */ function PauseTimer(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); C.timers.delete(whichTimer); return 0 } /** * native ResumeTimer takes timer whichTimer returns nothing */ function ResumeTimer(C: Context, L: lua_State) { let whichTimer = lua_touserdata(L, 1); C.timers.add(whichTimer); return 0 } /** * native GetExpiredTimer takes nothing returns timer */ function GetExpiredTimer(C: Context, L: lua_State) { let thread = C.currentThread; if (thread && thread.expiredTimer) { lua_pushlightuserdata(L, thread.expiredTimer); } else { lua_pushnil(L); } return 1; } /** * native CreateGroup takes nothing returns group */ function CreateGroup(C: Context, L: lua_State) { lua_pushlightuserdata(L, C.addHandle(new JassGroup())); return 1; } /** * native DestroyGroup takes group whichGroup returns nothing */ function DestroyGroup(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); C.freeHandle(whichGroup); return 0 } /** * native GroupAddUnit takes group whichGroup, unit whichUnit returns nothing */ function GroupAddUnit(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let whichUnit = lua_touserdata(L, 2); whichGroup.units.add(whichUnit); return 0 } /** * native GroupRemoveUnit takes group whichGroup, unit whichUnit returns nothing */ function GroupRemoveUnit(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let whichUnit = lua_touserdata(L, 2); whichGroup.units.delete(whichUnit); return 0 } /** * native GroupClear takes group whichGroup returns nothing */ function GroupClear(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); whichGroup.units.clear(); return 0 } /** * native GroupEnumUnitsOfType takes group whichGroup, string unitname, boolexpr filter returns nothing */ function GroupEnumUnitsOfType(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let unitname = luaL_checkstring(L, 2); let filter = lua_touserdata(L, 3); console.warn('GroupEnumUnitsOfType was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsOfPlayer takes group whichGroup, player whichPlayer, boolexpr filter returns nothing */ function GroupEnumUnitsOfPlayer(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let whichPlayer = lua_touserdata(L, 2); let filter = lua_touserdata(L, 3); console.warn('GroupEnumUnitsOfPlayer was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsOfTypeCounted takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing */ function GroupEnumUnitsOfTypeCounted(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let unitname = luaL_checkstring(L, 2); let filter = lua_touserdata(L, 3); let countLimit = luaL_checkinteger(L, 4); console.warn('GroupEnumUnitsOfTypeCounted was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsInRect takes group whichGroup, rect r, boolexpr filter returns nothing */ function GroupEnumUnitsInRect(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let r = lua_touserdata(L, 2); let filter = lua_touserdata(L, 3); console.warn('GroupEnumUnitsInRect was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsInRectCounted takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing */ function GroupEnumUnitsInRectCounted(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let r = lua_touserdata(L, 2); let filter = lua_touserdata(L, 3); let countLimit = luaL_checkinteger(L, 4); console.warn('GroupEnumUnitsInRectCounted was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing */ function GroupEnumUnitsInRange(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let x = luaL_checknumber(L, 2); let y = luaL_checknumber(L, 3); let radius = luaL_checknumber(L, 4); let filter = lua_touserdata(L, 5); console.warn('GroupEnumUnitsInRange was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsInRangeOfLoc takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing */ function GroupEnumUnitsInRangeOfLoc(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let whichLocation = lua_touserdata(L, 2); let radius = luaL_checknumber(L, 3); let filter = lua_touserdata(L, 4); console.warn('GroupEnumUnitsInRangeOfLoc was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsInRangeCounted takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing */ function GroupEnumUnitsInRangeCounted(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let x = luaL_checknumber(L, 2); let y = luaL_checknumber(L, 3); let radius = luaL_checknumber(L, 4); let filter = lua_touserdata(L, 5); let countLimit = luaL_checkinteger(L, 6); console.warn('GroupEnumUnitsInRangeCounted was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsInRangeOfLocCounted takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing */ function GroupEnumUnitsInRangeOfLocCounted(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let whichLocation = lua_touserdata(L, 2); let radius = luaL_checknumber(L, 3); let filter = lua_touserdata(L, 4); let countLimit = luaL_checkinteger(L, 5); console.warn('GroupEnumUnitsInRangeOfLocCounted was called but is not implemented :('); return 0 } /** * native GroupEnumUnitsSelected takes group whichGroup, player whichPlayer, boolexpr filter returns nothing */ function GroupEnumUnitsSelected(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let whichPlayer = lua_touserdata(L, 2); let filter = lua_touserdata(L, 3); console.warn('GroupEnumUnitsSelected was called but is not implemented :('); return 0 } /** * native GroupImmediateOrder takes group whichGroup, string order returns boolean */ function GroupImmediateOrder(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkstring(L, 2); console.warn('GroupImmediateOrder was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupImmediateOrderById takes group whichGroup, integer order returns boolean */ function GroupImmediateOrderById(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkinteger(L, 2); console.warn('GroupImmediateOrderById was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupPointOrder takes group whichGroup, string order, real x, real y returns boolean */ function GroupPointOrder(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkstring(L, 2); let x = luaL_checknumber(L, 3); let y = luaL_checknumber(L, 4); console.warn('GroupPointOrder was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupPointOrderLoc takes group whichGroup, string order, location whichLocation returns boolean */ function GroupPointOrderLoc(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkstring(L, 2); let whichLocation = lua_touserdata(L, 3); console.warn('GroupPointOrderLoc was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupPointOrderById takes group whichGroup, integer order, real x, real y returns boolean */ function GroupPointOrderById(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkinteger(L, 2); let x = luaL_checknumber(L, 3); let y = luaL_checknumber(L, 4); console.warn('GroupPointOrderById was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupPointOrderByIdLoc takes group whichGroup, integer order, location whichLocation returns boolean */ function GroupPointOrderByIdLoc(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkinteger(L, 2); let whichLocation = lua_touserdata(L, 3); console.warn('GroupPointOrderByIdLoc was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupTargetOrder takes group whichGroup, string order, widget targetWidget returns boolean */ function GroupTargetOrder(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkstring(L, 2); let targetWidget = lua_touserdata(L, 3); console.warn('GroupTargetOrder was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native GroupTargetOrderById takes group whichGroup, integer order, widget targetWidget returns boolean */ function GroupTargetOrderById(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let order = luaL_checkinteger(L, 2); let targetWidget = lua_touserdata(L, 3); console.warn('GroupTargetOrderById was called but is not implemented :('); lua_pushboolean(L, false); return 1; } /** * native ForGroup takes group whichGroup, code callback returns nothing */ function ForGroup(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); let callback = luaL_ref(L, LUA_REGISTRYINDEX); for (let unit of whichGroup.units) { C.enumUnit = unit; C.call(callback); } C.enumUnit = null; luaL_unref(L, callback); return 0 } /** * native FirstOfGroup takes group whichGroup returns unit */ function FirstOfGroup(C: Context, L: lua_State) { let whichGroup = lua_touserdata(L, 1); console.warn('FirstOfGroup was called but is not implemented :('); lua_pushlightuserdata(L, { name: 'FAKE' }); return 1; } /** * native CreateForce takes nothing returns force */ function CreateForce(C: Context, L: lua_State) { lua_pushlightuserdata(L, C.addHandle(new JassForce())); return 1; } /** * native DestroyForce takes force whichForce returns nothing */ function DestroyForce(C: Context, L: lua_State) { let whichForce = lua_touserdata(L, 1); C.freeHandle(whichForce); return 0 } /** * native ForceAddPlayer takes force whichForce, player whichPlayer returns nothing */ function ForceAddPlayer(C: Context, L: lua_State) { let whichForce = lua_touserdata(L, 1); let whichPlayer = lua_touserdata(L, 2); whichForce.players.ad