[Resource]-Torquescript Learners Guide-[WIP]

Author Topic: [Resource]-Torquescript Learners Guide-[WIP]  (Read 8512 times)

hey.. im a scripting noob :P but i was wondering how/if i could make it so when you are holding an item it displays bottomprint on the screen...
(doing it for my resource items add-on i am making, nothing big but helpful for easy RPs)
if you someone could tell me that it would be much appreciated...   

hey.. im a scripting noob :P but i was wondering how/if i could make it so when you are holding an item it displays bottomprint on the screen...
(doing it for my resource items add-on i am making, nothing big but helpful for easy RPs)
if you someone could tell me that it would be much appreciated...   
Code: [Select]
function itemImageHere::onMount(%this,%obj)
{
bottomPrint(%obj.client,"Hello World!",1);
parent::onMount(%this,%obj);
}

I and most of the community refer to them as arrays for lack of a better term.
Apologies for the misunderstanding though.
Oh, nah that's fine. I was just saying that because he said he watched a video on arrays, which would describe them the way they actually work, which isn't the way they work in Torque.

Good. Now you understand arrays, something Blockland doesn't have. What [] does in Blockland is variable insertion. %var[1] is the same as %var1. It just inserts whatever is inside [] into the variable name. This is useful because, like in the above example, sometimes you'll have a variable. %var%num won't work, but %var[%num] will. It'll insert the value of %num into the variable name, so if it's 4 it'll resolve to %var4.
This pretty much explains the export function design when it comes to how data is presented (with some underscores if I'm right) in a file.

This pretty much explains the export function design when it comes to how data is presented (with some underscores if I'm right) in a file.
What? If I understand what you're saying, no. That just exports a list of global variables that match the mask.

hey.. im a scripting noob :P but i was wondering how/if i could make it so when you are holding an item it displays bottomprint on the screen...
(doing it for my resource items add-on i am making, nothing big but helpful for easy RPs)
if you someone could tell me that it would be much appreciated...   

Code: [Select]
function itemImageHere::onMount(%this, %obj)
{
%obj.bottomPrintItemSchedule = schedule(120, 0, bottomPrintItemSchedule, %obj, "YOUR MESSAGE HERE");
Parent::onMount(%this,%obj);
}

function itemImageHere::onUnMount(%this, %obj)
{
cancel(%obj.bottomPrintItemSchedule);
Parent::onUnMount(%this, %obj);
}

function bottomPrintItemSchedule(%obj, %msg)
{
if(isObject(%obj))
{
if(isEventPending(%obj.bottomPrintItemSchedule))
cancel(%obj.bottomPrintItemSchedule);

bottomPrint(%obj.client, %msg);

%obj.bottomPrintItemSchedule = schedule(120, 0, bottomPrintItemSchedule, %obj);
}
}

Replace itemImageHere with the image name of your item. Replace "YOUR MESSAGE HERE" with whatever message you want to put. Make sure it's in quotes though.
« Last Edit: January 15, 2013, 06:33:56 PM by Electrk »

What? If I understand what you're saying, no. That just exports a list of global variables that match the mask.
Everything you said is correct but I'm just stating the part where the "$var[100]" has the "100" appended to "$var" within the file that the function has exported to and when Torquescript executes the exported variable(s) in the file, it interprets the end numbers (I think with underscores) as "[100]".

I hope this makes sense if not I'll try and find an exported file.

TY EEPOSS AND ELECTRK! :cookie: :cookie: :cookie:  i am makeing some weapons using spaceguy's ammoguns while at the same time makeing them have a weapon degradation variable.. (like in fallout) im 90% done now thanks to this guide...   i just cant seem to figure out how to make the weapon stop working entirely after the variable reaches 0(EDIT: i have a new problem now 98% done :o)...  (and i know this is not the place to ask.. i just figured id let you all know what im up to :P)

UH OH!!! if you want to give me a hand.. go to this link...   http://forum.blockland.us/index.php?topic=219507.0
« Last Edit: January 16, 2013, 11:50:56 PM by zombekillz »

Everything you said is correct but I'm just stating the part where the "$var[100]" has the "100" appended to "$var" within the file that the function has exported to and when Torquescript executes the exported variable(s) in the file, it interprets the end numbers (I think with underscores) as "[100]".

I hope this makes sense if not I'll try and find an exported file.
In Blockland $var[100] is equivalent to $var100.

I swear Im done even trying. Every time I attempt to make a simple chatbot or ANYTHING
even its its literally copy+paste a code my friend gives me, I get a syntax error

I swear Im done even trying. Every time I attempt to make a simple chatbot or ANYTHING
even its its literally copy+paste a code my friend gives me, I get a syntax error

Success is acquired after many failures.