Difference between revisions of "Talk:L4D2 Vscripts"

From Valve Developer Community
Jump to: navigation, search
(Squirrel VM table layout: new section)
m (Adding a quick note. Will move to article later.)
 
Line 1: Line 1:
 +
ent_script_dump is super useful.
 +
 
== Vscript Variables ==
 
== Vscript Variables ==
  

Latest revision as of 04:37, 3 February 2013

ent_script_dump is super useful.

Vscript Variables

I compiled a list of all of the variables read by the Director in the server binary. Here's The List. It could use some organization before being placed on the wiki. I also skipped the mutation variables since they're already known through the mutation .nut files. Most of them are self explanatory--if there's any questions about how some are used I might be able to look some of them up. --ProdigySim 01:48, 28 July 2010 (UTC)

That's a great looking list. I'm wondering about one thing, though. Official scripts used variables like ZombieSpawnInFog and it is either TRUE or FALSE. Why is it an INT in the binary? Is it because of the language itself? Thanks a lot for this! --ThaiGrocer 16:51, 28 July 2010 (UTC)
I don't even remember making that list, haha. Yes, it's probably just a semantics thing. As an int, false is 0 and true is everything else. --ProdigySim 07:17, 6 December 2010 (UTC)
Thanks a lot for your help and an explanation! All of the options you had on the list are in the article. --ThaiGrocer 07:42, 6 December 2010 (UTC)

Other functions

Does anyone know if there's any more functions than those used on official scripts? 'Cause it lacks a lot of event calls e.g. OnPlayerDeath. --Winded

I've been looking through the binary a little bit, and I don't really see anything else. The scripting language is set up so they can just call script functions by name whenever they want. This means calling functions in scripts is only added when it's convenient for Valve's mutations/scripting. Map makers can call functions from entity inputs, though. So there's that. If I find anything super useful in the binaries I'll be sure to shout about it. --ProdigySim 07:23, 6 December 2010 (UTC)
Thank you for checking it out. --Winded
Forgot to mention--a less-than-ideal substitute to event calls would be the Update() function, which runs on every game frame. Not the greatest thing to do, but with some trickery you'll be able to code a lot of things without causing too much CPU usage. --ProdigySim 07:26, 6 December 2010 (UTC)
I've tried (and partly succeeded on) making an asi mod for GTA IV, and it didnt have events, only checks like IsPlayerEnteringCar() that where used on a 'while' loop and at the end of it there was a wait for 100 milliseconds, so other stuff can be processed. As you said, it may be expensive for cpu, so I prefer not using a function like that. --Winded

Next()

Note: the Next() function for CEntities takes 1 parameter, should be: Next(null|prev)

As in

ent <- null;
while((ent = Entities.Next(ent)) != null)
{
   printl(ent);
}

I changed on the main page

Squirrel VM table layout

Not a lot is mentioned about the overall table layout of the squirrel VM in this article. It's worth noting a lot of these things. Here's a script I used as a mutation and some results: http://pastie.org/private/tpqmxmer3eypshecckogw As you can see the root namespace contains most of the function and class definitions mentioned on this page. Mutation scripts are loaded as the ::DirectorScript.ChallengeScript table. I'm not sure about where other VScripts are loaded by default, but that can be important I think. --ProdigySim 16:19, 4 July 2012 (PDT)