file Basic Marble Blast Coding Q&A

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
22 Mar 2013 21:17 #301
Quote:Because of the nature of the key binding in this engine, it may not be possible to tell it to fire one function per button press.

$AAYRL = false;

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: 155
  • Thank you received: 2
22 Mar 2013 23:09 #302
Will try something like that, but on the note of scheduling, how do I schedule a function? Probably been answered before but I can't find it.

EDIT: Did what you said about the %val argument, and it worked! Thanks, Jeff!

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
22 Mar 2013 23:29 #303
Mar 22, 2013, 4:09pm, frublox wrote:Will try something like that, but on the note of scheduling, how do I schedule a function? Probably been answered before but I can't find it.

EDIT: Did what you said about the %val argument, and it worked! Thanks, Jeff!

no problem.

for your convenience, scheduling:

$schedule_var = schedule(%time, 0, function_name, args);

if you want to stop a schedule from taking place:

cancel($schedule_var);

NOTE: $schedule_var is not a return of the function, rather the event handle of the schedule for canceling. If you dont need it, you never have to set the schedule to a variable. All functions result in void calls whenever used with schedules.

args are optional depending if the function has parameters. %time is defined in milliseconds. Once that time is hit, function_name is executed by the engine.

If you want to schedule a method on an object:

%obj.schedule(%time, method_name, args);

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: 155
  • Thank you received: 2
23 Mar 2013 00:44 #304
Ooh, thanks again!

Few questions:
In terms of the time, does it execute the function when the time in a mission gets to that point, or is based on some global time in the engine?

What's the difference between a function and a method? Is it that a method is a function that belongs to an object?

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
23 Mar 2013 00:53 #305
1. for scheduling, its all processed via ticks in the engine.

2. method is a function attached to an object. like this:
%marble = localclientconnection.player;
%matrix = %marble.getTransform();

getTransform() is a method of the object localclientconnection.player, or the method of the marble class.

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: 155
  • Thank you received: 2
23 Mar 2013 01:21 #306
Mar 22, 2013, 5:53pm, jeff wrote:1. for scheduling, its all processed via ticks in the engine.

2. method is a function attached to an object. like this:
%marble = localclientconnection.player;
%matrix = %marble.getTransform();

getTransform() is a method of the object localclientconnection.player, or the method of the marble class.

Yeah, I thought they were synonyms since in Java they're called methods, but I guess that makes sense considering everything in Java is an object.

So how would I schedule functions relative to other things happening? Like when a key is pressed, the function is scheduled to run 5 seconds after that.

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
23 Mar 2013 01:23 #307
example:

movement function:

function x(%val)
{
if (%val)
schedule(5000,0,y);
}

function y()
{
// do stuff
}

is this what you mean?

also frublox, check your PMs

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: 155
  • Thank you received: 2
23 Mar 2013 01:56 #308
So when the user presses the key that runs function x, function y will run 5 seconds afterwards? If so then yeah that's what I meant.

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
23 Mar 2013 02:01 #309
Mar 22, 2013, 6:56pm, frublox wrote:So when the user presses the key that runs function x, function y will run 5 seconds afterwards? If so then yeah that's what I meant.

yes. and if you want to cancel it:

1. put {} around if statement cuz it will take 2 statements. (you can omit braces ONLY if theres 1 statement)

2. put a cancel() call before the schedule is called

3. assign the schedule to a string ($global)

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.

  • Aayrl
  • Aayrl's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
  • Big Deal!
  • Posts: 1118
  • Thank you received: 370
23 Mar 2013 06:23 #310
It's also a good idea to cancel any schedules before calling them once again, especially if they run during the game and a player suddenly exits to the play menu. We've run into some issues as a result of that before, i.e. Emitter events trying to run on the main menu.

~Aayrl

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
24 Mar 2013 20:07 #311
Mar 22, 2013, 11:23pm, aayrl wrote:It's also a good idea to cancel any schedules before calling them once again, especially if they run during the game and a player suddenly exits to the play menu. We've run into some issues as a result of that before, i.e. Emitter events trying to run on the main menu.

~Aayrl

Going off of what aayrl said, theres a couple of places to do that if ever needed.

both are found in marble/server/scripts/game.cs

in function GameConnection::onClientLeaveGame(%this)

or

function onServerDestroyed()

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: 155
  • Thank you received: 2
24 Mar 2013 22:16 #312
At the mention of client-related and server-related stuff, are there any major differences I should know about? Or do they both pretty much handle the same way (since MB never used or finished the multiplayer aspect)?

Just asking because I've heard that there are some cases where only way to do something is via server and not client, or vice-versa.

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
24 Mar 2013 23:32 #313
Mar 24, 2013, 3:16pm, frublox wrote:At the mention of client-related and server-related stuff, are there any major differences I should know about? Or do they both pretty much handle the same way (since MB never used or finished the multiplayer aspect)?

Just asking because I've heard that there are some cases where only way to do something is via server and not client, or vice-versa.


Only matters if its multiplayer based...which you should not have to worry about as thats my job

But for good coding practices you should split it, however what i told you goes against my own coding ways :X

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: 155
  • Thank you received: 2
25 Mar 2013 00:09 #314
Okay, thanks!

So I want to call the function Marble::setPowerup, but I don't know how to get the marble object (what the functions use to get the powerUpData field). Any way to find and use the marble object that those functions use?

EDIT: idk if I made it clear in my post, but I need to get the value of the powerUpData field of the Marble object, but I don't know the Marble object's name.

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
25 Mar 2013 00:30 #315
Erm....

to get the marble object, %this is the marble in function Marble::setPowerup

alternativly, the marble object is localClientConnection.player

to get the powerup data field...well all torquescript fields are public access...so localClientConnection.player.powerUpData

is that what you needed?

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: 155
  • Thank you received: 2
25 Mar 2013 00:35 #316
Yeah, thanks. =D

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

  • Posts: 148
  • Thank you received: 31
31 Jul 2013 14:07 #317
Um, I would like two things. 1. A time modifier that works by directly reducing time. Capped at 0.00 -- and 2. A time modifier that will completely stop time when touched forever, but when you touch a second one it will start the time with (X) more seconds added to the time.

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

  • Posts: 240
  • Thank you received: 0
31 Jul 2013 15:02 #318
1 - marble/server/scripts/powerups.cs

Search for the TimeTravelItem::onPickup function
Code:function TimeTravelItem::onPickup(%this,%obj,%user,%amount)
{
Parent::onPickup(%this, %obj, %user, %amount);
if(%obj.timeBonus !$= )
%user.client.incBonusTime(%obj.timeBonus);
else
%user.client.incBonusTime($Game::TimeTravelBonus);
}

Change it to:
Code:function TimeTravelItem::onPickup(%this,%obj,%user,%amount){
Parent::onPickup(%this, %obj, %user, %amount);
if(%obj.timeBonus !$= )
playGui.setTime(PlayGui.elapsedTime - %obj.timeBonus);
else
playGui.setTime(PlayGui.elapsedTime - $Game::TimeTravelBonus);
}

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

  • whirligig
  • whirligig's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
  • Posts: 444
  • Thank you received: 261
31 Jul 2013 18:27 #319
Alexis: that won't cap at 0. Add a line as follows:

Code:function TimeTravelItem::onPickup(%this,%obj,%user,%amount){
Parent::onPickup(%this, %obj, %user, %amount);
if(%obj.timeBonus !$= )
playGui.setTime(PlayGui.elapsedTime - %obj.timeBonus);
else
playGui.setTime(PlayGui.elapsedTime - $Game::TimeTravelBonus);
if (PlayGui.elapsedTime < 0) PlayGui.setTime(0);
}


2) Replace the same function:

Code:function TimeTravelItem::onPickup(%this,%obj,%user,%amount){
Parent::onPickup(%this, %obj, %user, %amount);
if (PlayGui.bonusTime > 3000000) {
if(%obj.timeBonus !$= )
PlayGui.bonusTime = -%obj.timeBonus;
else
PlayGui.bonusTime = -$Game::TimeTravelBonus;
}
else PlayGui.bonusTime = 3599999;
}


If you wait an hour or so with the timer stopped, this will actually restart the timer, but that shouldn't come up in normal gameplay (the fix would require a change to playGui.cs).

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

  • Posts: 148
  • Thank you received: 31
31 Jul 2013 19:06 #320
Thank you for your help

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 Aug 2013 04:32 #321
@Whirligig

PlayGui.stopTimer(); to stop times.

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
01 Aug 2013 18:31 #322
Is it possible to use that window where you can type the code for the LE and change gravity as a chat window (Like in MBP Leaderboards)?

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 Aug 2013 19:00 #323
Press the ~ key? Also you can't use the console in LBs, its disabled.

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
02 Aug 2013 17:19 #324
also, how can you make a marble gravity slider (like in marble blast opal) in marble blast gold?

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
02 Aug 2013 17:25 #325
Okay, a few steps:

1. make your slider control in the GUI editor.

2. set the control's range property between -40 and 40

3. set the control's variable property to $pref::gravity

4. go to marble/main.cs and add this at the top of the file under the //comments

$marbleGravity = 20;

5. go to marble/server/scripts/game.cs

find function GameConnection::onClientEnterGame

before the last closing brace ( } ) add this:
Code:if ($pref::gravity !$= )
$marbleGravity = $pref::gravity;
%this.player.getDataBlock().gravity = $marbleGravity;


did this from memory. If it don't work post back. But make sure to follow all of the steps!

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
02 Aug 2013 19:17 #326
Is the //comments like Garage Games 2001?

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
02 Aug 2013 19:29 #327
yes

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
02 Aug 2013 21:29 #328
ok thank you so much you are awesome

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
10 Aug 2013 18:15 #329
I have a question.

Suppose I wanted to add on to the onMissionLoaded function in MBP, but only in one MIS file. You can do this in Java by using super(), but can you do it in TS? And if so, how?

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
10 Aug 2013 23:24 #330
u have to put it in a package and use the parent keyword:

package mismod
{
function onMissionLoaded()
{
// super
Parent::onMissionLoaded();
// code here
}
};
activatePackage(mismod);

however, if you are making a sub class in TS with a subobject, you can do this w/o package.

datablock bleh(b)
{
classname = hello;
};

// super
function bleh::onAdd(%this, %obj)
{
}

function hello::onAdd(%this, %obj)
{
// call super
Parent::onAdd(%this, %obj);
}

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.775 seconds