about summary refs log tree commit diff
path: root/pkg/lang/modules/core/natives.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/modules/core/natives.go')
-rw-r--r--pkg/lang/modules/core/natives.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/lang/modules/core/natives.go b/pkg/lang/modules/core/natives.go
index 7fc9a01..3031d82 100644
--- a/pkg/lang/modules/core/natives.go
+++ b/pkg/lang/modules/core/natives.go
@@ -5,6 +5,7 @@ import (
 	"jinx/pkg/lang/vm/code"
 	"jinx/pkg/lang/vm/executor"
 	"jinx/pkg/lang/vm/value"
+	"time"
 )
 
 var Natives = []any{
@@ -137,6 +138,18 @@ var Natives = []any{
 
 		return value.Value{}, exe.Write(s)
 	}),
+
+	n(":core:sleep", 1, func(exe executor.Exectutor, args []value.Value) (value.Value, error) {
+		duration, err := ensureType[value.IntData](args[0], value.IntType)
+		if err != nil {
+			return value.Value{}, err
+		}
+
+		durationInMilliseconds := duration.Get()
+		time.Sleep(time.Duration(durationInMilliseconds) * time.Millisecond)
+
+		return value.Value{}, nil
+	}),
 }
 
 type native struct {