Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11936


Ignore:
Timestamp:
May 3, 2018, 4:01:23 PM (6 years ago)
Author:
adamc
Message:

Trying to spawn entity (2nd attempt)

Location:
code/branches/ScriptableController_FS18
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ScriptableController_FS18/data/levels/AAAScriptableControllerTest.oxw

    r11928 r11936  
    11<LevelInfo
    22 name = "AAAScriptableControllerTest"
    3  description = "A level with absolutely nothing in it."
     3 description = "Demonstrates moving and killing a drone by use of a script."
    44 tags = "test"
    55 screenshot = "emptylevel.png"
     
    3030
    3131    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    32     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
     32    <SpawnPoint team=0 position="100,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
    3333
    3434
    35     <ModularSpaceShip id="Station" velocity= "0,0,0" position="50000000,0,0" lookat= "0,0,0" health="500" maxhealth="500" initialhealth="500">
    36       <templates>
    37         <Template link=endurance />
    38       </templates>
    39     </ModularSpaceShip>
     35  <AAAAutonomousDrone id="dummy" position="0,0,0">
     36    <attached>
     37      <Model scale="10" mesh="drone.mesh"/>
     38    </attached>
     39    <collisionShapes>
     40      <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
     41    </collisionShapes>
     42  </AAAAutonomousDrone>
    4043   
     44 
     45
     46
    4147  </Scene>
    4248</Level>
  • code/branches/ScriptableController_FS18/data/levels/scripts/AAAScriptableControllerTest.lua

    r11928 r11936  
    11
    2 rotate_factor = 0
    3 station_loc = 200
    4 station_speed = 0
     2rotate_factor = 0.0
     3station_loc = 200.0
     4station_speed = 0.0
     5
     6id = "dummy"
     7
    58
    69function spawn_station(obj)
     
    912        setOrientation("Station", 0, -1, 0, 0)
    1013end
     14
    1115
    1216function rotate_faster(obj1, obj2, health, shield)
     
    2327end
    2428
     29
    2530function kill_player_after_timeout(pawn)
    2631        orxPrint("Killing player after 5s")
     
    2833        registerAfterTimeout(kill_player, 5)
    2934end
     35
    3036
    3137function next_station_loc(obj1, obj2)
     
    4248
    4349
     50function kill_player()
     51        orxPrint("Killing player")
     52        killPawn("Player")
     53end
    4454
     55
     56function kill_dummy()
     57        orxPrint("Killing dummy!")
     58        killPawn(id)
     59end
     60
     61
     62function kill_player_after_timeout(pawn)
     63        orxPrint("Killing player after 5s")
     64
     65        registerAfterTimeout(kill_player, 5)
     66end
     67
     68
     69function kill_dummy_after_timeout(seconds)
     70        orxPrint("Killing dummy after " .. tostring(seconds))
     71        registerAfterTimeout(kill_dummy, seconds)
     72end
     73
     74
     75function move_dummy()
     76        orxPrint("Moving dummy!")
     77        moveControllableEntity(id, 1.0, 0.0, 0.0)
     78end
     79
     80
     81function move_dummy_after_timeout(seconds)
     82        orxPrint("Moving dummy after " .. tostring(seconds))
     83
     84        registerAfterTimeout(move_dummy, seconds)
     85end
     86
     87
     88
     89
     90move_dummy_after_timeout(5)
     91kill_dummy_after_timeout(10)
    4592
    4693
    4794orxPrint("Script started! OMG ROFL LOL WTF")
    4895mytestfunction(3.0, 4.0)
    49 spawn("ModularSpaceShip","Station2")
    5096
     97
     98spawn("ModularSpaceShip", "sepp")
     99setPosition("sepp", 500, 0, 0)
  • code/branches/ScriptableController_FS18/data/levels/scripts/BBBScriptableControllerTest.lua

    r11932 r11936  
    11
    22id = "dummy"
    3 
    43
    54
     
    2221end
    2322
     23
    2424function kill_dummy_after_timeout(seconds)
    2525        orxPrint("Killing dummy after " .. tostring(seconds))
     
    3333end
    3434
     35
    3536function move_dummy_after_timeout(seconds)
    3637        orxPrint("Moving dummy after " .. tostring(seconds))
    37 
    3838        registerAfterTimeout(move_dummy, seconds)
    3939end
  • code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc

    r11932 r11936  
    394394        if(entity == nullptr)
    395395        {
    396             orxout(user_warning) << "Trying to set velocity of an unknown object" << std::endl;
     396            orxout(user_warning) << "Trying to move an unknown object" << std::endl;
    397397            return;
    398398        }
     
    407407        {
    408408            controllable_entity = orxonox_cast<ControllableEntity*>(entity);
    409 
     409            //ATTACHED COLLISION SHAPE is MANDATORY in order to move the entity
    410410            controllable_entity->moveFrontBack(x);
    411411            controllable_entity->moveRightLeft(y);
Note: See TracChangeset for help on using the changeset viewer.