file Basic Marble Blast Coding Q&A

  • Beack
  • Beack's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
  • Beack ewe
  • Posts: 477
  • Thank you received: 0
01 Feb 2011 02:18 #121
Forget my sky questuion, but there is a way to change the font of the Help trigger, messages, etc, I found that in a MBR video I want do the same with the messages

The weirdest signature that I ever requested

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
01 Feb 2011 02:24 #122
@stall

I would think it is possible.

The following code that I posted is not for ids but should answer some questions. HiGuy or Spy47 (or Phil), could you please look at this and tell me if this would work:

Note that this is only for the landmine. This is not the full script. Not guarentteed to work. I am only guessing. I just copied and pasted from other scripts

You would need:

datablock TriggerData(CaboomTrigger)
{
tickPeriodMS = 100;
};

function CaboomTrigger::onEnterTrigger(%this,%trigger,%obj)
{
//This is what happens when you enter the trigger

function LandMine::onCollision(%this, %obj, %col)
{
%obj.setDamageState(Destroyed);

%resetTime = (%obj.resetTime $= Default)? %this.resetTime: %obj.resetTime;
if (%resetTime) {
%obj.startFade(0, 0, true);
%obj.schedule(%resetTime, setDamageState,Enabled);
%obj.schedule(%resetTime, startFade, 1000, 0, false);
}
}
}

At beack

This is just a guess:

datablock TriggerData(Help2Trigger)
{
tickPeriodMS = 100;
};

function Help2Trigger::onEnterTrigger(%this,%trigger,%obj)
{
// Leaving an in bounds area.
addHelpLine(%trigger.text, true);
displaytext<font:DomCasualD:32><color:ffff00>;
}

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
01 Feb 2011 02:38 #123
For the landmine, that doesn't look like it would work at all lol

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
01 Feb 2011 02:40 #124
PF, its just a guess. I am not the greatest coder in the world. I just know some stuff.

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: 227
  • Thank you received: 0
01 Feb 2011 03:26 #125
The ID idea was to make it easier to delay the times of land mine explosions so they didn't all go off at once, by adding a bunch of schedule lines. Fans etc have both an on and off state I think, should be able to switch. However in any case, level with code doesn't work. Also how is it supposed to work? It triggers all the land mines in the level?

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

  • Posts: 20
  • Thank you received: 0
01 Feb 2011 04:02 #126
Jan 31, 2011, 3:18pm, mbgdemon wrote:Trigger.
@Phil execute code every time in increments?

Figured a trigger would work, just think itd be a lot of effort to add triggers to every surface of the level, so was looking for a more scriptable solution.

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
01 Feb 2011 04:04 #127
As far as I know, triggers are the only way to go. Sorry Picklecow.

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: 484
  • Thank you received: 1
01 Feb 2011 14:04 #128
Jan 31, 2011, 3:18pm, mbgdemon wrote:Trigger.
@Phil execute code every time in increments?
Yeah you could, but the marble would just constantly jump (basically the same effect of incrementing the variable once but just a bit weirder)


Quote:Note that this is only for the landmine. This is not the full script. Not guarentteed to work. I am only guessing. I just copied and pasted from other scripts

You would need:

datablock TriggerData(CaboomTrigger)
{
tickPeriodMS = 100;
};

function CaboomTrigger::onEnterTrigger(%this,%trigger,%obj)
{
//This is what happens when you enter the trigger

function LandMine::onCollision(%this, %obj, %col)
{
%obj.setDamageState(Destroyed);

%resetTime = (%obj.resetTime $= Default)? %this.resetTime: %obj.resetTime;
if (%resetTime) {
%obj.startFade(0, 0, true);
%obj.schedule(%resetTime, setDamageState,Enabled);
%obj.schedule(%resetTime, startFade, 1000, 0, false);
}
}
}

You can't 'nest' functions within another function... it doesn't make any sense. Instead you could do something like this in ::onEnterTrigger():

Code:function CaboomTrigger::onEnterTrigger(%this, %trigger, %obj)
{
// Replace <landMineReference> with the name of the mine or a variable if you created it from script
<landMineReference>.setDamageState(Destroyed); // This causes the mine to blow up, and you can get affected by it if you're near it (not directly touching it!)

// For it to reappear, we'll just schedule it to happen whenever
<landMineReference>.schedule(<timeInMS>, setDamageState, Enabled);
}


(egh why does the forum kill the indentation of the code)


Quote:Anyone know a way to run a function whenever the marble hits the ground?
I had the same problem... as far as I know there doesn't seem to be any kind of onCollision() callback for an InteriorInstance (though it does exist for StaticShapes).

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

  • Posts: 20
  • Thank you received: 0
03 Feb 2011 10:32 #129
Damn.

OK, how about a way to tell if the marble is falling?
Just some way to determine if it's heading up or down...

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

  • Posts: 122
  • Thank you received: 0
03 Feb 2011 12:55 #130
compare the z variable's value each frame?

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

  • dobrakmato
  • dobrakmato's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 134
  • Thank you received: 0
03 Feb 2011 21:41 #131
How to save the file prefs.cs string and then also the value of it to load?

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
04 Feb 2011 00:25 #132
Off topic: your english is hard to understand

If I am correct, if I may say, it should be because it is somehow set to a command that it is either true (1) or false (0).

Also, thanks for the advice Phil about not to nest functions. I did not know that

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.

  • Marblemaster1
  • Marblemaster1's Avatar
  • Offline
  • Advanced Marbler
  • Advanced Marbler
  • Custom Code Enthusiast
  • Posts: 237
  • Thank you received: 8
04 Feb 2011 03:36 #133
Hi, I gotta problem.

I've been trying to make a powerup that makes you immune to all hazards for a few seconds. Right now, it's supposed to make you invincible forever, because I haven't gotten it to wear off yet. It shows up in MB fine, but as soon as I touch it, my C++ compiler (which is not open at the time) gives me an error message, asking if I want to debug it. I choose yes and the C++ compiler opens but nothing happens, I choose no and MB closes. WTF?
Here's the code:
Code:datablock ItemData(InvinciMarbleItem)
{
category = Powerups;
className = PowerUp;
powerUpId = 6;

pickupAudio = PuAntiGravityVoiceSfx;
pickupName = an InvinciMarble PowerUp!;

shapeFile = ~/data/shapes/items/InvinciMarble.dts;

mass = 1;
friction = 1;
elasticity = 0.3;
emap = false;

maxInventory = 1;
};

function InvinciMarbleItem::onAdd(%this,%obj)
{
%obj.playThread(0,Ambient);
}

function InvinciMarbleItem::onPickup(%this,%obj,%user,%amount)
{
PlayGui.setPowerup(InvinciMarbleItem);
}

function InvinciMarbleItem::onPowerUpUsed(%obj)
{
DuctFan.forceStrength[0] = 0;
SmallDuctFan.forceStrength[0] = 0;
Tornado.forceStrength[0] = 0;
Tornado.forceStrength[1] = 0;
Tornado.forceStrength[2] = 0;
LandMineExplosion.ImpulseForce = 0;
}

QuArK is still a good map editor

You know what's boring? Opaque marble skins. You know what's not? Glass Marbles!

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
04 Feb 2011 04:19 #134
I believe you have to set the powerup id in the marbles.cs file. Also, why in c++. Marble blast runs off of torque script and torque script is c#. so, make sure your file extension is .cs (thats if it is a seperate file)

If it is a seperate file:

Please execute it in the init so that the game know to execute the code. The game will automatically compile it if it is a seperate file.

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.

  • Marblemaster1
  • Marblemaster1's Avatar
  • Offline
  • Advanced Marbler
  • Advanced Marbler
  • Custom Code Enthusiast
  • Posts: 237
  • Thank you received: 8
04 Feb 2011 04:27 #135
Let's see...
I did set the powerup id in the marble.cs file (I think).
Weird, because my C++ compiler opens, and on the GG website, it says that Torque script is based off of C++.

QuArK is still a good map editor

You know what's boring? Opaque marble skins. You know what's not? Glass Marbles!

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
04 Feb 2011 04:31 #136
let me look over it again... (will replay ~5mins or less)

btw, is it in powerups.cs or a seperate file?

You forgot to end the datablock with a ;

the last bracket of the datablock in its intierity needs a ;

try this:

datablock ItemData(InvinciMarbleItem)
{
category = Powerups;
className = PowerUp;
powerUpId = 6;

pickupAudio = PuAntiGravityVoiceSfx;
pickupName = an InvinciMarble PowerUp!;

shapeFile = ~/data/shapes/items/InvinciMarble.dts;

mass = 1;
friction = 1;
elasticity = 0.3;
emap = false;

maxInventory = 1;

function InvinciMarbleItem::onAdd(%this,%obj)
{
%obj.playThread(0,Ambient);
}

function InvinciMarbleItem::onPickup(%this,%obj,%user,%amount)
{
PlayGui.setPowerup(InvinciMarbleItem);
}

function InvinciMarbleItem::onPowerUpUsed(%obj)
{
DuctFan.forceStrength[0] = 0;
SmallDuctFan.forceStrength[0] = 0;
Tornado.forceStrength[0] = 0;
Tornado.forceStrength[1] = 0;
Tornado.forceStrength[2] = 0;
LandMineExplosion.ImpulseForce = 0;
}
};

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.

  • Marblemaster1
  • Marblemaster1's Avatar
  • Offline
  • Advanced Marbler
  • Advanced Marbler
  • Custom Code Enthusiast
  • Posts: 237
  • Thank you received: 8
04 Feb 2011 04:54 #137
Nope, doesn't work. It doesn't appear in the LE now. I don't think you're supposed to put functions in a datablock. Just a guess, though.

QuArK is still a good map editor

You know what's boring? Opaque marble skins. You know what's not? Glass Marbles!

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

  • Seizure22
  • Seizure22's Avatar
  • Offline
  • Intermediate Marbler
  • Intermediate Marbler
  • Posts: 79
  • Thank you received: 0
04 Feb 2011 05:19 #138
@Dobrák

You probably want a function of this sort (for an item):


(Use the item datablock name in place of DBNAME)

function DBNAME::onPickup(%this, %obj)
{
$pref::HAVEITEM = 1;
}


@picklecow10

Compare Z values to tell if the marble is falling. However, this isn't 100% accurate because of framelag (and the getvelocity function doesn't work).

To 80%+ solve your original problem, though, check for $testCount == 1. (This value can be from 0-1; generally, partial values can be seen when bouncing off a surface). This value equals 1 when the marble is rolling on a surface (any surface, including a flat wall). You can raycast down to check if there's an interior under the marble. However, this will not account for those weird jumps on edges that you can sometimes perform.




@jeff

TorqueScript is similar to C languages but is not identical.

@Marblemaster1

That is because the default powerups are hardcoded in the engine, and there are no definitions of what to do for powerupid > 5. To fix this, you would need to edit the Marble::setPowerUp function to account for ID > 5 (and thus make functions to do what you want to accomplish) OR create a separate class of item object altogether (such as the gems are) with custom scripting to interface with the powerup variables, functions, and GUI element(s).

And you're correct about having no functions in datablocks. You must declare things separately from each other, not inside each other. The only exception is when you smash the declaration together in a text string and run Eval on it.

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

  • Posts: 20
  • Thank you received: 0
04 Feb 2011 09:43 #139
$testCount is exactly what I needed, thanks

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

  • Marblemaster1
  • Marblemaster1's Avatar
  • Offline
  • Advanced Marbler
  • Advanced Marbler
  • Custom Code Enthusiast
  • Posts: 237
  • Thank you received: 8
04 Feb 2011 18:42 #140
OK, let's see. *goes into marble.cs*

Here's the function SetPowerup:

Code:function Marble::setPowerUp(%this,%item,%reset)
{
PlayGui.setPowerUp(%item.shapeFile);
%this.powerUpData = %item;
%this.setPowerUpId(%item.powerUpId,%reset);
}


I have no idea what to edit. I'm not that good at coding...
I'd imagine it's the 3rd line, but I don't know which part.

EDIT: Well, I'm not completely clueless. I'd imagine it's something like:

Code:if (%item.powerUpId == 6)
{
//not sure what to put in here...
}

QuArK is still a good map editor

You know what's boring? Opaque marble skins. You know what's not? Glass Marbles!

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

  • dobrakmato
  • dobrakmato's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 134
  • Thank you received: 0
04 Feb 2011 21:19 #141
@Seizure22

Thank you, but now i have another question.

I have function:

Code:function DobrakmatoBox::onPickup(%this, %obj)
{
$pref::DobrakmatoBox = 1;
}

How to add currently loaded mission to the value like the best saved times in prefs.cs:

Code:$pref::highScoresmarble[/data/missions/advanced/a-maze-ing.mis_0] = 6973\tw;
$pref::highScoresmarble[/data/missions/advanced/a-maze-ing.mis_1] = 90000\tNardo Polo;
$pref::highScoresmarble[/data/missions/advanced/a-maze-ing.mis_2] = 90000\tNardo Polo;

And how to load value in choosegui.dso and then display image? I'm trying to code somethin as easter egg feature..

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

  • Seizure22
  • Seizure22's Avatar
  • Offline
  • Intermediate Marbler
  • Intermediate Marbler
  • Posts: 79
  • Thank you received: 0
04 Feb 2011 23:35 #142
@ Beack

Font of help line can be changed at client/scripts/chathud.cs in function addHelpLine.

@Marblemaster1

Yeah that's right, just make sure the rest of the code there doesn't set the true PowerUpID on the marble else you'll have a crash again.

@Dobrák

function DobrakmatoBox::onPickup(%this, %obj)
{
$pref::DobrakmatoBox[$Server::MissionFile] = 1;
}


Try this (edit the fields to customize it):

PlayMissionGui::onWake(%this, %obj)
{
if($MissionType $= )
$MissionType = Beginner;
PMSetMissionTab($MissionType); //function from original file

if (!isobject(dbText))
{

new GuiMLTextCtrl(DBText) {
profile = ChatHudMessageProfile;
horizSizing = center;
vertSizing = center;
position = 288 232;
extent = 64 32;
minExtent = 8 8;
visible = 1;
helpTag = 0;
lineSpacing = 2;
allowColorChars = 1;
maxChars = -1;
};



new GuiBitmapCtrl(DBBoxImage) {
profile = GuiDefaultProfile;
horizSizing = center;
vertSizing = center;
position = 300 6;
extent = 97 96;
minExtent = 8 8;
visible = 1;
helpTag = 0;
bitmap = ./game/DBBox.png;
wrap = 0;
};

PlayMissionGui.add(DBText); //add GUI elements to PlayMissionGui
PlayMissionGui.add(DBBoxImage);

}

%id = PM_missionList.getSelectedId();
%mission = getField(PM_missionList.getRowTextById(%id), 1);

%text = $Pref::DobrakmatoBox[%mission.file] == 1 ? YES DB BOX : NO DB BOX;
DBText.setText(%text); //set the text of the GUI element
}

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

  • dobrakmato
  • dobrakmato's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 134
  • Thank you received: 0
05 Feb 2011 00:41 #143
@Seizure22

Than you very much, trying it tomorrow.

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
05 Feb 2011 04:35 #144
I was wondering if this could work. For mbopal, I want a power up that will temporarly increase the surface friction of the default materials to increase to 10.


Quote:
//

datablock AudioProfile(doSuperJumpSfx)
{
filename = ~/data/sound/doSuperJump.wav;
description = AudioDefault3d;
preload = true;
};

datablock AudioProfile(PuSuperJumpSfx}
{
filename = ~/data/sound/pusuperJumpVoice.wav;
description = AudioDefault3d;
};

datablock ItemData(FrictionItem)
{
//Mission editor category
category = Powerups;
className = PowerUp;
powerUpId = 7;

activeAudio = DoSuperJumpSfx;
pickupAudio = PuSuperJumpVoicesSfx;

//Basic Item properties
shapeFile = ~/data/shapes/items/shockabsorber.dts;
pickupName = a Friction Increase PowerUp!;
useName = Friction Increase PowerUp;

function Marble::onPowerUpUsed(%obj)
{
PlayGui.setPowerUp();
%obj.playAudio(0, %obj.powerUpData.activeAudio);
%obj.powerUpData = ;
new MaterialProperty(DefaultMaterial)
{
friction = 10;
restitution = 1;
force = 0;
};
}
};

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.

  • IsraeliRD
  • IsraeliRD's Avatar
  • Offline
  • Project Manager
  • Project Manager
  • Dragon Power Supreme
  • Posts: 3502
  • Thank you received: 913
05 Feb 2011 04:38 #145
Does it really work above 6? When I tested for MBP, I didn't notice that the frictions went higher than 6, as in there was no noticeable effect. I put 6 as the limit, but I suspect it's somewhere between 4-6 including.

"matan, now i get what you meant a few years back when you said that "the level in mbg is beyond me" after the last rampage i noticed things were insane, and now i truly feel that too" - Dushine, 2015.

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
05 Feb 2011 04:42 #146
frictions can be over 6.

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.

  • IsraeliRD
  • IsraeliRD's Avatar
  • Offline
  • Project Manager
  • Project Manager
  • Dragon Power Supreme
  • Posts: 3502
  • Thank you received: 913
05 Feb 2011 04:59 #147
Really? Because as I said, when I test MBP, it never seemed to have an effect higher than 6 (as in, marble doesn't slow down faster).

"matan, now i get what you meant a few years back when you said that "the level in mbg is beyond me" after the last rampage i noticed things were insane, and now i truly feel that too" - Dushine, 2015.

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
05 Feb 2011 05:03 #148
Matan, it is coded in mbopal. It works, also, off topic:

is the colmesh.dts that cyberfox released to the public for any mod to use ie mbopal?

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.

  • IsraeliRD
  • IsraeliRD's Avatar
  • Offline
  • Project Manager
  • Project Manager
  • Dragon Power Supreme
  • Posts: 3502
  • Thank you received: 913
05 Feb 2011 05:05 #149
Yes

and Jeff, I know it works, I'm just stating that based on my own experience and testing, it doesn't have any greater effect than lower friction values. For example, try putting in 100, you'll not notice any difference to stop faster than 10 or 6.

"matan, now i get what you meant a few years back when you said that "the level in mbg is beyond me" after the last rampage i noticed things were insane, and now i truly feel that too" - Dushine, 2015.

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

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
05 Feb 2011 05:06 #150
oh, ok

missunderstood you matan.

Also, about my coding question, would what I have actually work. I have not tested it out yet. I wanted to make sure first.

Will download colmesh.dts to mbopal staff version

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.654 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.