Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script doesn't work
#1
Hello, please help me understand what did I do wrong with this code, I don't know why draw and messages "VISMENU HIDDEN" and "VISMENU SHOWN" don't appear.
http://pastebin.com/4pFUYCH1
I'm not very familiar with classess but this is basically a copy-paste of script "statistics.nut".
Reply
#2
I think I made this work. Try that:
Link
Reply
#3
Thank you! I've tried everything but I've missed it
title_DrawVisual = null;
Reply
#4
If you using class you have to remember, that any class vars, must be initialized in class constructor, and before initializing they have to be declared.

So for example:
Squirrel Script
  1. class Foo
  2. {
  3. constructor()
  4. {
  5. var1 = "Var 1";
  6. var2 = 921323;
  7. }
  8.  
  9. var1 = null;
  10. var2 = null;
  11. var3 = null; // This one isn't initialized so will be static member of this class
  12. };


Reply
#5
Yes,  I know that already, and actually I wonder why i can't make class like this


Code:
class Foo
{
    constructor()
    {
        table = {};
        table[1] = "Hello";
        table[2] = "XASDASDADSa";
        table[3] = 22;
    }

    for(local i = 1; i < 3; i++)
        table[i] = null;
};

compiler says: expected 'IDENTIFIER'
Reply
#6
(28.12.2015, 17:25)Tuv Wrote: Yes,  I know that already, and actually I wonder why i can't make class like this


Code:
class Foo
{
    constructor()
    {
        table = {};
        table[1] = "Hello";
        table[2] = "XASDASDADSa";
        table[3] = 22;
    }

    for(local i = 1; i < 3; i++)
        table[i] = null;
};

compiler says: expected 'IDENTIFIER'

Becasue doing this u spoil sytax of the class. Compiles says, that he wait for some identifier, which wasn't founded. In ur case u used reserved name table.

The correct way is:
Squirrel Script
  1. class Foo
  2. {
  3. constructor()
  4. {
  5. _table = [];
  6. _table.append("Hello");
  7. _table.append("XASDASDADSa");
  8. _table.append(22);
  9. // Or
  10. /*
  11.   _table = array(3); // Array size 3
  12.   _table[1] = "Hello";
  13.   _table[2] = "XASDASDADSa";
  14.   _table[3] = 22;
  15.   */
  16. }
  17.  
  18. _table = null;
  19. };



In squirrel we have array, and tables. They are different containers of data.

EDIT. If you really want to use tables then here is an example:
Squirrel Script
  1. class Foo
  2. {
  3. constructor()
  4. {
  5. _table = {};
  6. // Only way is create slot, and now will work
  7. _table[1] <- "Hello";
  8. _table[2] <- "XASDASDADSa";
  9. _table[3] <- 22;
  10.  
  11. // Slot can be deleted with keyworld delete slot;
  12. }
  13.  
  14. _table = null;
  15. };


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Script Ayate 3 2,961 27.12.2015, 14:12
Last Post: Buras

Forum Jump:


Users browsing this thread: