PDA

View Full Version : a few suggestions...



Master Maniac
05-24-2008, 01:06 PM
these would be particularly useful to me... i don't know if anyone else thinks so, but to me, they would be ideal.

in scripting:

a then() function. used in order to make sequences of a particular command. used after closing an if() statement. used like so:

if(this){
then(this){
then(this){
do this

however, the last part activates ONLY after the if() and then() requirements have been met in that order.

in the editor:

in the item editor, is it possible to make it able to rename the sounds? like in the item editor, where it shows how the item is named, and the ID, so it can still be used for scripting purposes (if needed). it would be easier than having to go through and listen to all of your sounds to find the right one.

thanks =)

_L_
05-24-2008, 01:25 PM
a then() function. used in order to make sequences of a particular command. used after closing an if() statement. used like so:

if(this){
then(this){
then(this){
do this

This was explained earlier, was it not? You can just write:


if( (this1) && (this2) && (this3) )
do this

Or:

if(this1)
if(this2)
if(this3)
do this
Both of these samples compare this1, this2 and this3, in order. That is the end of the matter.


As for your second suggestion: I suppose so.

Master Maniac
05-24-2008, 02:05 PM
yes, but for both of those, i would have to use else() a lot. i know im just being lazy, but it is the truth.

and doesent && mean if these are all happening at the same time?

i am currently using the second suggestion, i just thought it would be a little more convenient, instead of using a bunch of else()'s every other function.

Joe123
05-25-2008, 03:17 AM
That's how C++ works MM.

If you want to reduce your code, try using maths instead of ifs rather than requesting silly new features.

_L_
05-25-2008, 07:58 AM
and doesent && mean if these are all happening at the same time?

As far as I know there is no computer on this planet that can evaluate more than one statement simultaneously. Well, maybe those quad-cores or something. But the point is that ZScript is compiled into ZASM, and ZASM looks like this:


COMPAREV d1, 2
GOTOLESS 55
COMPAREV d2, 12
GOTOLESS 65

As you can see, it is impossible for it to compare multiple variables simultaneously, or in a non-deterministic order.

Revfan9
05-25-2008, 02:17 PM
Just like actual assembly, ZASM (Which is what Zscript compiles into) can only execute a single command at a time.

This isn't so much an issue of a new feature that needs to be added, but rather that you need to learn how to code. Nested if structures will work just fine for what you need, or even using logical operators in certain circumstances.

CJC
05-25-2008, 03:52 PM
The "If" function is used by the code to generate an "if->then" logical couplet. Actually, as far as I know, it generates an "iff->then" couplet (If and only if this happens, then this.)


I think I understand what you're trying to ask for...



if(Some Condition A){
then if(Some Condition B){
then (Action C occurs);
}
}

While that seems logical from a standpoint, the "then" aspect is implied by the "if" code. Inputting an additional "then" is unnecessary and would probably break the code. To make the same conditions for which your event to occur, drop the "thens":



if(Some Condition A){
if(Some Condition B){
Action C occurs;
}
}

That would generate the following logical chain:
If Condition A is true, then if Condition B is true, then perform action C.

Do you see how the "then" is implied by the code brackets?

Now, let's go a little more indepth with the coding.



if(!Some Condition A){
if(Some Condition B){
Action C occurs;
}
else{
Action D occurs;
}
}
else if(!Some Condition B){
Action E occurs;
}

This code first checks if Condition A is false. If it is not, all material between that check and the "else" function on the same tab line are ignored. Basically, it is telling the program this:

If Condition A is false, continue checking... otherwise...

The code continues to form a logical tree, which spells out:

If Condition A is false, then check condition B. If Condition B is true, perform Action C.
Otherwise, if Condition B is false, perform Action E. Otherwise, do nothing.



So the "then" is implied, and "else" serves as an "otherwise" condition in the code. Else lines are placed on the same column as the if statement they counteract.


Let's take one more step into the logic setup before calling it quits. I'm going to explain "And" and "Or" conditions.



if((!Some Condition A) && (!Some Condition B)){
Action C occurs;
}
else if((!Some Condition A) || (!Some Condition B)){
Action E occurs;
}
else if(Some Condition A){
Action F occurs;
}
else{
Action G occurs;
}


The above first checks if BOTH Condition A AND Condition B are false. If that is true, then the script performs Action C and concludes (The remaining clauses are all "else" clauses, so there are no more conditions to check.)
Should that first "if" clause fail, the script goes on to check if EITHER Condition is false. If it turns out that one is false, the script performs Action E and concludes.
If the second "if" clause fails, it is proven that at least one of the two conditions are true. The script goes on to test if Condition A is true. Like before, if the "if" condition is met, then the action is performed and the script concludes.
Finally, since there are no more possible combinations (They have been eliminated with the above if-statements), the script takes any remaining variables and performs the final action, G. It is important to be cautious with a straight "else" clause, otherwise other parameters might generate your action that you had not intended.

So to summarize the above script as a logic sentence:
If Condition A and Condition B are false, then perform action C. Otherwise, if Condition A or Condition B are false, then perform action E. Otherwise, if Condition A is true, then perform action F. Otherwise, perform action G.

Master Maniac
05-27-2008, 01:09 AM
oh... oooohhhh... oops...

^.^ i think i was understandinf if()s wrong then XD thanks. of course this doesent change anything about the scripts im writing, but that's ok. purely a misunderstanding... sorry for wasting time =)