Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (ozgur, TipmyPip, AndrewAMD), 1,209 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple wdl to C-script negation conditional #370937
05/16/11 20:09
05/16/11 20:09
Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Ericmor Offline OP
Member
Ericmor  Offline OP
Member

Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Hi people,
Having trouble to find a working example of negation conditional in the manual.
A flag conditional code is translated from wdl to lite-C the following way...

Code:
//c-script
if(my.flag1==1)
 {
  my.flag4=1;
  my.flag1=0;
 }



Is writen this way in Lite-C:

Code:
//lite-C
if is(my,FLAG1)
 {
  set(my,flag4);
  reset(my,FLAG1);
 }



Now, how i translate the following wdl code?

Code:
//C-script
var variable_test;

if(my.flag1==0)
{
variable_test=my.FLAG1;
}



I really couldn´t find this one. Sorry for the stupid question... any help is appreciated.
Thanks in advance.

Re: Simple wdl to C-script negation conditional [Re: Ericmor] #370941
05/16/11 20:19
05/16/11 20:19
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Code:
var variable_test;
if (!is(my,FLAG1)) {
	variable_test = 0;
}


Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Simple wdl to C-script negation conditional [Re: JibbSmart] #370943
05/16/11 20:31
05/16/11 20:31
Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Ericmor Offline OP
Member
Ericmor  Offline OP
Member

Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Thanks JulzMighty!
I´ve tried combinations with the "(!)", but it was crashing... now works, wonder what i did wrong.
Seems like i can´t declare a flag as a value to a variable anymore...oh well.
Thanks again.

Re: Simple wdl to C-script negation conditional [Re: Ericmor] #370951
05/16/11 20:52
05/16/11 20:52
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
No worries! Here's some more info if you need, of how flags work in Lite-C.

A var is 32-bits. A flag is only 1 bit (since it is either 1 or 0). So a var can contain 32 flags. Every entity has a "flags" var that contains their flags (and some flags in a "flags2" component).

If you want more general purpose flags (like FLAG1...FLAG8) you can store your own in other entity skills, if you know how to access them.

The bitwise operators are used to interact with individual bits in a variable, and as such can be used to interact with flags.

For example, set(my,INVISIBLE) is the same as:
Code:
my.flags |= INVISIBLE;

That means, set all the bits in flags to 1 that are already set in flags OR are set in INVISIBLE. INVISIBLE is all 0s except for a "1" in the right place for the INVISIBLE flag.

It's worth investigating further as you get more into Lite-C.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Simple wdl to C-script negation conditional [Re: JibbSmart] #370980
05/16/11 23:04
05/16/11 23:04
Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Ericmor Offline OP
Member
Ericmor  Offline OP
Member

Joined: Apr 2007
Posts: 125
Brazil - São Paulo
Thanks again!
I wasn´t sure if the |= operator would work in a conditional (i´m using set/reset/toggle for them)so i didn´t even tried - thanks for the manual page tip!
By the way, in the examples of this page...
Code:
z += 1; // add 1 to x


I think they should fix that, someone might not understand (like me)!

Re: Simple wdl to C-script negation conditional [Re: Ericmor] #370982
05/17/11 00:28
05/17/11 00:28
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Ha! Yes, they should fix that. You should let them know in the "Blame The Manual" forum.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1