@@ -2584,67 +2584,58 @@ function enemy:customtimeraction(action, arg, arg2)
2584
2584
end
2585
2585
2586
2586
function enemy :ifstatement (t , action , arg )
2587
- -- EXAMPLE: ["if","speedx","==","speedy"],["set","speedy"],10
2588
- -- EXAMPLE: ["if","speedx","==","speedy","and","jumping","~=",false],["set","speedy"],10
2587
+ -- EXAMPLE: ["if","speedx","==","speedy"],["set","speedy"],10],
2588
+ -- EXAMPLE: ["if","speedx","==","speedy","and","jumping","~=",false],["set","speedy"],10],
2589
2589
local statementPass = false
2590
2590
for step = 1 , math.floor (# t / 4 ) do
2591
2591
local i = 1 + (step - 1 )* 4
2592
- local check = t [i ]
2592
+ local check = t [i ]: lower ()
2593
2593
2594
- -- get properties needed for comparison
2595
- local prop1 ,prop2 = t [i + 1 ], t [i + 3 ]
2596
- if (type (prop1 ) == " table" and prop1 [1 ] and prop1 [2 ] and prop1 [1 ] == " property" ) then
2597
- prop1 = self [prop1 [2 ]]
2598
- else
2599
- prop1 = self [prop1 ]
2600
- end
2601
- if (type (prop2 ) == " string" and self [prop2 ] ~= nil ) then
2602
- prop2 = self [prop2 ]
2603
- elseif (type (prop2 ) == " table" and prop2 [1 ] and prop2 [2 ] and prop2 [1 ] == " property" ) then
2604
- prop2 = self [prop2 [2 ]]
2605
- end
2606
-
2607
- -- comparison
2608
- local comparison = t [i + 2 ]
2609
- if (not comparison ) or (type (comparison ) ~= " string" ) then
2610
- return false
2594
+ -- logic
2595
+ if check == " or" and statementPass then
2596
+ break
2611
2597
end
2612
- comparison = comparison :lower ()
2613
-
2614
- local pass
2615
- if (comparison == " equal" or comparison == " ==" ) and (prop1 == prop2 ) then
2616
- pass = true
2617
- elseif (comparison == " notequal" or comparison == " ~=" or comparison == " !=" ) and (prop1 ~= prop2 ) then
2618
- pass = true
2619
-
2620
- elseif (comparison == " greater" or comparison == " >" ) and (prop1 > prop2 ) then
2621
- pass = true
2622
- elseif (comparison == " less" or comparison == " <" ) and (prop1 < prop2 ) then
2623
- pass = true
2624
- elseif (comparison == " greaterequal" or comparison == " >=" ) and (prop1 >= prop2 ) then
2625
- pass = true
2626
- elseif (comparison == " lessequal" or comparison == " <=" ) and (prop1 <= prop2 ) then
2627
- pass = true
2628
-
2629
- elseif (comparison == " exists" ) and prop1 ~= nil then
2630
- pass = true
2631
- elseif (comparison == " notexists" ) and prop1 == nil then
2632
- pass = true
2633
- end
2634
-
2635
- -- logical operators
2636
- if check == " if" or check == " and" then
2637
- if pass then
2638
- statementPass = true
2598
+ if statementPass == true or check == " or" or step == 1 then
2599
+ -- get properties needed for comparison
2600
+ local prop1 ,prop2 = t [i + 1 ], t [i + 3 ]
2601
+ if (type (prop1 ) == " table" and prop1 [1 ] and prop1 [2 ] and prop1 [1 ] == " property" ) then
2602
+ prop1 = self [prop1 [2 ]]
2639
2603
else
2640
- statementPass = false
2641
- break
2604
+ prop1 = self [prop1 ]
2605
+ end
2606
+ if (type (prop2 ) == " string" and self [prop2 ] ~= nil ) then
2607
+ prop2 = self [prop2 ]
2608
+ elseif (type (prop2 ) == " table" and prop2 [1 ] and prop2 [2 ] and prop2 [1 ] == " property" ) then
2609
+ prop2 = self [prop2 [2 ]]
2642
2610
end
2643
- elseif check == " or" then
2644
- if pass then
2645
- statementPass = true
2646
- break
2611
+
2612
+ -- comparison
2613
+ local comparison = t [i + 2 ]
2614
+ if (not comparison ) or (type (comparison ) ~= " string" ) then
2615
+ return false
2647
2616
end
2617
+ comparison = comparison :lower ()
2618
+
2619
+ local pass = false
2620
+ if (comparison == " equal" or comparison == " ==" ) and (prop1 == prop2 ) then
2621
+ pass = true
2622
+ elseif (comparison == " notequal" or comparison == " ~=" or comparison == " !=" ) and (prop1 ~= prop2 ) then
2623
+ pass = true
2624
+ elseif (comparison == " greater" or comparison == " >" ) and (prop1 > prop2 ) then
2625
+ pass = true
2626
+ elseif (comparison == " less" or comparison == " <" ) and (prop1 < prop2 ) then
2627
+ pass = true
2628
+ elseif (comparison == " greaterequal" or comparison == " >=" ) and (prop1 >= prop2 ) then
2629
+ pass = true
2630
+ elseif (comparison == " lessequal" or comparison == " <=" ) and (prop1 <= prop2 ) then
2631
+ pass = true
2632
+ elseif (comparison == " exists" ) and prop1 ~= nil then
2633
+ pass = true
2634
+ elseif (comparison == " notexists" ) and prop1 == nil then
2635
+ pass = true
2636
+ end
2637
+
2638
+ statementPass = pass
2648
2639
end
2649
2640
end
2650
2641
0 commit comments