|
Re: Help! Fogotten functions
[Re: romin2011]
#365207
03/24/11 14:53
03/24/11 14:53
|
Joined: Jan 2011
Posts: 797 Da wo du nicht bist! Muhahaha!
xxxxxxx
User
|
User
Joined: Jan 2011
Posts: 797
Da wo du nicht bist! Muhahaha!
|
Just use * -1 if you only want the against number! if you dont know that your number is positv/negativ and you only want a positiv(or negativ) value use abs()(*-1 for negativ ); to check that you dosent move! xxxxxxx
Es ist immer wieder erstaunlich, dass Leute die riesen Scripte schreiben die einfachsten sachen nicht können zb. mich mit SIEBEN x zu schreiben!
|
|
|
Re: Help! Fogotten functions
[Re: xxxxxxx]
#365209
03/24/11 15:09
03/24/11 15:09
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
The function "converting negative numbers to positive numbers and vice versa" is called negation. In order to use it you have to put a minus sign in front of the variable or constant.
var x = 3;
var y;
y = -x; // This makes the magic happen...
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Help! Fogotten functions
[Re: MasterQ32]
#365239
03/24/11 17:53
03/24/11 17:53
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
i would never use goto! your code will be much clearer without! That might be true for many cases but not for all. As you know assembly, you should also know that there are some pretty good reasons to use goto instead of blowing up your code base and thus making it harder to maintain. Anyway, to answer the question, yes, you can use goto to jump into any kind of loop (they are made by using goto anyway), but you aren't allowed to jump over variable declarations.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Help! Fogotten functions
[Re: WretchedSid]
#365392
03/26/11 10:36
03/26/11 10:36
|
Joined: Sep 2003
Posts: 9,859
FBL
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 9,859
|
Unless you really use assembler, which I suspect you don't, simply think of goto as if it was non existent. Don't use it. An example of a very old version of WDL to show what happens with GOTO and similar...
IF_EQUAL no_new_item,1;
GOTO no_new_item;
IF_EQUAL free_item,free_item.MAX;
END;
IF_NEQUAL free_item,1;
SKIP 1;
RULE i_item1=cur_item+new_amount;
IF_NEQUAL free_item,2;
SKIP 1;
RULE i_item2=cur_item+new_amount;
IF_NEQUAL free_item,3;
SKIP 1;
...
no_new_item:
SET no_new_item,0;
IF (tot_amount>20) {SET newstring,1;SET info_str,no_setitem_str;GOTO update_inv;}
SET MY.INVISIBLE,1;
PLAY_SOUND collect_snd,0.3;
RULE weight=weight+new_amount*new_weight;
update_inv:
IF_EQUAL LAYERS.3,inventory_ovr;
CALL update_inv;
|
|
|
|