|
Post by Jeff on Mar 22, 2013 19:17:19 GMT
$AAYRL = false;
anyways, all REMAPABLE functions have a value that is passed from the engine into it function function_name(%val) { if (%val) { // do stuff here for when the key is pressed DOWN } else { // do stuff here when key is pressed up } } moveMap.bind(keyboard, key_here, function_name); to be honest, I would not do what aayrl did, however if you wanted his approach of using a $global_var then you could just do this: $toggle_var = false; function function_name(%val) { $toggle_var = !$toggle_var; if ($toggle_var) { // key press down } else { // key released } } but its kind of redundant Any further questions just ask away Jeff
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 22, 2013 21:09:04 GMT
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!
|
|
|
Post by Jeff on Mar 22, 2013 21:29:57 GMT
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);
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 22, 2013 22:44:45 GMT
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?
|
|
|
Post by Jeff on Mar 22, 2013 22:53:40 GMT
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.
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 22, 2013 23:21:00 GMT
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.
|
|
|
Post by Jeff on Mar 22, 2013 23:23:05 GMT
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
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 22, 2013 23:56:52 GMT
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.
|
|
|
Post by Jeff on Mar 23, 2013 0:01:57 GMT
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)
|
|
|
Post by Aayrl on Mar 23, 2013 4:23:52 GMT
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
|
|
|
Post by Jeff on Mar 24, 2013 18:07:40 GMT
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()
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 24, 2013 20:16:23 GMT
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.
|
|
|
Post by Jeff on Mar 24, 2013 21:32:50 GMT
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
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 24, 2013 22:09:47 GMT
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.
|
|
|
Post by Jeff on Mar 24, 2013 22:30:54 GMT
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?
|
|
FruBlox
Advanced Marbler
[ss:Default Skin (DO NOT TOUCH)]
It's marbling time!
Posts: 338
|
Post by FruBlox on Mar 24, 2013 22:35:39 GMT
Yeah, thanks. =D
|
|
main_gi
Intermediate Marbler
Solving a Rubik's cube in less than [s]2[/s]1 minute[s]s[/s].
Posts: 83
|
Post by main_gi on Jul 31, 2013 12:07:17 GMT
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.
|
|
|
Post by Alexis on Jul 31, 2013 13:02:24 GMT
1 - marble/server/scripts/powerups.cs
Search for the TimeTravelItem::onPickup function
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:
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); }
|
|
whirligig
Experienced Marbler
[ss:Phil'sEmpire Skin]
Posts: 168
|
Post by whirligig on Jul 31, 2013 16:27:51 GMT
Alexis: that won't cap at 0. Add a line as follows:
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:
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).
|
|
main_gi
Intermediate Marbler
Solving a Rubik's cube in less than [s]2[/s]1 minute[s]s[/s].
Posts: 83
|
Post by main_gi on Jul 31, 2013 17:06:24 GMT
Thank you for your help
|
|
|
Post by Jeff on Aug 1, 2013 2:32:17 GMT
|
|
|
Post by LegoCreator768 on Aug 1, 2013 16:31:12 GMT
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)?
|
|
|
Post by Jeff on Aug 1, 2013 17:00:24 GMT
Press the ~ key? Also you can't use the console in LBs, its disabled.
|
|
|
Post by LegoCreator768 on Aug 2, 2013 15:19:52 GMT
also, how can you make a marble gravity slider (like in marble blast opal) in marble blast gold?
|
|
|
Post by Jeff on Aug 2, 2013 15:25:55 GMT
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:
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!
|
|
|
Post by LegoCreator768 on Aug 2, 2013 17:17:06 GMT
Is the //comments like Garage Games 2001?
|
|
|
Post by Jeff on Aug 2, 2013 17:29:40 GMT
yes
|
|
|
Post by LegoCreator768 on Aug 2, 2013 19:29:27 GMT
ok thank you so much you are awesome
|
|
Marblemaster1 (Frosty)
Professional Marbler
Master of the Spam Board, that is[ss:Default Skin]
I have CDO. It's just like OCD, except the letters are in alphabetical order AS THEY SHOULD BE.
Posts: 361
|
Post by Marblemaster1 (Frosty) on Aug 10, 2013 16:15:41 GMT
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?
|
|
|
Post by Jeff on Aug 10, 2013 21:24:30 GMT
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); }
|
|