Post new topic    
Liquid Metal Slime
Send private message
Variables and Math Issue 
 PostFri Apr 04, 2014 7:00 pm
Send private message Reply with quote
Hey guys,

I have a script that increments a global variable twice by 3 each time. This variable starts out as 0. Once it is incremented to 6, it is divided by 3. Two should be the answer, but the script that checks that math always returns false to that statement and I'm not sure why.

Here are some excerpts of the scripts. Perhaps one of you guys know what might be going on.

Code:

plotscript,mfsword,begin
if (check tag (279)==false) then (
set tag (279,on)
play sound (35,false)
mflastpuzzle += 3
wait for all)
end

plotscript,mfshield,begin
if (check tag (280)==false) then (
set tag (280,on)
play sound (35,false)
mflastpuzzle += 3
wait for all )
end

plotscript,mfbook,begin
if (check tag (281)==false) then (
set tag (281,on)
play sound (35,false)
variable (mfnm)
mfnm := mflastpuzzle
mflastpuzzle := (mfnm / 3)
wait for all)
end

plotscript,mflastswitch,begin
if (mflastpuzzle == 2) then (
set npc direction (11,left)
play sound (35,false)
wait (10)
play sound (2,false)
write map block (55,41,61)
write map block (55,40,0)
write pass block (55,41,11)
wait for all)
else (
fight formation (0)
mflastpuzzle := 0
set tag (279,off)
set tag (280,off)
set tag (281,off)
)
end

Cornbread Chemist
Liquid Metal Slime
Send private message
 
 PostFri Apr 04, 2014 7:05 pm
Send private message Reply with quote
I left off the first part that actually declares the global and sets it to 0 (I think they are 0 by default but just wanted to make sure).

Code:
plotscript,setmfglobal,begin
if (check tag (282)==false) then (
play sound (35,false)
set npc direction (10,left)
wait (2)
set npc direction (10,down)
wait for all
set tag (282,on)
mflastpuzzle := 0
show text box (1814)
wait for textbox)
else (
play sound (35,false)
set npc direction (10,left)
wait (2)
set npc direction (10,down)
wait for all
show textbox (1814)
wait for textbox)
end

Cornbread Chemist
Super Slime
Send private message
Re: Variables and Math Issue 
 PostFri Apr 04, 2014 7:16 pm
Send private message Reply with quote
Meatballsub wrote:
Hey guys,

I have a script that increments a global variable twice by 3 each time. This variable starts out as 0. Once it is incremented to 6, it is divided by 3. Two should be the answer, but the script that checks that math always returns false to that statement and I'm not sure why.

Here are some excerpts of the scripts. Perhaps one of you guys know what might be going on.


It's not entirely clear how your scripts are intended to work, but here's a good debugging tip: put show value(mflastpuzzle) after every line that changes its value. That will let you monitor the variable as it changes.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Liquid Metal Slime
Send private message
 
 PostFri Apr 04, 2014 7:43 pm
Send private message Reply with quote
Thanks, and sorry I should have been more clear how they worked together.

I did find out the issue with the help of your suggestions though, and it boiled down to having a npc in the wrong place. Works like a charm now!
Cornbread Chemist
Display posts from previous: