/j2se/LGame-j2se-0.2.6/org/loon/framework/game/simple/extend/command/lua/LUAPrint.java

http://loon-simple.googlecode.com/ · Java · 51 lines · 22 code · 9 blank · 20 comment · 0 complexity · 15b7967332f25a709dce85163da2509f MD5 · raw file

  1. package org.loon.framework.game.simple.extend.command.lua;
  2. import java.io.PrintStream;
  3. import org.keplerproject.luajava.JavaFunction;
  4. import org.keplerproject.luajava.LuaState;
  5. /**
  6. * Copyright 2008 - 2009
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  9. * use this file except in compliance with the License. You may obtain a copy of
  10. * the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  16. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  17. * License for the specific language governing permissions and limitations under
  18. * the License.
  19. *
  20. * @project loonframework
  21. * @author chenpeng
  22. * @email??šceponline@yahoo.com.cn
  23. * @version 0.1
  24. */
  25. public class LUAPrint extends JavaFunction {
  26. private PrintStream out;
  27. LuaState ls;
  28. public LUAPrint(LuaState ls) {
  29. this(System.out, ls);
  30. }
  31. public LUAPrint(PrintStream out, LuaState ls) {
  32. super(ls);
  33. this.out = out;
  34. this.ls = ls;
  35. }
  36. public int execute() {
  37. int line = ls.getTop();
  38. String message = ls.toString(line);
  39. out.println(message);
  40. return 0;
  41. }
  42. }