github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/base/warn.go (about)

     1  package base
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	rt "github.com/arnodel/golua/runtime"
     8  )
     9  
    10  func warn(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
    11  	args := c.Etc()
    12  	if len(args) == 0 {
    13  		return nil, errors.New("bad argument #1 (value needed)")
    14  	}
    15  	msgs := make([]string, len(args))
    16  	for i, v := range args {
    17  		s, ok := v.ToString()
    18  		if !ok {
    19  			return nil, fmt.Errorf("bad argument #%d (string expected)", i+1)
    20  		}
    21  		msgs[i] = s
    22  	}
    23  	t.Warn(msgs...)
    24  	return c.Next(), nil
    25  }