Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - boodals 2

Pages: 1 [2] 3 4 5 6 7 ... 66
16
Modification Help / Re: Tutor / Teacher?
« on: October 14, 2015, 05:09:40 AM »
I suggest you try to figure it out yourself and when you need advising just use search to find related posts, and then make a topic here.

Making a topic should be the last thing you do, once all your other sources have been exhausted.

Here are some good resources to use:
Search - seriously, use it. 99% of questions have already been asked, and answered. And nobody is paid to be here and help you.
TorqueScript Quick References - This has basically all of the default functions in TorqueScript. Badspot has added many more, and removed some, but for general raw torquescript use, this is gold. (Ctrl+F is your friend)
Blockland Unofficial API documentation - A nice webpage made my someone in the community, it has most of the functions that the Quick References misses, and even covers the general structure of Blockland's classes, and files.
The official coding resource thread - This post has a ton of resources that people have written, typically small scripts that you can include, that will simplify some of the more complicated things you need to do.
TorqueScript For Blockland - A website made by elm which goes over several general programming concepts, as well as most of the concepts unique to TorqueScript, all laid out in a simple way, designed for new coders.
Coding Help - Yes the entire board. A great way to learn is just to read other peoples questions, and see how they're answered. However, only answer a question if you are pretty confident with the subject, a lot of people have given out wrong information which could cause a lot of confusion easily. Also check out all the stickied posts, they're there for a reason.
Modification Discussion - This board isn't directly for coding problems, but often you'll find useful concepts or even code snippets you can use. It also has a ton of models in it you can use if you need them.

You should bookmark each of these, so if you need them (you will) you can quickly find them.

17
Modification Help / Re: Group.add(); doesn't add the object to the group.
« on: October 12, 2015, 10:19:39 AM »
Another thing I just noticed, you should not change the group of a brick, since they go in BrickGroups, which is a SimGroup that is created when a client joins, one per BL_ID, and all the bricks they own are placed into it.
Many brick functions rely on the brick being in that group, so by moving it you are breaking other things.

You should use a SimSet instead of a ScriptGroup (although SimSet doesn't allow you to use a custom class and stuff, and there's no ScriptSet. Use a ScriptObject with a reference to a SimSet).
An object has to be in exactly one Group, but can be in as many SimSets as you like.

18
Modification Help / Re: Saving objects as *.cs or a third saving system
« on: October 12, 2015, 08:55:34 AM »
If you can get away with using export or save, do so. The overhead for a custom reader/writer is rarely worth the small amount of storage space you'll save. However, if you are writing thousands of lines, and you are concerned about read or write times, then it is best to write a slow reader/writer, so that it doesn't read/write the entire file at once, but rather schedules it out so that it only does a few hundred lines at a time.

Writing a saving/loading system can be quite fun though, and its a good learning experience.

19
Modification Help / Re: Spawning an item at any coordinate
« on: October 12, 2015, 08:47:59 AM »
To clarify: GunItem is an ItemData (which is a type of Datablock), which is different to an Item. An Item is an instance of an ItemData, just like a Player is an instance of a PlayerData.
Datablocks are downloaded to the client when they join a server, and so you cannot modify the variables on them (safely). Datablocks determine some base stats of the item, things that should not change, such as its name or its mass. Instances are copies of that datablock, but they can have a position, rotation, velocity, etc. and they are actually visible in-game.

jes00 is talking about an item instance, Quartz is talking about an item datablock.

Do you want to create a new type of item (ItemData), or do you just want to spawn an item (Item)?

20
Modification Help / Re: Group.add(); doesn't add the object to the group.
« on: October 12, 2015, 08:40:02 AM »
Code: [Select]
function inBounds(%brick) {
%client = %brick.client;
if(isObject(%client.lastBound))
if(isInBox(%brick,%client.lastBound))
return %client.lastBound;
for(%i = 0;%i < $LotGroup.getCount;%i++) {
if(isInBox(%brick,$LotGroup.getObject(%i))) {
%client.lastBound= $LotGroup.getObject(%i);
return %client.lastBound;
}
}
return 0;
}

$LotGroup.getCount(); in the For loop returns 0.

You are not calling $LotGroup.getCount(), you are accessing the variable getCount on $LotGroup. You forgot the ().
Idk if that will fix your overall problem.

Also that is inefficient, as every iteration it will call $LotGroup.getCount() . Instead you should either store the count in a variable before the loop; eg %count = $LotGroup.getCount(); for(%i = 0; %i < %count; %i++) { Or you could start at the end and work backwards; for(%i = $LotGroup.getCount() - 1; %i >= 0; %i--) {
The second method is slightly harder to read, but also slightly faster. Of course, it doesn't really matter in this case, as (I assume) there wont be too many objects in $LotGroup , but it's worth learning and getting used to.



And the console outputs the following when I press and hold my Enter button:
Code: [Select]
032552
032553
032554
-snip-

None of those are actual objects. isObject(); retuns false.

Just to be sure, you are doing the isObject() check before you delete them, right?

21
Modification Help / Re: Silly Torque, that's not an array!
« on: October 06, 2015, 01:20:44 PM »
$foo[":"] = 1;

Yeah, I didn't take colons into account when i first made the function, and then when I started using it I found that it was putting them into the array (which i think worked, but I wanted it to look nice). I'll just take it out of the %extra variable so that it works again.

Ok, fixed it.

22
Modification Help / Re: Silly Torque, that's not an array!
« on: October 06, 2015, 01:10:23 PM »
This function will export a file, and then read through that file using a FileObject, and when it finds something which would cause a syntax error, it encapsulates the rest of the variable in an array.

This is not a good thing to do if you are releasing the add-on, as its much slower than export, but it works fine if you just want to lazily save some variables.
Also worth noting that this allows you to save arrays and stuff when you don't know either the length or the index of each element, as it uses export.

Code: [Select]
function Safe_Export(%vars, %dir) {
export(%vars, "Config/Client/SafeExport_Temp.cs");

%readFile = new fileObject();
%readFile.openForRead("Config/Client/SafeExport_Temp.cs");
%writeFile = new fileObject();
%writeFile.openForWrite(%dir);

%legalChars = "abcdefghijklmnopqrstuvwxyz_"; //Only these chars can be the first letter of a var name
%extra = "0123456789"; //These chars can be anywhere in a var name

while(!%readFile.isEOF()) {
%line = %readFile.readLine();

%var = getSubStr(%line, 1, (%pos = strPos(%line, " = "))-1);
%value = getSubStr(%line, %pos + 3, strLen(%line) - strLen(%var) - 5);

if(striPos(%legalChars, %firstChar = getSubStr(%var, 0, 1)) == -1) {
error("ERROR: Safe_Export: Var starts with illegal char!" SPC %firstChar);
continue;
}

for(%i=1; %i < strLen(%var); %i++) {
%char = getSubStr(%var, %i, 1);
if(striPos(%legalChars @ %extra, %char) == -1) {
%var = getSubStr(%var, 0, %i) @ "[\"" @ expandEscape(getSubStr(%var, %i, strLen(%var) - %i)) @ "\"]";
break;
}
}

if(getSubStr(%value, 0, 1) !$= "\"" || getSubStr(%value, strLen(%value)-1, 1) !$= "\"")
%value = "\"" @ %value @ "\"";

%writeFile.writeLine("$" @ %var SPC "=" SPC %value @ ";");
}

%readFile.close();
%readFile.delete();

%writeFile.close();
%writeFile.delete();
}


Edit: Also, you'll probably want to check that openForWrite(%dir); returns true, and if it doesn't, close and delete the file objects. I've already spoonfed enough though.
Edit 2: Oh, it's also a lot smarter, faster, and more efficient to simply start the array after the first character in the variable's name. This function is old, idk what I was thinking.

23
Modification Help / Re: Rotating Vectors
« on: September 30, 2015, 05:18:34 AM »
This might help you
http://forum.blockland.us/index.php?topic=270070


Edit: What are you trying to do exactly? There might be a simpler way of doing it.

24
Modification Help / Re: NEW TOPIC: Event help
« on: September 26, 2015, 04:01:16 AM »
There is no reason to check if %this exists in this case, as in order to call this function, you should be using %this.setMaxForwardSpeed(%x) , so if %this didn't exist, it would throw an error there.

Although it is possible to call it using Player::setMaxForwardSpeed(%this, %x); (exploiting how torque functions work), but if anyone is doing that, they should check if its an object themselves.

25
Modification Help / Re: Making a raycast bounce?
« on: September 25, 2015, 08:39:33 PM »
that doesn't fix it

i don't know if port's example works right, it seems to get things perpendicular to the normal? (e.g. i fire it at an angle, the angle is flattened and sent in reverse from the normal or something)

Port's math seems fine to me in my head.

Looking at it again, I think I was wrong thinking it should be %nv. Try changing
%vn = vectorAdd(vectorScale(%n, -2 * vectorDot(%v, %n)), %v);
to
%vn = vectorAdd(vectorScale(%n, -2 * vectorDot(%eyeVector, %n)), %eyeVector);
No guarantees though, its late.

%v is badly named, it is the hit position of the raycast, not a vector.

26
doesnt seem to work since %forward is always near 0,0,0 regardless of player position

EDIT: nvm i added %point to %player.geteyepoint n it worked thx senpai bb :)

%forward, %up, and %right are all vectors, not positions. %point was badly named.

27
Modification Help / Re: Making a raycast bounce?
« on: September 25, 2015, 05:04:12 PM »
In your while loop, the raycast is using the wrong parameter.

%raycast = containerRayCast(%v,%range,$TypeMasks::fxBrickObjectType);
should be
%raycast = containerRayCast(%nv,%range,$TypeMasks::fxBrickObjectType);


Cant see anything else wrong other than that. Your variable names could be better though. I recommend start and end for raycast points.

28
All you really need is the relative forward, up, and right vector, and the rest is easy.

Code: [Select]
%forward = %player.getEyeVector(); //May have issues when freelooking, if so use [tt]getForwardVector()[/tt] and the z component of [tt]getEyeVector()[/tt]
%right = vectorCross(%forward, "0 0 1"); //Cross product returns a vector which is perpendicular to both input vectors
%up = vectorCross(%forward, %right); //This might actually be down, if so just swap the inputs

Using these vectors, you can scale them and add them to get any point relative to the player. eg:

Code: [Select]
%point = vectorAdd(vectorAdd(vectorScale(%forward, 2), vectorScale(%up, 0.3)), vectorScale(%right, 1));

%point will be a vector that is 2 units forward, 0.3 up, and 1 to the right, in front of the player.

29
Not quite
I see why you think that, but he's getting that z velocity from the result of vectorNormalize, not getVelocity, so it's only going to be between 0 and 1

Ah, so he is.

30
Or just cut out the second vector entirely cuz I don't see what he's trying to do with that concatenation funkiness,  just replace it with "0". Or even better, don't, and look at the way I did it
I think he might be trying to but he's doing it the wrong way....that Z part will be 0 unless the player is already traveling vertically some, in which case it isn't terribly needed for that goal...I think it's more likely he just did random stuff until he made something that looked like it worked

He is preserving the z velocity, which is the correct thing to do. If you are falling, and you dash, you don't want to magically stop falling and move forwards instead.

But yeah, its much easier to use AddVelocity here.

Pages: 1 [2] 3 4 5 6 7 ... 66