Blockland Forums > Modification Help
Event: onPlayerFirstSpawn not working
Mordius:
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:
Kalphiter:
--- Quote from: Mordius on May 07, 2012, 07:33:42 PM ---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?
--- End quote ---
You will append to the list or remove pieces of it directly in the "hooks" you mentioned
Mordius:
@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: ---%somebrick.addEvent = function(%event) {
%bricksWithMyEvent.push(%thisBrickID);
return %event;
}
--- End code ---
(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.
xXBeibsFan119Xx:
--- Quote from: Mordius on May 07, 2012, 07:33:42 PM ---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?
--- End quote ---
Yes.
--- Quote from: Mordius on May 07, 2012, 07:33:42 PM ---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?
--- End quote ---
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.
--- Quote from: Mordius on May 07, 2012, 07:33:42 PM ---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:
--- End quote ---
Read other people's code. That's as easy as it gets.
--- Quote from: Mordius on May 07, 2012, 07:42:44 PM ---@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?
--- End quote ---
TorqueScript doesn't have hooks. I just used the term for the whole package thing where you overwrite methods.
Kalphiter:
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.