Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: deadworm222 on March 09, 2004, 02:56:10 PM

Title: nmbr.added=true;
Post by: deadworm222 on March 09, 2004, 02:56:10 PM
There's only ONE problem with the notepad system. I have defined each note lsomehow like this:
Code: [Select]
var note1;
note1.contents="Blaa";
note1.added=false;

Now, when I execute a function called AddNote() (which works like this: AddNote(note1) ), I would like it to set note1.added to true.

Code: [Select]
method AddNote(nmbr)
{

if(nmbr.added==false)
{

WinNotepad.DoStuff();

nmbr.added=true; // if nmbr was note1, this line would mean note1.added=true

}


}

But this doesn't work... Is there any way to make it work?

If's impossible to make it work, well, we have to resort to loads of state variables...

:D

Thanks!
Title: Re:nmbr.added=true;
Post by: Mnemonic on March 09, 2004, 04:13:22 PM
Yeah, it doesn't work, it sucks, doesn't it? >:( It seems I'll have to implement some sort of "ref" parameters...

The only thing I can suggest at the moment is to store all the notes in a global array and only send a note number as a parameter.
Title: Re:nmbr.added=true;
Post by: deadworm222 on March 10, 2004, 12:34:28 PM
One thing I always hoped WME would support is the eval function JavaScript has. I don't really know what the real description of eval is, but is something doesn't work, use eval and it works :D
Title: Re:nmbr.added=true;
Post by: Mnemonic on March 10, 2004, 04:52:56 PM
Jerrot already mentioned eval before, but it a little tricky, since the script compiler usually isn't part of the finished game (it's in a separated DLL). Anyway, do you think it would help in this case?
Title: Re:nmbr.added=true;
Post by: Jerrot on March 10, 2004, 07:25:48 PM
Jerrot already mentioned eval before, but it a little tricky, since the script compiler usually isn't part of the finished game (it's in a separated DLL). Anyway, do you think it would help in this case?

It was my first thought while reading the thread, too. But in most cases a workaround with arrays should work fine, you mostly use it to add numbers to variable names anyway...

So if it would eat speed from the engine, don't even think about realizing it. ;)

Title: Re:nmbr.added=true;
Post by: creatorbri on March 11, 2004, 09:04:23 PM
Jussi, are there any major drawbacks to using a global array?

Incidentally, since the WMScript is based on objects, it would make sense to be able to pass objects around by reference. In fact... Mnemonic, what if you took the PHP5 route, and force the engine to pass objects by reference? Would that cause any major problems?
Title: Re:nmbr.added=true;
Post by: Mnemonic on March 11, 2004, 09:08:13 PM
Mnemonic, what if you took the PHP5 route, and force the engine to pass objects by reference? Would that cause any major problems?

I'm not sure, I will have to investigate what would it take to implement it. I've added it to my ToDo list, I'll look into it.
Title: Re:nmbr.added=true;
Post by: deadworm222 on March 12, 2004, 12:04:11 PM
Jussi, are there any major drawbacks to using a global array?

I remember I only hypothetically considered this approach and found it problematic, but perhaps it can be done after all.