Author Topic: Event: onPlayerFirstSpawn not working  (Read 2516 times)

just suggesting a way so the code actualy works, instead of telling him not to do it at all

just suggesting a way so the code actualy works, instead of telling him not to do it at all

That's what I did.

You also need to return onClientEnterGame or else you will get occasional crashes

Do what xXBeibsFan119Xx (Jookia) said and simply make a tab-delimited list of every brick containing the event, then loop through that list and call the event on each of the bricks in it.

Okay, that makes sense, but I have a few questions. First, what does the term "tab-delimited list" mean? Is this referring to an array of tab-seperated object handles, and if so, how would I initialize such a list? Next, how do I find the bricks containing this event so that I can add them to the list?

Okay, that makes sense, but I have a few questions. First, what does the term "tab-delimited list" mean? Is this referring to an array of tab-seperated object handles, and if so, how would I initialize such a list? Next, how do I find the bricks containing this event so that I can add them to the list?

A tab-delimited list is just a list of thing, separated by items. Torque just refers to items by IDs, so you can put those in a long string seperated by something, then use getWord (or getField in cases you want multiple words, just separate with tabs) and getWordCount to traverse the string, and use each word as a brick, no typecasting is needed.

Finding the bricks containing the event can be done two ways: Looping through the hundreds of thousands of bricks in the world, or just hooking in to when events are added and removed and modifying to the list, and then traversing the list on the connection.

Ah, okay. I read some tutorials and they referred to the IDs as "handlers", that's why I used that terminology. That makes sense, but I'm left with two last questions that should hopefully clear things up for good (for now).

First, how do I store a global variable that persists (a list of IDs that have a particular event on them)? Is it as easy as, say $bricksWithMyEvent = "1234    5678"? Is that variable them made available to other scripts?

Second, how do I know when I've added an event to a brick (or removed one)? In other words, what's the "hook" I can use? You mention something about "...addEvent/removeEvent", but where exactly do I put that and, assuming these are functions, what's the syntax I would use for calling them?

Thanks for taking the time to deal a noob like myself. I'm interested in learning Torque Script for Blockland, but it's hard to find references for simple stuff like this. Well, I mean, it was easy enough to find a couple tutorials on syntax ($ = global variable, % = local, etc.) and a list of functions, but I can't really find anywhere that helps me put it all together. Here's a cookie for you.  :cookie:
« Last Edit: May 07, 2012, 07:35:26 PM by Mordius »

First, how do I store a global variable that persists (a list of IDs that have a particular event on them)? Is it as easy as, say $bricksWithMyEvent = "1234    5678"? Is that variable them made available to other scripts?
You will append to the list or remove pieces of it directly in the "hooks" you mentioned

@Kalphiter: Yes, that much is clear to me (as I previously explained). However, I'm specifically interested in the syntax necessary to achieve this, since I can't seem to find anything that deals specifically with creating an event mod, nor are the other event scripts of much help since I really don't know what I'm doing. Mostly what I need to know is, how exactly do I create a hook on a brick? Something like this?

Code: [Select]
%somebrick.addEvent = function(%event) {
    %bricksWithMyEvent.push(%thisBrickID);
    return %event;
}

(without knowing much of the syntax I default to Javascript-ish gibberish.) What's the correct way of stating the above? I could look it up but that could take hours... and I don't want to spend hours on such a simple issue.

First, how do I store a global variable that persists (a list of IDs that have a particular event on them)? Is it as easy as, say $bricksWithMyEvent = "1234    5678"? Is that variable them made available to other scripts?

Yes.

Second, how do I know when I've added an event to a brick (or removed one)? In other words, what's the "hook" I can use? You mention something about "...addEvent/removeEvent", but where exactly do I put that and, assuming these are functions, what's the syntax I would use for calling them?

Blockland and TorqueScript lack documentation. The best way to figure this out is to find a brick's ID (it's usually seen in the window title of the wrench menu) and perform the 'dump' member function on it. You'll see a listing of all the methods a brick has, and you can overwrite those like you did in the first post. As for arguments, you can either use the 'trace' command (uses a boolean argument) to toggle tracing all the functions and whatnot that happen, but from my experience I've just added a bunch of useless arguments and passed them on, and echo'd them to see what they were, and just guessed at what the appropriate variable name would be. I don't actually know the event system scripting wise as I left Blockland scripting in v9, just as events were getting started.

Thanks for taking the time to deal a noob like myself. I'm interested in learning Torque Script for Blockland, but it's hard to find references for simple stuff like this. Well, I mean, it was easy enough to find a couple tutorials on syntax ($ = global variable, % = local, etc.) and a list of functions, but I can't really find anywhere that helps me put it all together. Here's a cookie for you.  :cookie:

Read other people's code. That's as easy as it gets.

@Kalphiter: Yes, that much is clear to me (as I previously explained). However, I'm specifically interested in the syntax necessary to achieve this, since I can't seem to find anything that deals specifically with creating an event mod, nor are the other event scripts of much help since I really don't know what I'm doing. Mostly what I need to know is, how exactly do I create a hook on a brick? Something like this?

TorqueScript doesn't have hooks. I just used the term for the whole package thing where you overwrite methods.

Welcome to this poor engine. No, there is no real handling for lists in this engine (although there is an ArrayList fix available somewhere, that would be nice hint hint).

I don't know the function for when events are changed.

Okay, thanks for the help, guys. I'll do some dumps and traces and see where I get. ^_^

Also, for information on evaluating your own code when ::addEvent/::removeEvent are invoked, refer to this post by Trader.