@@ -431,45 +431,6 @@ namespace LuaFunctions {
431
431
return 1 ;
432
432
}
433
433
434
- int IdToString (lua_State* l) {
435
- if (lua_isinteger (l, 1 )) {
436
- DWORD id = (DWORD)lua_tointeger (l, 1 );
437
- std::reverse (&(((LPSTR)&id)[0 ]), &(((LPSTR)&id)[4 ]));
438
- lua_pushlstring (l, (LPSTR)&id, 4 );
439
- }
440
- else {
441
- return luaL_typeerror (l, 1 , " integer" );
442
- }
443
-
444
-
445
- return 1 ;
446
- }
447
-
448
- int StringToId (lua_State* l) {
449
- if (lua_isstring (l, 1 )) {
450
- lua_pushinteger (l, Jass::ToID (lua_tostring (l, 1 )));
451
- }
452
- else {
453
- return luaL_typeerror (l, 1 , " string" );
454
- }
455
-
456
- return 1 ;
457
- }
458
-
459
- int FourCC (lua_State* l) {
460
- if (lua_isinteger (l, 1 )) {
461
- IdToString (l);
462
- }
463
- else if (lua_isstring (l, 1 )) {
464
- StringToId (l);
465
- }
466
- else {
467
- return luaL_typeerror (l, 1 , " string or integer" );
468
- }
469
-
470
- return 1 ;
471
- }
472
-
473
434
int lua_jassoplistgc (lua_State* l) {
474
435
lua_getfield (l, 1 , " oplist" );
475
436
delete (JassMachine::JASS_OPLIST*)lua_touserdata (l, -1 );
@@ -527,11 +488,7 @@ namespace LuaFunctions {
527
488
528
489
for (auto & native : Jass::jassnatives) {
529
490
lua_registerJassNative (l, native.first .data (), &native.second , lua_invokeNative);
530
- }
531
-
532
- lua_register (l, " IdToString" , IdToString);
533
- lua_register (l, " StringToId" , StringToId);
534
- lua_register (l, " FourCC" , FourCC);
491
+ }
535
492
}
536
493
537
494
int lua_getJassArrayElement (lua_State* l) {
@@ -720,6 +677,45 @@ namespace LuaFunctions {
720
677
721
678
// --------------------------------------------------------
722
679
680
+ int lua_IdToString (lua_State* l) {
681
+ if (lua_isinteger (l, 1 )) {
682
+ DWORD id = (DWORD)lua_tointeger (l, 1 );
683
+ std::reverse (&(((LPSTR)&id)[0 ]), &(((LPSTR)&id)[4 ]));
684
+ lua_pushlstring (l, (LPSTR)&id, 4 );
685
+ }
686
+ else {
687
+ return luaL_typeerror (l, 1 , " integer" );
688
+ }
689
+
690
+
691
+ return 1 ;
692
+ }
693
+
694
+ int lua_StringToId (lua_State* l) {
695
+ if (lua_isstring (l, 1 )) {
696
+ lua_pushinteger (l, Jass::ToID (lua_tostring (l, 1 )));
697
+ }
698
+ else {
699
+ return luaL_typeerror (l, 1 , " string" );
700
+ }
701
+
702
+ return 1 ;
703
+ }
704
+
705
+ int lua_FourCC (lua_State* l) {
706
+ if (lua_isinteger (l, 1 )) {
707
+ lua_IdToString (l);
708
+ }
709
+ else if (lua_isstring (l, 1 )) {
710
+ lua_StringToId (l);
711
+ }
712
+ else {
713
+ return luaL_typeerror (l, 1 , " string or integer" );
714
+ }
715
+
716
+ return 1 ;
717
+ }
718
+
723
719
int lua_GetMapFileName (lua_State* l) {
724
720
if (lua_isboolean (l, 1 )) {
725
721
Storm::Archive map;
@@ -740,7 +736,26 @@ namespace LuaFunctions {
740
736
return 1 ;
741
737
}
742
738
739
+ int lua_IsDevMode (lua_State* l) {
740
+ lua_pushboolean (l, developerMode);
741
+
742
+ return 1 ;
743
+ }
744
+
745
+ int lua_IsUjAPI (lua_State* l) {
746
+ lua_pushboolean (l, isUjAPI);
747
+
748
+ return 1 ;
749
+ }
750
+
743
751
void lua_openExternalFunctions (lua_State* l) {
752
+ lua_register (l, " IdToString" , lua_IdToString);
753
+ lua_register (l, " StringToId" , lua_StringToId);
754
+ lua_register (l, " FourCC" , lua_FourCC);
755
+
744
756
lua_register (l, " GetMapFileName" , lua_GetMapFileName);
757
+
758
+ lua_register (l, " IsDevMode" , lua_IsDevMode);
759
+ lua_register (l, " IsUjAPI" , lua_IsUjAPI);
745
760
}
746
761
}
0 commit comments