0 Members and 3 Guests are viewing this topic.
:Data(1,0,1,0,0,0,0,0,0,1,0,1)->A
:If {B+A}=0:(stuff):Else:(other stuff):End
So, first off, I'd like to say hello all, as this is my first post here.Anyway, getting to the matter at hand, and I don't know if this is the right place, I have a question about how I should properly use the Data( command.I have a variable in my program, let's call it A, and I doCode: [Select]:Data(1,0,1,0,0,0,0,0,0,1,0,1)->Ato write to it. I then read from it like so:Code: [Select]:If {B+A}=0:(stuff):Else:(other stuff):Endwhere B is added to get me the value stored in the Bth position after A.This all works very well, just as I'd expect it to, but the problem arises when I try to assign different values to A using Data(. Throughout the course of a level in the game, all the values in A are set to 1. The problem I'm experiencing currently is that using Data( again to just rewrite to A doesn't work and re-entering the level after completion (without actually ending and re-executing the game, mind you) has all those values still set to 1. I've tried DelVar, storing 0 to the first place then Fill( -ing, using the same method I used to write to it (0->{B+A}) and just more Data(, but it seems I don't have an appropriate grasp on what I'm doing because all the values in A remain at 1 after being set once. I can't tell if I'm performing these actions wrong or it doesn't work, so I'm wondering if any of you gurus out there know how to rewrite a list of data to a variable. And also, is Data( even supposed to be used on variables, or am I writing onto the first byte which is the variable and then into the positions onward, which are not meant for the variable?The source is really big, messy, and hard to sift through so I won't include it unless someone thinks it'll help.
:0->W:Data(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)->W:If L=0:6->X:3->Y:Data(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,0,0,0)->W:.The length of this is equal to X*Y, as that's the number of positions in the room:End:If L=1:.Other level stuff, all in the same format as the first.
:For (Z,0,(X*Y)):If {Z+W}=1:.Draw the "on" sprite:Else:.Draw the "off" sprite:End
:For (Z,0,(X*Y)):If {Z+W}=1:0->{Z+W}:End:End