~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/lua/embed3/runme.lua

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-11-10 16:29:56 UTC
  • mfrom: (1.2.8 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20081110162956-xue6itkuqhbza87s
Tags: 1.3.36-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop pike and libchicken-dev from the build-depends 
    (both are universe)
  - Use python2.5 instead of python2.4.
  - use php5
  - Clean Runtime/ as well.
  - debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.
  - drop "--without-mzscheme", we don't have it in our build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
print "[lua] This is runme.lua"
 
2
-- test program for embeded lua
 
3
-- we do not need to load the library, as it was already in the intrepreter
 
4
-- but lets check anyway
 
5
 
 
6
assert(type(example)=='table',"Don't appear to have loaded the example module. Do not run this file directly, run the embed3 executable")
 
7
 
 
8
print "[lua] looking to see if we have a pointer to the engine"
 
9
if type(pEngine)=="userdata" then
 
10
    print "[lua] looks good"
 
11
else
 
12
    print "[lua] nope, no signs of it"
 
13
end
 
14
 
 
15
 
 
16
-- the embed program expects a function void onEvent(Event)
 
17
-- this is it
 
18
 
 
19
function onEvent(e)
 
20
    print("[Lua] onEvent with event",e.mType)
 
21
    -- lets do something with the Engine
 
22
    -- nothing clever, but ...
 
23
    if e.mType==example.Event_STARTUP then
 
24
        pEngine:start()
 
25
    elseif e.mType==example.Event_KEYPRESS then
 
26
        pEngine:accelerate(0.4)
 
27
    elseif e.mType==example.Event_MOUSEPRESS then
 
28
        pEngine:decelerate(0.4)
 
29
    elseif e.mType==example.Event_SHUTDOWN then
 
30
        pEngine:stop()
 
31
    else
 
32
        error("unknown event type")
 
33
    end
 
34
    print("[Lua] ending onEvent")
 
35
end
 
 
b'\\ No newline at end of file'