Page 1 of 2

Any way to have 1000+ scripts?

Posted: Wed Jul 09, 2014 6:21 am
by Crimzon
I am scripting a lot for the wad I am working on and I heard that Zandronum does not support acs_namedexecute , so is there any way to have over 999 number of scripts?

RE: Any way to have 1000+ scripts?

Posted: Wed Jul 09, 2014 7:47 am
by Catastrophe
No. But you can save space by turning some scripts into functions instead.

Also, the there is a maximum variable limit of 128. Remember this.

RE: Any way to have 1000+ scripts?

Posted: Wed Jul 09, 2014 8:40 am
by Konda

Code: Select all

script 1 (int scriptnum)
{
  Switch(scriptnum)
  {
    case 1:
      //Script 1
      break;
    case 2:
      //Script 2
      break;
    [...]
    case 65536:
      //Script 65536
      break;
  }
}
Also I think there's a variable limit of 20 local variables per script. Not sure about the ones defined outside of a script.

RE: Any way to have 1000+ scripts?

Posted: Wed Jul 09, 2014 1:34 pm
by ZzZombo
Special scripts (ENTER, OPEN, etc) can be declared as named, actually, even right now.

Code: Select all

script "MyMod_OPEN" OPEN
{
//stuff
}
so you can use their numbers for other scripts. You can only do that to special scripts, because otherwise you won't be able to call them.

RE: Any way to have 1000+ scripts?

Posted: Wed Jul 09, 2014 2:08 pm
by ibm5155
Ehm
#define Blood_Script 1

script Blood_Script OPEN{
...
}
Now you have a named script that can be compiled on zandronum :lol:
Also I don't think there's a need for 1000 scripts, ofc you can reuse a lot of it, just use your brain a bit

Code: Select all

ex:
script 1 (void){ code(1); }
script 2 (void){ code(2); }
script 3 (void){ code(3); }
script 4 (void){ code(4); }

to

script 1 (int arg) { code(arg);}

RE: Any way to have 1000+ scripts?

Posted: Wed Jul 09, 2014 5:55 pm
by Crimzon
Wow every single one of you provided some nice information!

RE: Any way to have 1000+ scripts?

Posted: Fri Jul 11, 2014 1:24 am
by Catastrophe
ibm5155 wrote: Also I don't think there's a need for 1000 scripts, ofc you can reuse a lot of it, just use your brain a bit
Yeah there is. Making multiple mods compatible with each other.

RE: Any way to have 1000+ scripts?

Posted: Fri Jul 11, 2014 1:45 am
by Ijon Tichy
Konda wrote:

Code: Select all

script 1 (int scriptnum)
{
  Switch(scriptnum)
  {
    case 1:
      //Script 1
      break;
    case 2:
      //Script 2
      break;
    [...]
    case 65536:
      //Script 65536
      break;
  }
}
You can only have 128 cases per switch block, by the way.

RE: Any way to have 1000+ scripts?

Posted: Fri Jul 11, 2014 1:55 am
by Catastrophe
Ijon Tichy wrote:
Konda wrote:

Code: Select all

script 1 (int scriptnum)
{
  Switch(scriptnum)
  {
    case 1:
      //Script 1
      break;
    case 2:
      //Script 2
      break;
    [...]
    case 65536:
      //Script 65536
      break;
  }
}
You can only have 128 cases per switch block, by the way.
Interesting, I never knew about this one.

RE: Any way to have 1000+ scripts?

Posted: Fri Jul 11, 2014 3:29 am
by TheMightyHeracross
Well 999 * 128 = 127,872. That should do! :smile:

RE: Any way to have 1000+ scripts?

Posted: Fri Jul 11, 2014 5:10 pm
by Torr Samaho
ZzZombo wrote: Special scripts (ENTER, OPEN, etc) can be declared as named, actually, even right now.

Code: Select all

script "MyMod_OPEN" OPEN
{
//stuff
}
so you can use their numbers for other scripts. You can only do that to special scripts, because otherwise you won't be able to call them.
Are you sure that this really works properly and that "MyMod_OPEN" is not just converted to its internal ACS string number?

RE: Any way to have 1000+ scripts?

Posted: Sat Jul 12, 2014 12:57 am
by ZzZombo
With bcc.exe, I'm not sure, but why would latest acc.exe do that? Both produced .WADs that worked correctly in the end.

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 4:16 am
by fr blood
Hi there, you can also use this:

Code: Select all

script 1 (int Typ)
{
If(Typ == 0)
{
}
If(Typ == 1)
{
}
If(Typ == 2)
{
}
[...]
If(Typ == 366)
{
}
}
I never tested it above 100, but it gives you a lot of choice for a single script.

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 6:13 am
by Konar6
FYI you are the third one after ibm5155 and Konda to suggest this.

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 10:31 am
by Dusk
fr blood wrote: Hi there, you can also use this:

Code: Select all

horrible code
I never tested it above 100, but it gives you a lot of choice for a single script.
That is not only ugly but also very inefficient because the ACS VM will wind up testing all those conditions separately with O(n) complexity.

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 1:07 pm
by ibm5155
an else if would be welcome on blood code :lol:

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 2:54 pm
by Konda
You can also save script numbers by converting some scripts into functions. However you can't convert any script with delay() or tagwait() or anything that causes a delay, into a function. You also can't call functions from Decorate or via map specials. Only from an actual script you can call a function. But it's still an improvement.

I suppose you can also use switch blocks inside switch blocks to surpass the 128 cases limit, like this:

Code: Select all

Switch(script_number)
{
  case 0:
    [...]
    break;

  [...]

  case 126:
    [...]
    break;

  default:
    Switch(script_number)
    {
      case 127:
         [...]
         break;

      [...]

    }
    break;
}
Or if that's not going to work, then don't use Switchblockception:

Code: Select all

Switch(script_number)
{
  case 0:
    [...]
    break;
  
  [...]

  case 126:
    [...]
    break;

  default:
    break;
    //Not sure if this is actually necessary. If not, then replace this with case 127 and begin the next switch block with case 128
}

Switch(script_number)
{
  case 127:
    [...]
    break;

  [...]

  case 254:
    [...]
    break;

  default:
    break;
    //Same goes here
} 
:v

The complexity of that would be O(n/128) which is better than what ibm suggested (unless the switch statements operate exactly like the if/else statements). This is basically how to write horrible hacks 101.

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 3:02 pm
by Ivan
I always wondered, what is the reason for functions to not allow Delay in them? Does it break internally or what?

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 3:11 pm
by Konda
Ivan wrote: I always wondered, what is the reason for functions to not allow Delay in them? Does it break internally or what?
From a logical standpoint, functions' purpose is calculation (for example, abs function). So it wouldn't make much sense if it had delays in it. However, the void functions don't return anything so they're pretty much the same as scripts, so I don't know why they're not allowed to have delays in them. I am not sure, but I think delays are not allowed in functions for technical reasons, not logical reasons.

RE: Any way to have 1000+ scripts?

Posted: Tue Jul 29, 2014 6:25 pm
by Catastrophe
Ivan wrote: I always wondered, what is the reason for functions to not allow Delay in them? Does it break internally or what?
Well you do have acs_executewait but it takes up a precious script slot.