file Jeff's Custom Marble Selector!

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
12 Aug 2011 17:53 #1
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
  • Posts: 882
  • Thank you received: 21
12 Aug 2011 18:29 #2
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
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
12 Aug 2011 18:32 #3
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
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
12 Aug 2011 20:51 #4
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
  • Posts: 882
  • Thank you received: 21
12 Aug 2011 21:54 #5
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
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
12 Aug 2011 22:20 #6
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
  • Posts: 80
  • Thank you received: 8
25 Jun 2012 05:48 #7
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
  • Posts: 80
  • Thank you received: 8
25 Jun 2012 09:10 #8
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.

  • Posts: 226
  • Thank you received: 0
25 Jun 2012 14:28 #9
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
  • Posts: 80
  • Thank you received: 8
26 Jun 2012 04:22 #10
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
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
26 Jun 2012 04:36 #11
@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
  • Posts: 148
  • Thank you received: 19
03 Aug 2013 06:07 #12
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
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
06 Aug 2013 21:24 #13
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
  • Posts: 148
  • Thank you received: 19
25 Aug 2013 18:50 #14
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
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
25 Aug 2013 19:09 #15
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.

  • Posts: 238
  • Thank you received: 17
01 Oct 2013 02:50 #16
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;
}

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

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
01 Oct 2013 03:16 #17
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.

  • Posts: 238
  • Thank you received: 17
01 Oct 2013 03:26 #18
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?

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

  • Jeff
  • Jeff's Avatar Topic Author
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
01 Oct 2013 03:35 #19
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: Doomblah
Time to create page: 1.515 seconds
We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.