How to go from a level to another level
by Uldon · in Torque Game Engine · 11/02/2009 (6:59 pm) · 7 replies
As i do not know much at all in Torque i seem to cant find a answer to one of my biggest questions, in a game i make, how would i go from level 1 to level 2 without going through files and saves. Like it would be cool to have a arrow at the bottom and click on it to go to the next level, is it scripting? What do i do to go from level to level?
#2
11/03/2009 (7:17 pm)
Umm, im a bit confused would i just stick this in the game.cs file? at the bottom of the script or replace it with the one already there, also would i keep the number there or do i just backspace and delete them all. I put it on the bottom of the game.cs script and i loaded my game and it was a black screen..so i took out the script and it went back to the game screen again. Should i make like a arrow on each map? If i do that i may need a script to go to the next level.
#3
So far, I know you want a button to send to the next level. Do you want this button always visible? Do you want it only visible or able to be pressed when the level has been completed? Gimme a few more details and I'll get ya going.
11/03/2009 (7:35 pm)
Let's ignore the above code, and work on getting you something tailored to what you are trying to accomplish. Nothing worse than trying to learn from code that does something similiar, but not exactly what you want.So far, I know you want a button to send to the next level. Do you want this button always visible? Do you want it only visible or able to be pressed when the level has been completed? Gimme a few more details and I'll get ya going.
#4
11/04/2009 (5:02 pm)
I want it to be a small white arrow, visable. I also would like to know where did you get our knowledge about this stuff for scripting and such, and forums or anything? I would like to know for i may be able to do it myself.
#5
To tie the above code to pressing the arrow, you would add to the command field of the arrow, "onCycleExec();". Doing so would call that specific function, which searches through your mission files to find the next one in line, it will be important to save your missions and keep them in order, something like mygamemission01.mis then 02, 03, 04 etc. That should be enough to accomplish what you're going for.
As far as where did I get the knowledge, I got it through years of headaches, and screaming at my computer screen. I've learned most from just browsing the forums and searching for ideas I had that I wanted to know how to do. I've learned some through asking questions here, but you really stand a bad chance of having a question answered that you ask. The community has moved onto T3D mostly, but there are still a few good people around who go out of their way to help, so don't ever be scared to ask, no matter how dumb or small you may think it to be.
11/04/2009 (7:36 pm)
For the arrow you're gonna want to make a .png file of an arrow to be clicked (sure you already knew that). Now there are a few things you want to keep in mind. Like I said before, should this arrow be clickable at any time, or only when certain aspects of the game have been achieved. The latter will take a bit more finess and scripting to accomplish. Also be aware that if you are making a clickable element, that the mouse needs to be active, which unties the control of the character unless you script this type of control.To tie the above code to pressing the arrow, you would add to the command field of the arrow, "onCycleExec();". Doing so would call that specific function, which searches through your mission files to find the next one in line, it will be important to save your missions and keep them in order, something like mygamemission01.mis then 02, 03, 04 etc. That should be enough to accomplish what you're going for.
As far as where did I get the knowledge, I got it through years of headaches, and screaming at my computer screen. I've learned most from just browsing the forums and searching for ideas I had that I wanted to know how to do. I've learned some through asking questions here, but you really stand a bad chance of having a question answered that you ask. The community has moved onto T3D mostly, but there are still a few good people around who go out of their way to help, so don't ever be scared to ask, no matter how dumb or small you may think it to be.
#6
Here's the one I use:
(I learned from trial and error, and reading the books sold here on GG.)
11/04/2009 (8:50 pm)
There is a much easier way to change missions than to click an object. You can make a trigger. When the player follows your arrow, he enters the trigger and get's moved to the new mission.Here's the one I use:
//Trigger to switch missions
datablock TriggerData (Trigger2SwapMission)
{
tickPeriodMS = 100;
};
function Trigger2SwapMission::onEnterTrigger(%this,%trigger,%obj)
{
%client = %obj.client;
if(!%client)
{
// return if not a client
// we do not want any npc or other players walking into our trigger and seting off the swap mission
return;
}
%ZoneName = "mazeWorld2.mis"; // mission name
%SpawnPoint = %trigger.SpawnPoint; // Spawn Point in mission
echo("Zone client:" SPC %client SPC "to" SPC %ZoneName SPC "at" SPC %SpawnPoint);
schedule( 0, 0, loadMission, "game/data/missions/" @ %ZoneName,false,%SpawnPoint);
}You can copy that to a new cs file and place in in the server folder. Exec it in game.cs. (I learned from trial and error, and reading the books sold here on GG.)
#7
11/12/2009 (7:02 pm)
I want the arrow to be click able only when they have finished that player or a amount of time is finished.
Torque Owner Richard Preziosi
WinterLeaf Entertainment
// set the timer in function startGame (called by onMissionLoaded) $Game::Schedule = schedule($Game::Duration * 1000, 0, "CycleGame" ); function cycleGame() { if (!$Game::Cycling) { $Game::Cycling = true; $Game::Schedule = schedule(0, 0, "onCycleExec"); } } function onCycleExec() { endGame(); $Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd"); } function onCyclePauseEnd() { $Game::Cycling = false; echo("@@@@@@@@@@@ enter to onCyclePauseEnd "); // Just cycle through the missions for now. %search = $Server::MissionFileSpec; for (%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search)) { if (%file $= $Server::MissionFile) { // Get the next one, back to the first if there is no next. %file = findNextFile(%search); if (%file $= "") %file = findFirstFile(%search); break; } } loadMission(%file); echo("@@@@@@@@@@@ leave the onCyclePauseEnd "); }If you're just clicking a GUI element, just use loadMission(missionname);