Marble Blast Forums
« Changing the Marble Size In Game :D »

Welcome Guest. Please Login or Register.
May 25, 2013, 9:22pm


Marble Blast Forums


Marble Blast Forums :: Marble Blast Modifications Zone :: Marble Blast Development Kit :: Codes :: Changing the Marble Size In Game :D
   [Search This Thread] [Share Topic] [Print]
 AuthorTopic: Changing the Marble Size In Game :D (Read 887 times)
Jeff
Elite Marbler
*****
torqueScript maniac[ss:Default Skin]
member is offline



MBP Leaderboard Moderator.



Joined: Nov 2010
Gender: Male
Posts: 1,559
Location: Kicking people from LBs...
 Changing the Marble Size In Game :D
« Thread Started on Nov 16, 2011, 1:01pm »

Well, this will work for both big marble and small marble, but its not in powerup form. This weekend, I will release a video of me coding it in Powerup format.

Anyways, add this code to marble.cs:

Code:
datablock MarbleData(BigMarbleSize : DefaultMarble) {
shapeFile = "~/data/shapes/balls/Big Marble.dts";
};

datablock MarbleData(SmallMarbleSize : DefaultMarble) {
shapeFile = "~/data/shapes/balls/Small Marble.dts";
};

function changeMarbleSize(%marble) {
if(!isObject(LocalClientConnection.player))
return;
localClientConnection.player.setDatablock(%marble);
}


When u want to change the Datablock in game, just call this method:

Code:
changeMarbleSize("datablock name you choose");


(name must be in quotes, no acceptions)

This is unreliable since you have to have a big marble dts or a small marble dts, but for now, its all we got, unless if somehow i can get the scale to work.

Enjoy guys!

Jeff

PS. To revert the marble, make the datablock parameter defaultmarble
« Last Edit: Nov 16, 2011, 1:04pm by Jeff »Link to Post - Back to Top  IP: Logged

[image]
Hi Guy‮
Expert Marbler
****
TorqueScript Hacking Maniac[ss:Blue Groove (MF)]
member is offline

[avatar]

If you can see my avatar, then my server is still functioning.



Joined: Mar 2008
Gender: Male
Posts: 610
Location: Both nowhere and everywhere...
 Re: Changing the Marble Size In Game :D
« Reply #1 on Nov 17, 2011, 11:06am »

Very nice. Could be useful for more MBO mega-marble style things.
Link to Post - Back to Top  IP: Logged

Definitely On-Topic MBP Coding
[image]
Jeff
Elite Marbler
*****
torqueScript maniac[ss:Default Skin]
member is offline



MBP Leaderboard Moderator.



Joined: Nov 2010
Gender: Male
Posts: 1,559
Location: Kicking people from LBs...
 Re: Changing the Marble Size In Game :D
« Reply #2 on Nov 17, 2011, 11:10am »

i will be doing a video this weekend on intigrating it into a powerup :).

Just for you Higuy, lol.
Link to Post - Back to Top  IP: Logged

[image]
NaCl586
Professional Marbler
***
Searching Stolen Seven Gems[ss:Phil'sEmpire Skin]
member is offline

[avatar]

MBElite Level and Skybox Designer

[msn]

Joined: Jul 2010
Gender: Female
Posts: 485
Location: Depends where I am now
 Re: Changing the Marble Size In Game :D
« Reply #3 on Nov 17, 2011, 6:26pm »

Thank you jeff, i may able to code it on powerup form. but im not sure, im bad programmer. BTW what I've said on MSN is correct? MBAdventure always use MBDK code so only less possibility for me to called as a code robber.

EDIT:
That code is cursed and dont work properly.

See this code
Code:
datablock AudioProfile(PuMegaMarbleSfx)
{
filename = "~/data/sound/spawn.wav";
description = AudioDefault3d;
preload = true;
};

datablock ItemData(MegaMarble) {
// Mission editor category
category = "Powerups";
className = "PowerUp";
powerUpId = 6;

activeAudio = PuMegaMarbleSfx; //change to the audio root!
pickupAudio = PuMegaMarbleSfx; //change to the pickup audio root!

// Basic Item properties
shapeFile = "~/data/shapes/balls/BigMarble.dts"; //path of the shapefile
mass = 1;
friction = 1;
elasticity = 0.3;
emap = false;

// Dynamic properties defined by the scripts
pickupName = "a Mega Marble Powerup!";
useName = "";
maxInventory = 1;
};

function MegaMarble::onUse(%this,%marble) {

changeMarbleSize("BigMarbleSize");

schedule(10000, 0, "undoMegaMarble");
}

function undoMegaMarble() {

changeMarbleSize("DefaultMarbleSize");

}


And
Code:
datablock MarbleData(BigMarbleSize) {
shapeFile = "~/data/shapes/balls/BigMarble.dts";
};

datablock MarbleData(SmallMarbleSize) {
shapeFile = "~/data/shapes/balls/SmallMarble.dts";
};

datablock MarbleData(DefaultMarbleSize) {
shapeFile = "~/data/shapes/balls/ball-superball.dts";
};

function changeMarbleSize(%marble) {
if(!isObject(LocalClientConnection.player))
return;
localClientConnection.player.setDatablock(%marble);
}


I know whats the mistake. Ah i must copy all codes from teh defaultmarble datablock. Aw man, That 100 line of code that mato said is just a COPY PASTE!
I give up.
« Last Edit: Nov 17, 2011, 7:36pm by NaCl586 »Link to Post - Back to Top  IP: Logged

2.05, 2.63, 7.47
7s count : 51
~NaCl586~
Hi Guy‮
Expert Marbler
****
TorqueScript Hacking Maniac[ss:Blue Groove (MF)]
member is offline

[avatar]

If you can see my avatar, then my server is still functioning.



Joined: Mar 2008
Gender: Male
Posts: 610
Location: Both nowhere and everywhere...
 Re: Changing the Marble Size In Game :D
« Reply #4 on Nov 18, 2011, 7:12am »

Actually, what you forgot was the ": DefaultMarble" section in the BigMarbleSize datablock definition. Watered-down version:


Quote:
datablock MarbleData(BigMarbleSize : DefaultMarble) {
shapeFile = "~/data/shapes/balls/BigMarble.dts";
};

datablock MarbleData(SmallMarbleSize : DefaultMarble) {
shapeFile = "~/data/shapes/balls/SmallMarble.dts";
};

datablock MarbleData(DefaultMarbleSize : DefaultMarble) {
shapeFile = "~/data/shapes/balls/ball-superball.dts";
};

function changeMarbleSize(%marble) {
if(!isObject(LocalClientConnection.player))
return;
localClientConnection.player.setDatablock(%marble);
}


:)
Link to Post - Back to Top  IP: Logged

Definitely On-Topic MBP Coding
[image]
Jeff
Elite Marbler
*****
torqueScript maniac[ss:Default Skin]
member is offline



MBP Leaderboard Moderator.



Joined: Nov 2010
Gender: Male
Posts: 1,559
Location: Kicking people from LBs...
 Re: Changing the Marble Size In Game :D
« Reply #5 on Nov 18, 2011, 7:12am »


Nov 17, 2011, 11:10am, Jeff wrote:
i will be doing a video this weekend on intigrating it into a powerup :).

Just for you Higuy, lol.


How many more free post counds will i get?

argh, ninga'd by Higuy -.-
« Last Edit: Nov 18, 2011, 7:13am by Jeff »Link to Post - Back to Top  IP: Logged

[image]
NaCl586
Professional Marbler
***
Searching Stolen Seven Gems[ss:Phil'sEmpire Skin]
member is offline

[avatar]

MBElite Level and Skybox Designer

[msn]

Joined: Jul 2010
Gender: Female
Posts: 485
Location: Depends where I am now
 Re: Changing the Marble Size In Game :D
« Reply #6 on Nov 18, 2011, 7:51pm »

@jeff, im trying to beat you before you do that code.
@higuy and jeff: so the code will be "changeMarbleSize("BigMarbleSize : DefaultMarble"); ?
Link to Post - Back to Top  IP: Logged

2.05, 2.63, 7.47
7s count : 51
~NaCl586~
Jeff
Elite Marbler
*****
torqueScript maniac[ss:Default Skin]
member is offline



MBP Leaderboard Moderator.



Joined: Nov 2010
Gender: Male
Posts: 1,559
Location: Kicking people from LBs...
 Re: Changing the Marble Size In Game :D
« Reply #7 on Nov 19, 2011, 6:03am »

no, thats only used as a child datablock, think of defaultmarble as a parent, and its children are bigmarble and small marble, u would just call big, small, or default marble, u dont use that syntax :P

Also, because you did that, I had to go fix mbelite cause it kept crashing, so thanks :P
« Last Edit: Nov 19, 2011, 6:04am by Jeff »Link to Post - Back to Top  IP: Logged

[image]
Jeff
Elite Marbler
*****
torqueScript maniac[ss:Default Skin]
member is offline



MBP Leaderboard Moderator.



Joined: Nov 2010
Gender: Male
Posts: 1,559
Location: Kicking people from LBs...
 Re: Changing the Marble Size In Game :D
« Reply #8 on Nov 19, 2011, 7:34am »

Excuse the double post:

here is the guts of the powerup edition to the codes, if you want the full thing, you have to watch the 3 part video series on my youtube, which will be here within a few hours (its 3GB worth of footage :P).

heres the guts:

Code:
//-----------------------------------------------------------------------------
// Marble Changing Items by Jeff Hutchinson
//-----------------------------------------------------------------------------

datablock MarbleData(BigMarble : DefaultMarble) {
shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed
};

datablock MarbleData(SmallMarble : DefaultMarble) {
shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed
};

function switchMarble(%powerup) {
if(!isObject(LocalClientConnection.player))
     return warn("Warning, there is no local client!");
    //which powerup will we be choosing, hmmmm
%returnval = "defaultMarble";
switch$ (%powerup) {
case "BigMarble":
     localClientConnection.player.SetDatablock("BigMarble");
schedule(5000, 0, "SwitchMarble", %returnval);        
case "SmallMarble" :
     localClientConnection.player.SetDatablock("SmallMarble");    
schedule(5000, 0, "SwitchMarble", %returnval);    //5000 is time in miliseconds... till reloop :)        
     case "DefaultMarble" :
     localClientConnection.player.SetDatablock("DefaultMarble");         
     default :
        return warn("Warning, the shape does not exist!"); //echo to the console displaying the error message...
}
}

//-----------------------------------------------------------------------------
// Powerup stuff now :D
//-----------------------------------------------------------------------------

datablock ItemData(BigMarbleItem) {
category = "Powerups";
className = "PowerUp";
shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed
emap = false; //we dont want reflection here..., unless u want it :P
pickupName = "a Big Marble Powerup!";
powerupId = 6;
};

datablock ItemData(SmallMarbleItem) {
category = "Powerups";
className = "PowerUp";
shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed
emap = false; //we dont want reflection here..., unless u want it :P
pickupName = "a Small Marble Powerup!";
powerupId = 7;
};

function BigMarbleItem::ondeploy(%this, %obj) {
switchMarble("BigMarble"); //see that method above, now it comes in handy :)
}

function SmallMarbleItem::ondeploy(%this, %obj) {
switchMarble("SmallMarble"); //see that method above, not it really comes in handy :)
}
Link to Post - Back to Top  IP: Logged

[image]
Gary
Beginner Marbler
*
[ss:Prolassic]
member is offline

[avatar]

i am Forfun before i get the English name

[msn]

Joined: Jan 2012
Gender: Male
Posts: 58
Location: China
 Re: Changing the Marble Size In Game :D
« Reply #9 on Jun 9, 2012, 8:56pm »


Nov 19, 2011, 7:34am, Jeff wrote:
Excuse the double post:

here is the guts of the powerup edition to the codes, if you want the full thing, you have to watch the 3 part video series on my youtube, which will be here within a few hours (its 3GB worth of footage :P).

heres the guts:

Code:
//-----------------------------------------------------------------------------
// Marble Changing Items by Jeff Hutchinson
//-----------------------------------------------------------------------------

datablock MarbleData(BigMarble : DefaultMarble) {
shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed
};

datablock MarbleData(SmallMarble : DefaultMarble) {
shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed
};

function switchMarble(%powerup) {
if(!isObject(LocalClientConnection.player))
     return warn("Warning, there is no local client!");
    //which powerup will we be choosing, hmmmm
%returnval = "defaultMarble";
switch$ (%powerup) {
case "BigMarble":
     localClientConnection.player.SetDatablock("BigMarble");
schedule(5000, 0, "SwitchMarble", %returnval);        
case "SmallMarble" :
     localClientConnection.player.SetDatablock("SmallMarble");    
schedule(5000, 0, "SwitchMarble", %returnval);    //5000 is time in miliseconds... till reloop :)        
     case "DefaultMarble" :
     localClientConnection.player.SetDatablock("DefaultMarble");         
     default :
        return warn("Warning, the shape does not exist!"); //echo to the console displaying the error message...
}
}

//-----------------------------------------------------------------------------
// Powerup stuff now :D
//-----------------------------------------------------------------------------

datablock ItemData(BigMarbleItem) {
category = "Powerups";
className = "PowerUp";
shapeFile = "~/data/shapes/balls/Big Marble.dts"; //to be changed if needed
emap = false; //we dont want reflection here..., unless u want it :P
pickupName = "a Big Marble Powerup!";
powerupId = 6;
};

datablock ItemData(SmallMarbleItem) {
category = "Powerups";
className = "PowerUp";
shapeFile = "~/data/shapes/balls/Small Marble.dts"; //to be changed if needed
emap = false; //we dont want reflection here..., unless u want it :P
pickupName = "a Small Marble Powerup!";
powerupId = 7;
};

function BigMarbleItem::ondeploy(%this, %obj) {
switchMarble("BigMarble"); //see that method above, now it comes in handy :)
}

function SmallMarbleItem::ondeploy(%this, %obj) {
switchMarble("SmallMarble"); //see that method above, not it really comes in handy :)
}

Sorry.I don't know which file should i edit...the“marble.cs”or “powerup.cs”?
i tried to copy this code to both marble.cs and powerup.cs,i can see the powerups,but it doesn't work.
(my marble.cs and powerup.cs are in the Attachment)

Please login to download attachments.
Link to Post - Back to Top  IP: Logged

HapyRoll Level Builder and GUI designer.
------------
I love ballance and marble blast~
I love ballance costum levels and marble blast costum levels~
I'm from China and My English is not good.
So.So if there is grammatical mistakes, please forgive me (^.^)

Look~a video of the costum level Gem Gallery(without easteregg)
--click here--
Jeff
Elite Marbler
*****
torqueScript maniac[ss:Default Skin]
member is offline



MBP Leaderboard Moderator.



Joined: Nov 2010
Gender: Male
Posts: 1,559
Location: Kicking people from LBs...
 Re: Changing the Marble Size In Game :D
« Reply #10 on Jun 10, 2012, 2:00am »

You need to install HiGuy's custom powerup tutorial thing, so that these new powerups will take effect. The problem is without this hack, the engine thinks that you are trying to use an origional powerup, and not a normal one, so it just does nothing. Install this first, then come back for help if it still does not work:

http://marbleblast.com/index.cgi?board=mbdkcode&action=display&thread=11902
Link to Post - Back to Top  IP: Logged

[image]
whirligig
Intermediate Marbler
**
member is offline





Joined: Dec 2009
Gender: Male
Posts: 114
 Re: Changing the Marble Size In Game :D
« Reply #11 on Jun 10, 2012, 10:46am »

Note: you may want to apply an impulse to the marble when increasing its size (otherwise it can get stuck in the floor). This is a more complicated process than it might seem (as the normal applyImpulse is glitched; you have to mess around with server objects). I'm not sure if an applyImpulse fix has been posted on this forum.
Link to Post - Back to Top  IP: Logged
Hi Guy‮
Expert Marbler
****
TorqueScript Hacking Maniac[ss:Blue Groove (MF)]
member is offline

[avatar]

If you can see my avatar, then my server is still functioning.



Joined: Mar 2008
Gender: Male
Posts: 610
Location: Both nowhere and everywhere...
 Re: Changing the Marble Size In Game :D
« Reply #12 on Jun 11, 2012, 12:45pm »

*Takes the bait* I will post one shortly :)
Link to Post - Back to Top  IP: Logged

Definitely On-Topic MBP Coding
[image]
Gary
Beginner Marbler
*
[ss:Prolassic]
member is offline

[avatar]

i am Forfun before i get the English name

[msn]

Joined: Jan 2012
Gender: Male
Posts: 58
Location: China
 Re: Changing the Marble Size In Game :D
« Reply #13 on Jun 15, 2012, 8:49pm »


Jun 10, 2012, 2:00am, Jeff wrote:
You need to install HiGuy's custom powerup tutorial thing, so that these new powerups will take effect. The problem is without this hack, the engine thinks that you are trying to use an origional powerup, and not a normal one, so it just does nothing. Install this first, then come back for help if it still does not work:

http://marbleblast.com/index.cgi?board=mbdkcode&action=display&thread=11902


ok..i will try..thanks~
Link to Post - Back to Top  IP: Logged

HapyRoll Level Builder and GUI designer.
------------
I love ballance and marble blast~
I love ballance costum levels and marble blast costum levels~
I'm from China and My English is not good.
So.So if there is grammatical mistakes, please forgive me (^.^)

Look~a video of the costum level Gem Gallery(without easteregg)
--click here--
   [Search This Thread] [Share Topic] [Print]

Click Here To Make This Board Ad-Free


This Board Hosted For FREE By ProBoards
Get Your Own Free Message Boards & Free Forums!
Terms of Service | Privacy Policy | Notice | FTC Disclosure | Report Abuse | Mobile