Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Variable changing with touch_start

Ebenezer Yoshikawa
Registered User
Join date: 1 Jul 2008
Posts: 7
04-07-2009 12:04
CODE

integer durum;

default
{
state_entry()
{
durum=0;
llWhisper(0,"Touch to animate wings");
}
touch_start(integer total_number)
{
if (durum=0)
{
durum==1;
}
else
{
durum==0;
}
llOwnerSay("Hadise");
llOwnerSay((string) durum);
}
}


Here is the code I wrote by looking at tutorials and references. This is supposed to send you a message 0 or 1 each time you touch. Unfortunately since I have a little bit problem with variables, the outcome is always 0. I am suspecting that at one place of the code that defines 'durum' as 0 overrides any possible change to it in if-else block. Any suggestions?
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
04-07-2009 12:11
durum==1;

This doesn't do anything the way you use it. == is for comparing a number to a variable; = is used to assign a number to a variable.


This should work:

CODE

integer durum;

default
{
state_entry()
{
durum=0;
llWhisper(0,"Touch to animate wings");
}
touch_start(integer total_number)
{
if (durum==0)
{
durum=1;
}
else
{
durum=0;
}
llOwnerSay("Hadise");
llOwnerSay((string) durum);
}
}
_____________________
Lennard Lopez
Registered User
Join date: 9 Oct 2007
Posts: 52
04-07-2009 12:12
Hi,

You swapped "=" and "==".


CODE

integer durum;

default
{
state_entry()
{
durum=0;
llWhisper(0,"Touch to animate wings");
}
touch_start(integer total_number)
{
if (durum==0)
{
durum=1;
}
else
{
durum=0;
}
llOwnerSay("Hadise");
llOwnerSay((string) durum);
}
}
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
04-07-2009 12:17
You could also just invert durum on every touch:

CODE

touch_start(integer num)
{
durum = !durum;
}
Ebenezer Yoshikawa
Registered User
Join date: 1 Jul 2008
Posts: 7
04-07-2009 12:29
Many thanks for the fast responses. I should focus on defining variables it seems.