Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/contentcreation/pps/MichiVonKaenel/scripts/moonstation/quest.lua @ 12373

Last change on this file since 12373 was 4835, checked in by vkaenemi, 18 years ago

a lot of scripting(intro/quests) +destroyed introroom

File size: 2.8 KB
Line 
1-- Get objects from orxonox
2thisscript:addObject("FPSPlayer", "Player")
3thisscript:addObject("CameraMan", "cameraManager")
4thisscript:addObject("QuestGUI", "energyQuest")
5thisscript:addObject("NPC", "triggeredDoor")
6thisscript:addObjectAsName("GameWorld", "Moon Station", "gameWorld") -- =gameTitle
7
8--get first Quest
9triggerGetEnergyQuest = ScriptTrigger()
10triggerGetEnergyQuest:setScript("quest.lua")
11triggerGetEnergyQuest:setFunction("getEnergyQuest")
12triggerGetEnergyQuest:setAbsCoor(229.492569, 38.417606, -363.788483)
13triggerGetEnergyQuest:setTarget("Player")
14triggerGetEnergyQuest:setRadius(160)
15triggerGetEnergyQuest:setDebugDraw(true)
16
17--activate energy - finish energyQuest
18triggerFinishEnergyQuest = ScriptTrigger()
19triggerFinishEnergyQuest:setScript("quest.lua")
20triggerFinishEnergyQuest:setFunction("finishEnergyQuest")
21triggerFinishEnergyQuest:setAbsCoor(346.239166, 482.885010, -160.825775)
22triggerFinishEnergyQuest:setTarget("Player")
23triggerFinishEnergyQuest:setRadius(30)
24triggerFinishEnergyQuest:setDebugDraw(true)
25
26--HINT Broken station -> find another way
27
28--HINT find action button
29
30--Tick: HINT need to open the door and stop the player
31trigger = ScriptTrigger()
32trigger:setName("doorClosedTick")
33trigger:setScript("quest.lua")
34trigger:setFunction("tick")
35trigger:setActiveOnCreation(true)
36
37
38--gloabals---------------------------------------------------------------------
39questEnergyDone = false
40lastPlayerZ = 0
41lastDoorY = 47.2
42doorSequenceTime = 7 --duration time sec
43
44function getEnergyQuest(timestep)
45        energyQuest:startGUI()
46        return true
47end
48
49function finishEnergyQuest(timestep)
50        gameWorld:showText("Good work: the emergency energy system seems to be up again.")
51        cameraManager:setCam("CameraDoor")
52        cameraManager:changeCurrTarget("NPC", "triggeredDoor")
53       
54        energyQuest:stopGUI()
55        questEnergyDone = true
56        return true
57end
58
59function tick(timestep)
60        --io.write("tick called \n")
61        if not questEnergyDone then
62                if Player:getAbsCoorZ() < -454 then
63                        --gameWorld:showText("The door can't open without energy.");
64                        Player:setAbsCoor(Player:getAbsCoorX(),Player:getAbsCoorY(),lastPlayerZ) --set player back
65                else
66                        lastPlayerZ = Player:getAbsCoorZ() --store last position
67                end
68        else --quest finished
69                if doorSequenceTime > 0 then --sequence running
70                        --triggeredDoor:walkTo(222, 47.2+92.5, -472)
71                        --lastDoorY = lastDoorY+92.5/7*timestep
72                        --triggeredDoor:setAbsDir(0,0,1,0)
73                        --triggeredDoor:setAbsDir(triggeredDoor:getAbsCoorX(), lastDoorY, triggeredDoor:getAbsCoorZ()) --BUG
74                        triggeredDoor:setVisibility(false)
75                        io.write("visibility off \n")
76                        doorSequenceTime = doorSequenceTime - timestep
77                else
78                        cameraManager:setCam("GameWorldCamera")
79                        gameWorld:showText("You should hurry as long as there  is still energy.")
80                        return true --quest&sequence finished: kill trigger
81                end
82        end
83        return false
84end
Note: See TracBrowser for help on using the repository browser.