added . operator, changed priorities of ~ and ., cleaned entity_event handler and docs, replaced default call function to space, added stacktrace to unknown exceptions, renamed event to 'on_damaged'

This commit is contained in:
gnembon committed 2019-10-01 02:37:30 -03:00
1 parent 99af49661b
commit aac313bbb3
4 files changed
+57 -12

No files matched your search

@@ -235,7 +235,7 @@ public class CarpetEventServer
private ScheduledCall makeEventCall(CarpetContext cc, String function, List<Value> extraArgs, int argCount)
{
UserDefinedFunction udf = cc.host.globalFunctions.get(function);
if (udf == null || (udf.getArguments().size()-extraArgs.size()) != argCount)
if (udf == null || (udf.getArguments().size()-(extraArgs == null ? 0 : extraArgs.size())) != argCount)
{
// call won't match arguments
return null;
@@ -389,11 +389,9 @@ public class CarpetEventServer
}
public ScheduledCall makeDamageCall(CarpetContext cc, String function, List<Value> extraArgs)
{
return makeEventCall(cc, function, extraArgs, 3);
return makeEventCall(cc, function, extraArgs, 4);
}
public void onEntityDeath(ScheduledCall call, Entity e, String reason)
{
call.execute( Arrays.asList( (c, t)-> new EntityValue(e), (c, t)-> new StringValue(reason)));