file Jeff's Custom Marble Selector!

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
12 Aug 2011 17:53 #1 by Jeff
Jeff's Custom Marble Selector! was created by Jeff
This is a basic marble selector. Well, heres the code, and I hope you enjoy

paste this code in a new file called marbleselectordlg.gui:

this goes in marble/client/ui

Code://
//MarbleSelectorDlg.gui by Jeff Hutchinson
//This is open sourced, so use it for whatever you want. Yes, you can modify
//it, and you do not have to credit me in your mod for this, I just want you
//to enjoy this!
//
//One note to make: I do remember the for loop from mbopal/mbemerald, so sorry
//bout that, I have a photographic memory, so I knew about the specific path :P
//

//--- OBJECT WRITE BEGIN ---
new GuiControl(MarbleSelectorDlg) {
profile = GuiDefaultProfile;
horizSizing = center;
vertSizing = center;
position = -1 44;
extent = 641 392;
minExtent = 8 8;
visible = 1;
helpTag = 0;

new GuiBitmapCtrl() {
profile = GuiDefaultProfile;
horizSizing = center;
vertSizing = center;
position = 15 10;
extent = 400 280;
minExtent = 8 8;
visible = 1;
helpTag = 0;
bitmap = common/ui/dialog;
wrap = 0;

new GuiScrollCtrl() {
profile = GuiScrollProfile;
horizSizing = right;
vertSizing = bottom;
position = 93 36;
extent = 209 129;
minExtent = 8 8;
visible = 1;
helpTag = 0;
willFirstRespond = 1;
hScrollBar = dynamic;
vScrollBar = alwaysOn;
constantThumbHeight = 0;
childMargin = 0 0;
defaultLineHeight = 15;

new GuiTextListCtrl(MarbleList) {
profile = GuiTextArrayProfile;
horizSizing = right;
vertSizing = bottom;
position = 2 2;
extent = 416 8;
minExtent = 8 8;
visible = 1;
helpTag = 0;
enumerate = 0;
resizeCell = 1;
columns = 0;
fitParentWidth = 1;
clipColumnText = 0;
noDuplicates = false;
};
};
new GuiBitmapButtonCtrl() {
profile = GuiButtonProfile;
horizSizing = right;
vertSizing = bottom;
position = 157 188;
extent = 77 58;
minExtent = 8 8;
visible = 1;
command = chooseMarble();;
helpTag = 0;
text = Choose;
groupNum = -1;
buttonType = PushButton;
repeatPeriod = 1000;
repeatDecay = 1;
bitmap = common/ui/ok;
};
};
};
//--- OBJECT WRITE END ---

function MarbleSelectorDlg::onWake(%this) {
//clear the list and then build it
MarbleList.clear();
%this.BuildList();
}

function MarbleSelectorDlg::BuildList(%this) {
MarbleList.clear();
%msfiles = 0;
//grab those files :D
for(%file = findFirstFile(marble/data/shapes/balls/*.dts); %file !$= ; %file = findNextFile(marble/data/shapes/balls*.dts)) {
%msfiles ++;
$MSF[%msfiles] = filebase(%file);
MarbleList.addRow(%msfiles, $MSF[%msfiles]);
}
}

function ChooseMarble() {
%id = MarbleList.getSelectedId();
%marble = MarbleList.getRowTextbyId(%id);
//check to see if a selection was made...
if(%marble !$= ) {
$pref::marbleshape = %marble;
echo(Marble Chosen: @ %marble @ .dts);
Canvas.popDialog(MarbleSelectorDlg);
} else
MessageBoxOk(Warning!, You did not select a marble! Please select a Marble!);
}

go to marble/client/init.cs

add the following line where the others are being exec'd

Code:exec(./ui/marbleselectordlg.gui);

now, go to marble/server/scripts/game.cs, and add this:

find function onMissionLoaded (near the top)

and add:

Code:%shape = $pref::marbleshape;
//checking for null....
if(%shape $= )
%shape = ball-superball;
defaultmarble.shapeFile = marble/data/shapes/balls/ @ %shape @ .dts;

Now, run your game to compile it, and enjoy!

NOTE: to add marbles, place the .dts in marble/data/shapes/balls

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Perishingflames
  • Perishingflames's Avatar
  • Offline
  • Senior Marbler
  • Senior Marbler
More
12 Aug 2011 18:29 #2 by Perishingflames
Replied by Perishingflames on topic Jeff's Custom Marble Selector!
How does this save the marble choice for subsequent launches?

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
12 Aug 2011 18:32 #3 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
well, it works as long as if you don't exit out of the game. When you exit, you will have the ball-superball.dts when you relaunch the exe. Maybe I should add a pref in there...

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
12 Aug 2011 20:51 #4 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
NOTE: *Andrew gave me permission to double post*

Hey folks, just wanted to say that I updated the marble selector, so now the marble you use will now be saved to your prefs file! So, if you downloaded this script already, redownload the whole thing again! (except for the execution of the script, cause that remained the same!)

Thanks guys, for always being supportive!

Jeff

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Perishingflames
  • Perishingflames's Avatar
  • Offline
  • Senior Marbler
  • Senior Marbler
More
12 Aug 2011 21:54 #5 by Perishingflames
Replied by Perishingflames on topic Jeff's Custom Marble Selector!
Nice. So that just uses one datablock then since you're only changing the shape's location, right? Convenient.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
12 Aug 2011 22:20 #6 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
correct pf, just the defaultmarble datablock, and u change the shapefile when the mission loads

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar
  • Offline
  • Intermediate Marbler
  • Intermediate Marbler
  • Hi all
More
25 Jun 2012 05:48 #7 by Gary
Replied by Gary on topic Jeff's Custom Marble Selector!
i have a problem now....i add a button in playmissiongui in order to use the marbleselectordlg.gui,but it doesn't work this is the picture

HappyRoll Mod Leader
C++ Beginner

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar
  • Offline
  • Intermediate Marbler
  • Intermediate Marbler
  • Hi all
More
25 Jun 2012 09:10 #8 by Gary
Replied by Gary on topic Jeff's Custom Marble Selector!
ok...i solved this ploblem~
Code:command = Canvas.pushDialog(marbleselectordlg);;
hah~

HappyRoll Mod Leader
C++ Beginner

Please Log in or Create an account to join the conversation.

More
25 Jun 2012 14:28 #9 by Addict
Replied by Addict on topic Jeff's Custom Marble Selector!
Do you know how to code?

Please Log in or Create an account to join the conversation.

  • Gary
  • Gary's Avatar
  • Offline
  • Intermediate Marbler
  • Intermediate Marbler
  • Hi all
More
26 Jun 2012 04:22 #10 by Gary
Replied by Gary on topic Jeff's Custom Marble Selector!
Sorry.I don't know how to code.

HappyRoll Mod Leader
C++ Beginner

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
26 Jun 2012 04:36 #11 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
@forfun congrats for figuring it out! Im sorry i wasn't paying attention enough to this board to help ya out. Still, its good to see that people figure things out themselves sometimes =)

If you have any questions or anything as always feel free to pm me =)

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • LegoCreator768
  • LegoCreator768's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Always on technology
More
03 Aug 2013 06:07 #12 by LegoCreator768
Replied by LegoCreator768 on topic Jeff's Custom Marble Selector!
The Okay button doesn't work.

Here's the error report.

>>> Advanced script error report. Line 803.
>>> Some error context, with ## on sides of error halt:
%marbleSkin = convertToFileBase($Pref::MarbleSelection);

%this.player.setSkinName(%marbleSkin);

}



function ##G##ameConnection::onClientLeaveGame(%this)

{

if (isObject(%this.camera))
>>> Error report complete.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
06 Aug 2013 21:24 #13 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
that means your missing a } somewhere.

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • LegoCreator768
  • LegoCreator768's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Always on technology
More
25 Aug 2013 18:50 #14 by LegoCreator768
Replied by LegoCreator768 on topic Jeff's Custom Marble Selector!
Ok button now works, but yet another error report...
Here it is:

marble/server/scripts/game.cs Line: 403 - Syntax error
%marbleSkin = convertToFileBase($Perf::MarbleSelection);
%this.player.setSkinName(%marbleSkin);
}

function ##G##ameConnection::onClientLeaveGame(%this)
{
if (isObject(%this.camera))
>>> Error report complete.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
25 Aug 2013 19:09 #15 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
Can't determine with that much script, need more of it.
Also, you misspelled something:

%marbleSkin = convertToFileBase($Perf::MarbleSelection);

$pref

that won't cause a syntax error, but that's another problem.

Provide more script please. Open game.cs go to like line 320 and post from that to like line 420

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Enigma
  • Enigma's Avatar
  • Offline
  • Advanced Marbler
  • Advanced Marbler
  • tubularly dank marble memes
More
01 Oct 2013 02:50 #16 by Enigma
Replied by Enigma on topic Jeff's Custom Marble Selector!
Hate to bump, but whatever:
I can't find the function onMissionLoaded in game.cs. Here's the full file:
Code://
// Torque Game Engine
//
// Copyright (c) 2001 GarageGames.Com
//

//
// Game start / end events sent from the server
//

function clientCmdGameStart()
{
}

function getBestTimes(%mis)
{
for(%i = 0; %i < 3; %i++)
{
$hs[%i] = $pref::highScores[%mis, %i];
if($hs[%i] $= )
{
if(MissionInfo.time)
$hs[%i] = MissionInfo.time @ \tNardo Polo;
else
$hs[%i] = 5998999\tNardo Polo;
}
}
}

function clientCmdGameEnd()
{
if($playingDemo)
return;

getBestTimes($Server::MissionFile);
$highScoreIndex = ;
for(%i = 0; %i < 3; %i++)
{
if($Game::ScoreTime < getField($hs[%i], 0))
{
for(%j = 2; %j > %i; %j--)
{
$hs[%j] = $hs[%j - 1];
}
$highScoreIndex = %i;
$hs[%i] = $Game::ScoreTime @ \t @ $pref::highScoreName;
break;
}
}
reformatGameEndText();
Canvas.pushDialog(EndGameGui);
if($highScoreIndex !$= )
{
if($highScoreIndex == 0)
%msgIn = ;
else if($highScoreIndex == 1)
%msgIn = 2nd;
else
%msgIn = 3rd;
EnterNameText.setText(<just:center><font:Expo:50>Congratulations!\n<font:DomCasualD:32>You got the @ %msgIn @ best time!);
Canvas.pushDialog(EnterNameDlg);
EnterNameEdit.setSelectionRange(0, 100000);
}
}

function highScoreNameAccept()
{
Canvas.popDialog(EnterNameDlg);
for(%i = 0; %i < 3; %i++)
$pref::highScores[$Server::MissionFile, %i] = $hs[%i];
}

function highScoreNameChanged()
{
$hs[$highScoreIndex] = $Game::ScoreTime @ \t @ $pref::highScoreName;
reformatGameEndText();
}

function reformatGameEndText()
{
// Final Score
%text =
<shadow:1:1><tab:240,250> @
<font:Expo:50><color:ffff00>Final Time:\t<color:fff090> @
formatTime($Game::ScoreTime) @ <color:000000><font:Expo:32>\n<just:center>;

// Qualification time
if($Game::Qualified)
{
%text = %text @ <color:00ff00> @ ((MissionInfo.goldTime && $Game::ScoreTime < MissionInfo.goldTime) ?
You beat the <color:ffff00>GOLD<color:00ff00> time! : You've qualified!);
}
else
%text = %text @ <color:ff0000>You failed to qualify!;

// Basic time info
%text = %text @
\n<just:left><font:Arial:14>\n<lmargin:65><tab:235,245><shadowcolor:ffffff7f><shadow:1:1>;
if (MissionInfo.time)
%text = %text @
<color:000000> @
<font:DomCasualD:32>Qualify Time:\t @
($Game::Qualified? <shadowcolor:ffffff7f><color:000000>: <shadowcolor:0000007f><color:ff0000>) @
formatTime(MissionInfo.time) @ \n;
else
%text = %text @ <color:000000><font:DomCasualD:32>Qualify Time:\t\t99:59.99\n;

if(MissionInfo.goldTime)
{
%text = %text @ <shadowcolor:ffffff7f><color:000000><font:DomCasualD:32>Gold Time:\t<color:FFFF00><shadowcolor:0000007f> @
formatTime(MissionInfo.goldTime) @ \n;
}

%text = %text @
<shadowcolor:ffffff7f><color:000000> @
<font:DomCasualD:32>Elapsed Time:\t @ formatTime($Game::ElapsedTime) @ \n @
<font:DomCasualD:32>Bonus Time:\t @ formatTime($Game::BonusTime) @ \n;
%text = %text @ <font:Arial:14>\n<font:DomCasualD:32><color:000000>Best Times:\n;
for(%i = 0; %i < 3; %i++)
{
%time = getField($hs[%i], 0);
%name = getField($hs[%i], 1);
%text = %text
@ <shadowcolor:ffffff7f><color:000000><font:DomCasualD:32> @ %i+1 @ . @ %name @ \t
@ (%time < MissionInfo.goldTime ? <shadowcolor:0000007f><color:ffff00> : ) @ formatTime(%time) @ \n;
}
// Display the end-game screen
EndGameGuiDescription.setText(%text);
}


//

function formatTime(%time)
{
%isNeg = \t;
if (%time < 0)
{
%time = -%time;
%isNeg = -\t;
}
%hundredth = mFloor((%time % 1000) / 10);
%totalSeconds = mFloor(%time / 1000);
%seconds = %totalSeconds % 60;
%minutes = (%totalSeconds - %seconds) / 60;

%secondsOne = %seconds % 10;
%secondsTen = (%seconds - %secondsOne) / 10;
%minutesOne = %minutes % 10;
%minutesTen = (%minutes - %minutesOne) / 10;
%hundredthOne = %hundredth % 10;
%hundredthTen = (%hundredth - %hundredthOne) / 10;

return %isNeg @ %minutesTen @ %minutesOne @ : @
%secondsTen @ %secondsOne @ . @
%hundredthTen @ %hundredthOne;
}

A journey of ten thousand miles begins with a single... Er... Call to a travel agent.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
01 Oct 2013 03:16 #17 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
marble/server/scripts/game.cs

what you posted is client game.cs

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Enigma
  • Enigma's Avatar
  • Offline
  • Advanced Marbler
  • Advanced Marbler
  • tubularly dank marble memes
More
01 Oct 2013 03:26 #18 by Enigma
Replied by Enigma on topic Jeff's Custom Marble Selector!
Sept 30, 2013, 8:16pm, jeff wrote:marble/server/scripts/game.cs

what you posted is client game.cs
Oh sorry! Thanks for the pointout!

EDIT: Where exactly is the selector? I'm guessing it's in the menu or pause menu? Also: to work does the balls folder have to have more than one marble for the selector to show up on the screen?

A journey of ten thousand miles begins with a single... Er... Call to a travel agent.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Developer
  • Developer
  • PlatinumQuest Programmer
More
01 Oct 2013 03:35 #19 by Jeff
Replied by Jeff on topic Jeff's Custom Marble Selector!
1. no where
2. u have to code that yourself
3. yes you should use the custom skin selector if you only want 1 dts shape (see that thread)

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

Moderators: AayrlKalle29Regislian