Skip to content

Commit

Permalink
key L reloads all lua scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rfabbri committed Mar 4, 2015
1 parent 5dc80a0 commit 75e7421
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/main/java/com/pulapirata/core/PetWorld.java
Expand Up @@ -92,6 +92,7 @@ class PetWorld extends World {
private boolean print_status_ = false;
public final String tstScript_ = "lua/tst.lua";
public LuaValue tstChunk_;
public Globals globals_;

/*-------------------------------------------------------------------------------*/
/** Types of entities */
Expand Down Expand Up @@ -297,10 +298,10 @@ public void onFailure(Throwable err) {
// Instantiate Lua Script Engine

// create an environment to run in
Globals globals = JsePlatform.standardGlobals();
globals_ = JsePlatform.standardGlobals();

// Use the convenience function on Globals to load a chunk.
tstChunk_ = globals.loadfile(tstScript_);
tstChunk_ = globals_.loadfile(tstScript_);
}

// FIXME use enum
Expand Down Expand Up @@ -676,7 +677,6 @@ private void clampxyPoly(Point p, float r) {
pprint("[key] DOWN press " + velo_.x + ", " + velo_.y);
break;
case SPACE:
java.lang.System.out.println("Key SPACE pressed: u mean jump?");
mainPet_.print();
break;
case S:
Expand All @@ -688,6 +688,10 @@ private void clampxyPoly(Point p, float r) {
case R:
java.lang.System.out.println("Key R pressed: u mean reload attributes file?");
break;
case L:
pprint("Reloading lua scripts\n");
tstChunk_ = globals_.loadfile(tstScript_);
break;
case EQUALS:
case PLUS:
if (attributesLoaded_)
Expand Down

0 comments on commit 75e7421

Please sign in to comment.