Any way to have 1000+ scripts?
Posted: Wed Jul 09, 2014 6:21 am
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?
Leading the way in newschool multiplayer Doom online
https://zandronum.com/forum/
Code: Select all
script 1 (int scriptnum)
{
Switch(scriptnum)
{
case 1:
//Script 1
break;
case 2:
//Script 2
break;
[...]
case 65536:
//Script 65536
break;
}
}Code: Select all
script "MyMod_OPEN" OPEN
{
//stuff
}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);}
Yeah there is. Making multiple mods compatible with each other.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
You can only have 128 cases per switch block, by the way.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; } }
Interesting, I never knew about this one.Ijon Tichy wrote:You can only have 128 cases per switch block, by the way.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; } }
Are you sure that this really works properly and that "MyMod_OPEN" is not just converted to its internal ACS string number?ZzZombo wrote: Special scripts (ENTER, OPEN, etc) can be declared as named, actually, even right now.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.Code: Select all
script "MyMod_OPEN" OPEN { //stuff }
Code: Select all
script 1 (int Typ)
{
If(Typ == 0)
{
}
If(Typ == 1)
{
}
If(Typ == 2)
{
}
[...]
If(Typ == 366)
{
}
}
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.fr blood wrote: Hi there, you can also use this:I never tested it above 100, but it gives you a lot of choice for a single script.Code: Select all
horrible code
Code: Select all
Switch(script_number)
{
case 0:
[...]
break;
[...]
case 126:
[...]
break;
default:
Switch(script_number)
{
case 127:
[...]
break;
[...]
}
break;
}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
} 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.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.Ivan wrote: I always wondered, what is the reason for functions to not allow Delay in them? Does it break internally or what?