Modding Q&A thread

Fluid CoreFluid Core Join Date: 2007-12-26 Member: 63260Members, Reinforced - Shadow
<div class="IPBDescription">Sharing your collected knowledge</div>Hello Community!

Lately I've been thinking about creating some mod again, this time for the gorge. Before I've been wrestling on a skulk view rotation mod, but although we got both view rotating and inputs changing it never quite worked out for the general case. The thing is, I think we as a community have so much knowledge about how to code different things, and someone probably know how to make a particular thing that have been bothering you work. So...

The intent of this thread is dual: asking for things you need help with, and replying to things you can help out with. I suppose it could become a form of modding Q&A thread. I will try to add the questions and answers to the first post for ease of access.


<b>Q: How do you find the wall normal for a non-wallwalking situation? Either for rotation or collision purposes, such as bouncing.</b>
A: ???

<b>Q: How do you make an attack "charge up" as you hold the attack key? Think in the sense of TF2 sniper with the huntsman.</b>
A: ???

Comments

  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    edited May 2012
    <!--quoteo(post=1936663:date=May 17 2012, 11:35 AM:name=Fluid Core)--><div class='quotetop'>QUOTE (Fluid Core @ May 17 2012, 11:35 AM) <a href="index.php?act=findpost&pid=1936663"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--><b>Q: How do you find the wall normal for a non-wallwalking situation? Either for rotation or collision purposes, such as bouncing.</b><!--QuoteEnd--></div><!--QuoteEEnd-->

    You can have a look at the wall walking code in WallMovementMixin:GetAverageWallWalkingNormal but basically you do a trace with a given direction to see if you hit anything.

    It's seems there is two kind of traces Shared.TraceCapsule and Shared.TraceRay, I'm not sure what's the difference, maybe TraceRay use only a line and TraceCapsule move the collision box.

    Anyway you can use this as an example from GetAverageWallWalkingNormal, once you did the trace you just need to check if it hit anything.

    startPoint is the start position of the ray and endPoint (startPoint + Vector(0, -wallWalkingRange, 0) in this case) the end of the ray.

    groundTrace.fraction is the fraction of the length at which the ray touched something, so if you want the distance you need to do fraction * (endPoint-startPoint):GetLength(). groundTrace.normal is the normal of what you touched, I'm not sure about groundTrace.entity but it probably tells you if you hit a player or something else.

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// Check if we are right above a surface we can stand on.
    // Even if we are in "wall walking mode", we want it to look
    // like it is standing on a surface if it is right above it.

    local groundTrace = Shared.TraceRay(startPoint, startPoint + Vector(0, -wallWalkingRange, 0), CollisionRep.Move, PhysicsMask.AllButPCs, EntityFilterOne(self))

    if (groundTrace.fraction > 0 and groundTrace.fraction < 1 and groundTrace.entity == nil) then
      return groundTrace.normal
    end<!--c2--></div><!--ec2-->
  • Fluid CoreFluid Core Join Date: 2007-12-26 Member: 63260Members, Reinforced - Shadow
    edited May 2012
    Thanks for the reply Yuuki! I see how that code works, but from my understanding of it, there is a trace in your negative y-direction (down from your model), and if it collides with something close enough, it will give you the normal of what the trace collided with. But I'm pretty sure this is just the secondary effect of what actually gives the wall normal. For example the actual rotation of the model of the skulk (in the case you supplied?) and the rotation of hydras would probably handle it more directly and not go through the need of actually wallwalking. I took a look at the hydra placement code and I didn't get how it worked. It got some angle and somehow got the correct rotation from that, but it was all pretty unclear how it happened. Sadly I'm on the wrong comp for supplying the code, but it's found in weapons/alien/hydrasomething.lua I think. Something else that probably use the wall normal, is the bouncing of grenades of surfaces, and I should probably take a look in that code too and see if there is any wallnormal and bounces in there.

    <i>But maybe I can use that by using the speed vector as the direction of the trace, and somehow making the fraction=1 the size of the model.</i>

    To clearify what I'm going to try to do with the code, I plan on making the gorge belly slide bounce against walls (angle of reflection same as angle of inclination naturally) and also get a speed boost during the bounce.

    For the charging up effect, I seek to make the spit chargable, dealing more damage and getting more mass the longer you hold. This way you can charge up your spits, dealing more damage but the range getting shorter. Once i got that working I can start tweaking splash effects and potential slowing (more with longer charge...)
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->To clearify what I'm going to try to do with the code, I plan on making the gorge belly slide bounce against walls (angle of reflection same as angle of inclination naturally) and also get a speed boost during the bounce.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I think the ray trace is the way to go for this, something like this :

    if bellySliding then

    do a trace in front of the gorge (in velocity or view direction)

    if trace hit a wall then

    flip velocity and add bounce
  • Fluid CoreFluid Core Join Date: 2007-12-26 Member: 63260Members, Reinforced - Shadow
    That's what I had in mind, and I'll try to see if I can get the ray working with it. The puzzling thing about the structure rotation I talked about was this piece of code:

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->                // Check for space
                    if structure:SpaceClearForEntity(coords.origin) then
                    
    [b]                    local angles = Angles()
                        angles:BuildFromCoords(coords)
                        structure:SetAngles(angles)[/b]
                        
                        if structure.OnCreatedByGorge then
                            structure:OnCreatedByGorge(self.lastCreatedId)
                        end
                        
                        player:AddResources(-cost)
                        
                        if self:GetActiveStructure():GetStoreBuildId() then
                            self.lastCreatedId = structure:GetId()
                        end
                        
                        // Jackpot
                        self.droppedStructure = true
                        player:SlowDown(1)
                        return true
                        
                    else<!--c2--></div><!--ec2-->

    It's in weapons/alien/DropStructureAbility.lua - it's clear that it does <i>something</i> with the angle... Just how it actually get it right is beyond me.
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    Well it just transform the coordinate representation (three axis) into angles (yaw, pitch, roll).

    The coordinates system is create by GetPositionForStructure :

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// Given a gorge player's position and view angles, return a position and orientation
    // for structure. Used to preview placement via a ghost structure and then to create it.
    // Also returns bool if it's a valid position or not.
    function DropStructureAbility:GetPositionForStructure(player)<!--c2--></div><!--ec2-->

    If you look into it, it actually does a ray cast :

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    local origin = player:GetEyePos() + player:GetViewAngles():GetCoords().zAxis * range

        // Trace short distance in front
        local trace = Shared.TraceRay(player:GetEyePos(), origin, CollisionRep.Default, PhysicsMask.AllButPCsAndRagdolls, EntityFilterTwo(player, self))<!--c2--></div><!--ec2-->
  • Fluid CoreFluid Core Join Date: 2007-12-26 Member: 63260Members, Reinforced - Shadow
    Trying to make something... We'll see if it works
  • therake6therake6 Join Date: 2011-12-04 Member: 136544Members
    <b>Q: How do you apply a force to a player such as that in the old version of gore(I think it was build 199)?</b>

    I already used setDisruptionDuration( ) in order to stun the player but I'm attempting to make him fly across the room.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    you could use player:SetVelocity().
  • BlasphemyBlasphemy Join Date: 2008-05-02 Member: 64201Members, NS2 Playtester, Subnautica Playtester
    When I edited the Cyst.lua file, I wanted to add some code to the Cyst:OnCreate() and Cyst:OnDestroy() functions.

    I added some lines of

    self.amblight = Client.CreateRenderLight()

    self.amblight:SetType( RenderLight.Type_Point )
    self.amblight:SetColor( Color(255,106;34) )

    and a couple other parameters, saved it and tried to test it ingame. But when I started a map it immediately kicked me saying that my Client differs from my Server, even though I just hosted one when I loaded my map.

    Can anyone tell me why that is?
  • fsfodfsfod uk Join Date: 2004-04-09 Member: 27810Members, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited June 2012
    <!--quoteo(post=1941936:date=Jun 7 2012, 02:06 AM:name=Blasphemy)--><div class='quotetop'>QUOTE (Blasphemy @ Jun 7 2012, 02:06 AM) <a href="index.php?act=findpost&pid=1941936"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->self.amblight = Client.CreateRenderLight()

    self.amblight:SetType( RenderLight.Type_Point )
    self.amblight:SetColor( Color(255,106;34) )<!--QuoteEnd--></div><!--QuoteEEnd-->

    Did you mistype a comma here Color(255,106<!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><b>;</b><!--sizec--></span><!--/sizec-->34)

    You also need to make sure you code is inside a "if(Client) then YOURCODE end" guard
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    Often the "Client differs from my Server" is caused by some bugs on the server (like forgot the if Client then).
    Look at the console while it's loading. You can also start a dedicated server so you got a dos console to look for errors without having to start the game.
  • BlasphemyBlasphemy Join Date: 2008-05-02 Member: 64201Members, NS2 Playtester, Subnautica Playtester
    edited June 2012
    Okay, so I'm fairly sure my problems stemmed from the semicolon when I was defining the color as my issues with client/server went away once I changed it from (;) to a (,).

    New problem though is when it is placing the lights, it is not next to the cyst. Although I imagine that is because I did not tell it to place the light at parent model location. Could someone tell me what type of strings I would need? Some kind of Get:SelfPos? Self:SetPos()?
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    edited June 2012
    Doing this from memory and been away from the programming for a few weeks..

    entity:GetCoords() or entity:GetModelCoords() where entity is the parent cyst. Then light:SetCoords() to place, where the set coords match the entity coords.

    Function names may be wrong, lack of practice breeds a lack of confidence :)

    Look at the code for the current glow for the cysts as this is a light that emanates at the point of the cyst, failing that check out twiliteblue's code for the cyst light mod he has done :)
  • HuzeHuze Insightful Join Date: 2003-11-12 Member: 22724Members, NS1 Playtester, NS2 Playtester, Squad Five Blue, Reinforced - Shadow
    You can check out how the alien commander 'cursor light' works in AlienCommander.lua:174

    This puts a light on the alien commander's cursor, using 'SetCoords', which is probably what you'll to position it on cysts.

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local mouseX, mouseY = Client.GetCursorPosScreen()
    local pickVec = CreatePickRay(self, mouseX, mouseY)
    local trace = Shared.TraceRay(self:GetOrigin(), self:GetOrigin() + pickVec*1000, CollisionRep.Select, PhysicsMask.CommanderSelect, EntityFilterOne(self))
    self.cursorLight:SetCoords(Coords.GetTranslation(trace.endPoint + trace.normal * 0.5))<!--c2--></div><!--ec2-->
  • BlasphemyBlasphemy Join Date: 2008-05-02 Member: 64201Members, NS2 Playtester, Subnautica Playtester
    edited October 2012
    Warning: I don't know how to code, so this is just the equivalent of me bashing my head against a wall.

    Well I was working a bit on the whole cyst lighting thing. I did actually manage to get a working version which you can use offline. But you can't join a server with this mod running, (client/server mismatch) so I was trying to figure out how to make it use Workshop. Note: A lot of the code was taken straight from twiliteblue's cyst mod.

    What it looks like.
    <a href="http://i.imgur.com/p0cL5.jpg" target="_blank"><img src="http://i.imgur.com/p0cL5l.jpg" border="0" class="linked-image" /></a>

    Basically my problem stems as such:

    1) I edited Cyst.lua
    2) That won't work when joining servers, need workshop
    3) Make a mod called CystLights, make lua file called CystLights.lua.
    4) Added the code
    5) Code is just the isolated parts of the changes I did to Cyst.lua


    Now obviously, this isn't working like it was when I changed Cyst.lua, so my question is what kind of code I would need in order to integrate this with Cyst.lua? I was looking at 6john's FlashLite code to see how he does it, and it does appear he uses a Class_ReplaceMethod. Although to me, it just looks as though he changes some wording in the code instead of inserting it into the original. I did try adapting it to use the format in his code, but it still didn't work. So what is it that I am doing wrong?


    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// CystLights mod

    Script.Load("lua/Cyst.lua")

    Cyst.kGlowIntensity = 2
    Cyst.kGlowRadius = 12
    Cyst.kGlowColor = Color(255/255, 128/255, 64/255)

    function Cyst:OnDestroy()

        if Client then
            
            if self.glow ~= nil then
                Client.DestroyRenderLight(self.glow)
            end
            
        end
        
    end

    function Cyst:OnInitialized()

        if Server then
        
        end

        elseif Client then

            // create the emissive light
            self.glow = Client.CreateRenderLight()
            
            self.glow:SetType( RenderLight.Type_Point )
            self.glow:SetCastsShadows( true )

            self.glowCoords = CopyCoords(self:GetCoords())
            self.glowCoords.origin = self.glowCoords.origin + self.glowCoords.yAxis * 0.6
            self.glow:SetCoords( self.glowCoords )
            self.glow:SetRadius( Cyst.kGlowRadius )
            self.glow:SetIntensity( Cyst.kGlowIntensity )
            self.glow:SetColor( Cyst.kGlowColor )
            self.glow:SetSpecular( true )
            self.glow:SetIsVisible(true)

        end
        
    end<!--c2--></div><!--ec2-->

    FlashLite
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local originalOnUpdateRender


    originalOnUpdateRender = Class_ReplaceMethod( "Marine", "OnUpdateRender",
        function(self)
            
            originalOnUpdateRender(self)
            
            if self.flashlightOn then
                // Only display atmospherics for third person players.
                local density = 0.1
                if self:GetIsLocalPlayer() and not self:GetIsThirdPerson() then
                    density = 0
                end
                self.flashlight:SetAtmosphericDensity(density)
                
            end
            
        end
    )<!--c2--></div><!--ec2-->
  • MCMLXXXIVMCMLXXXIV Join Date: 2010-04-14 Member: 71400Members
    edited October 2012
    Okay, so step one is to turn this into a function that makes use of Hooks instead of overwriting Cyst.lua entirely. For an easy example of this, have a look at Soul Catcher 2000 and copy what that does. It seems that FlashLite is doing something similar.

    To get it on the workshop, create a new mod in launch pad, get all your files into that folder and once it's working, click publish from there. There's a guide at the top of this modding forum.

    For a more advanced example look at fsfod's non-flash menu or Combat Mode, which are both using fsfod's "Class Hook" functionality and can make replacements at the beginning or end of functions without having to copy the whole function, making maintenance almost a non-issue for small projects.

    I think it's about time someone wrote a decent 'how to start a mod' guide... I'll give it a go this week.
  • BlasphemyBlasphemy Join Date: 2008-05-02 Member: 64201Members, NS2 Playtester, Subnautica Playtester
    Well I changed the code around so it uses that Class_ReplaceMethod hook. And initially, it appears as though it works. That is until I near finish compiling the map. Then it gives me a whole load of errors in lua files I never even reference in the script. This is now completely maddening and I do not understand why it is doing what it is doing.

    This is getting fairly frustrating considering I have to publish the mod, download the mod, load the map, load the map a second time, and THEN get my errors. Really wish the "test mod" button worked.

    CystLights.lua
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Class.lua")
    Script.Load("lua/Cyst.lua")

    local originalCystOnDestroy

    originalCystOnDestroy = Class_ReplaceMethod("Cyst", "OnDestroy",
        function(self)
        
            if Client then
                
                if self.glow ~= nil then
                    Client.DestroyRenderLight(self.glow)
                end
            
            end
        
            originalCystOnDestroy(self)
            
        end
    )

    local originalCystOnInitialized

    originalCystOnInitialized = Class_ReplaceMethod("Cyst", "OnInitialized",
        function(self)
        
            if Server then
        
        
            elseif Client then
        
                // create the emissive light
                self.glow = Client.CreateRenderLight()
            
                self.glow:SetType( RenderLight.Type_Point )
                self.glow:SetCastsShadows( true )

                self.glowCoords = CopyCoords(self:GetCoords())
                self.glowCoords.origin = self.glowCoords.origin + self.glowCoords.yAxis * 0.6
                self.glow:SetCoords( self.glowCoords )
                self.glow:SetRadius( Cyst.kGlowRadius )
                self.glow:SetIntensity( Cyst.kGlowIntensity )
                self.glow:SetColor( Cyst.kGlowColor )
                self.glow:SetSpecular( true )
                self.glow:SetIsVisible(true)

            end
        
            originalCystOnInitialized(self)
        
        end
    )<!--c2--></div><!--ec2-->

    The Console Mess
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Downloading mods
    Mounting mod from C:/Users/Chris/AppData/Roaming/Natural Selection 2/Workshop/m60a5889_1349683990
    Mounting mod from C:/Users/Chris/AppData/Roaming/Natural Selection 2/Workshop/m60a5889_1349683990
    Mounting mod from C:/Users/Chris/AppData/Roaming/Natural Selection 2/Workshop/m60a5889_1349683990
    Script Error #1: lua/SleeperMixin.lua:11: attempt to call global 'CreateMixin' (a nil value)
        Call stack:
        #1: lua/SleeperMixin.lua:11
        #2: Load [C]:-1
        #3: lua/Cyst.lua:11
        #4: Load [C]:-1
        #5: lua/CystLights.lua:4
        #6: Load [C]:-1
        #7: lua/Client.lua:3
    Script Error #2: lua/FireMixin.lua:10: attempt to call global 'CreateMixin' (a nil value)
        Call stack:
        #1: lua/FireMixin.lua:10
        #2: Load [C]:-1
        #3: lua/Cyst.lua:12
        #4: Load [C]:-1
        #5: lua/CystLights.lua:4
        #6: Load [C]:-1
        #7: lua/Client.lua:3
    Script Error #3: lua/UmbraMixin.lua:14: attempt to call global 'CreateMixin' (a nil value)
        Call stack:
        #1: lua/UmbraMixin.lua:14
        #2: Load [C]:-1
        #3: lua/Cyst.lua:13
        #4: Load [C]:-1
        #5: lua/CystLights.lua:4
        #6: Load [C]:-1
        #7: lua/Client.lua:3<!--c2--></div><!--ec2-->

    It proceeds for another 25 script errors before finally "loading" the map. Not that it means anything because the map doesn't load. If you want, I could PM you the entire console log, but it is fairly lengthy.
  • SpetsnazSpetsnaz Join Date: 2003-12-26 Member: 24761Members, Constellation
    <b>Q. How do I edit the orignal skins/models?</b>
  • RoyaleJoonsRoyaleJoons Join Date: 2012-11-04 Member: 166866Members
    <b>Q. Does one have to use 3ds max or are the plugin(s) avalible for Maya/Blender as well that one could use?</b>
  • ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
    edited November 2012
    <!--quoteo(post=2010098:date=Nov 4 2012, 04:15 PM:name=RoyaleJoons)--><div class='quotetop'>QUOTE (RoyaleJoons @ Nov 4 2012, 04:15 PM) <a href="index.php?act=findpost&pid=2010098"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--><b>Q. Does one have to use 3ds max or are the plugin(s) avalible for Maya/Blender as well that one could use?</b><!--QuoteEnd--></div><!--QuoteEEnd-->

    <b>A: </b>Just google it. I don't know what versions you're on, but here's a Blender plugin: <a href="http://colladablender.illusoft.com/cms/" target="_blank">http://colladablender.illusoft.com/cms/</a>
  • ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
    edited November 2012
    <b>Q: How to properly use hooks</b>

    I thought this would be something relatively simple, but for whatever reason I can't seem to get it to work. Below is a chunk of code from a mod I'm working on that's supposed to damage marine buildings when they're touched by infestation. To do this, I'm adding a bit of code to the Infestation_Server's UpdateInfestation function. But when I run the game it says that 'Global Class_ReplaceMethod (a nil value)'. I'm assuming I'm missing something here, probably something small and/or noobish as programming mistakes tend to be, so could someone be so kind as to point out what that mistake could be?

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Shared.lua")
    Script.Load("lua/InfestationMod_Balance.lua")
    Script.Load("lua/InfestationMod_ResGeneration.lua")
    Script.Load("lua/Infestation.lua")
    Script.Load("lua/InfestationMod_Cyst.lua")
            

    if Server then
            
        local originalUpdateInfestation
        
        originalUpdateInfestation = Class_ReplaceMethod("Infestation_Server", "Infestation:UpdateInfestation", function(deltaTime)

            Shared.Message("Inside InfestationMod_InfestationChanges.lua!")
            
            originalUpdateInfestation(deltaTime)
        
            //How large is the radius of infestation around the cyst?
            local smallestRadius = self:GetRadius()
            local biggestRadius = self.lastRadius or 0
        
            if smallestRadius > biggestRadius then
                smallestRadius, biggestRadius = biggestRadius, smallestRadius
            end
        
            local origin = self:GetOrigin()
            
            local function getMarineStructures(ent)
                return ent ~= nil and ent:GetTeamNumber() == kmarineTeamType
            end

            //Get list of marine buildings within that range
            local structure = Shared.GetEntitiesWithTagInRange("class:Structure", origin, biggestRadius, getMarineStructures)
            
            //When marine buildings are touched by infestation, damage them.
            for index = 1, #structure do
                Shared.Message("It works!")
                local dotMarker = CreateEntity(DotMarker.kMapName, self:GetOrigin() + Vector(0, 0.2, 0), kAlienTeamType)
                dotMarker:SetDamageType(kInfestationDamageType)
                dotMarker:SetLifeTime(kInfestationDuration)
                dotMarker:SetDamage(kInfestationDamage)
                dotMarker:SetRadius(1)
                dotMarker:SetDamageIntervall(kInfestationDotIntervall)
                dotMarker:SetDotMarkerType(DotMarker.kType.Static)
                dotMarker:SetTargetEffectName("bilebomb_onstructure")
                dotMarker:SetDeathIconIndex(kDeathMessageIcon.BuildAbility)
                dotMarker:SetOwner(self:GetOwner())
            
            end
            
        end)
        
    end<!--c2--></div><!--ec2-->

    EDIT:
    Updated code and question details. Still doesn't work, but I'm at least getting an error now. (Albeit one that doesn't make any sense.)
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    I can't tell you why it's not working, doesn't appear to be anything obvious to me from this piece of code. Interestingly I haven't been able to get my damage trigger to do any damage either :P

    One thing I would mention with you code.. It will also do DoT to marines in it's current format, if it was working, as players are also scriptactors....
  • ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
    Ah, that's true. Originally I'd had it as a Structure, but when that didn't work I changed it to ScriptActor. When that didn't work, I added in the Shared.message bit and found out that it was never even being called. Guess I never changed it back.
  • ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
    <!--quoteo(post=2010895:date=Nov 5 2012, 06:30 AM:name=ChaosXBeing)--><div class='quotetop'>QUOTE (ChaosXBeing @ Nov 5 2012, 06:30 AM) <a href="index.php?act=findpost&pid=2010895"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--><b>Q: How to properly use hooks</b><!--QuoteEnd--></div><!--QuoteEEnd-->


    A: I didn't add Script.Load("lua/Class.lua") to the top.
  • ByorunByorun Join Date: 2003-04-19 Member: 15661Members, Constellation
    <b>Q: What are Client and Server objects and where are they coming from?</b>
    from NS2Utility.lua
    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>if Server then
    Script.Load("lua/NS2Utility_Server.lua")
    end

    if Client then
    PrecacheAsset("ui/buildmenu.dds")
    end</div>

    <b>Q: Is there an api doc for the "behind the scenes" classes ?</b>
    from Player_Server.lua
    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>function Player:OnClientConnect(client)

    self:SetRequestsScores(true)
    self.clientIndex = client:GetId()
    self.client = client

    end</div>
    from the name of the variable "client" I assume that this is a client object but I cant find any documentation about what functions are available in this object
  • DghelneshiDghelneshi Aims to surpass Fana in post edits. Join Date: 2011-11-01 Member: 130634Members, Squad Five Blue, Reinforced - Shadow
    edited November 2012
    CyberTrunks: Both of what you are asking is hidden in the Engine. Client and Server are defined by the engine before anything even happens in Lua. Lua does not understand what classes are, "class(foo)" is an engine (C++) function call and the class "foo" is actually just a normal Lua table.

    There is no documentation for anything yet, so the only thing you can do is dig through the code to find functions and variables.
Sign In or Register to comment.