Some questions to get me started a bit faster

clankill3rclankill3r Join Date: 2007-09-03 Member: 62145Members, NS2 Map Tester, Reinforced - Shadow
Hi all,

I just started to mod for NS2 so I have to learn a lot.
I have a few questions, I hope someone can answer.

1.
I want to make changes to xeno, how can I quick research xeno?
Sandbox mode is broken as hell. None of the upgrades work for example (like celerity, cloack etc.) so I prefer not to test in sandbox cause I have no idea what else is broken.
And outside sandbox mode it takes really long to get to biomass 9.

2.
Can I add non moving bots? (dummies)

3.
How can a local function be overwritten?

In my file XenoChange I have:
local function TriggerXenocide(self, player)

    Print("xeno!");

    --rest of code


But it does not seem to overwrite the default TriggerXenocide cause I never see the print in the console.

I load the file with:
modEntry = [[
Shared: lua/XenoChange.lua,
Priority: 1
]]

That is it for now.




Comments

  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited May 2015
    1. Cheats are the devs best friend. In this case:
    cheats 1
    alltech
    allfree
    

    2. Use
    addpassivebot <number of bots> <teamNum> <test/com> <className>
    
    or just place a few dummy objects via
    create <item (classname)>
    
    or use normal boots and the
    freezebots
    
    commands. Overall just use what suits you best.

    3. local functions are only locally declared. That means you can't access them via the Global table. This make things a bit tricky. You can access local variables of a globally declared function (called "Upvalues" ) via the debug library. In case you don't want to dig to much into the Lua language you can use utility classes like Elixer (ofc you have to ship those with your mod).

    In the end i wouldn't recommend to directly work with stuff like the debug lib at the very start of learning Lua and NS2 modding. So i would suggest to just overload
    function XenocideLeap:OnPrimaryAttack(player)
    
    completely for now.

    Tip: Have a closer look at the linked Lua book to get used to Lua itself before getting dragged too much into the NS2 code ;).
  • clankill3rclankill3r Join Date: 2007-09-03 Member: 62145Members, NS2 Map Tester, Reinforced - Shadow
    Thanks!

    Is it save to remove all content in:

    C:\Users\Doeke\AppData\Roaming\Natural Selection 2

    Cause for some reason I can't load any map anymore. My mod is nothing more then the UberShotgun.
    Even if i create a new mod and leave it totally empty and build it then I still can't load any level.

    It says:
    Error: Unable to open 'maps/ns_tram.level' (usage 0x1)

    And then I get a File not Found error.

    I checked in explorer and ns_tram.level does exists.


  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited May 2015
    clankill3r wrote: »
    Thanks!

    Is it save to remove all content in:

    C:\Users\Doeke\AppData\Roaming\Natural Selection 2

    Cause for some reason I can't load any map anymore. My mod is nothing more then the UberShotgun.
    Even if i create a new mod and leave it totally empty and build it then I still can't load any level.

    It says:
    Error: Unable to open 'maps/ns_tram.level' (usage 0x1)

    And then I get a File not Found error.

    I checked in explorer and ns_tram.level does exists.


    Yes it is safe to remove your NS2 appdata folder (beside that you loose some of your settings). I never heard of a ns2 map named "ns_tram" must be a typo for "ns2_tram", right?
  • clankill3rclankill3r Join Date: 2007-09-03 Member: 62145Members, NS2 Map Tester, Reinforced - Shadow
    Thanks for taking all the time. I will make some blog posts soon on how to get started for other people.
    Your help means a lot. Soon I probably need less help...

    O damn, yeah I meant ns2_tram :)

    Back to new problems.

    1.

    I have my own 'XenocideLeap:OnPrimaryAttack(player)' function now which is just a copy of the original with an print in it.

    In game I get (when trying to xeno):
    attempt to call global 'TriggerXenocide' (a nil value)

    I tried to resolve it with adding:
    Script.Load("lua/Weapons/Alien/XenocideLeap.lua")
    

    But that does not work. How can I make it see the global function TriggerXenocide?


    2.

    Is there a way to copy all the content of the console, or save it to a file?



  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited May 2015
    1. Did you redefine the local function in your mods code? As said local functions are only locally declared? So if you override/overload a vanilla function and want to reuse code using a local function you have to make sure that the given local function is also declared in your mod file.

    2. All console output should be saved into the log.txt at %appdata%/Natural Selection 2/ (use win + r to get there ;) )
  • clankill3rclankill3r Join Date: 2007-09-03 Member: 62145Members, NS2 Map Tester, Reinforced - Shadow
    1. No, since the message complained about global. But I get it now.

    I got Xeno working now lol :)

    I do wonder, if I xenoside then it prints "xeno!!" to the console but it does this a lot of times (27x for example), why is that?

    function XenocideLeap:OnPrimaryAttack(player)
        
        Print("xeno!!")
        
        if player:GetEnergy() >= self:GetEnergyCost() then
        
            if not self.xenociding then
    
                TriggerXenocide(self, player)
                self.xenociding = true
                
            else
            
                if self.xenocideTimeLeft and self.xenocideTimeLeft < kDetonateTime * 0.8 then
                    BiteLeap.OnPrimaryAttack(self, player)
                end
                
            end
            
        end
        
    end
    


    2. Thx, the log makes it so much easier to search and read :)
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    That's because OnPrimaryAttack is checked and called each tick while primary attack is active. I think you should only print while self.xenociding is true.
Sign In or Register to comment.