Jump to content

On Create problem


Jal D`aron

Recommended Posts

I need some advice I started with a complicated idea which no surprise didn`t work first time and cut it back to basics .The mod premise was to add a dog that could be used to hunt rabbits so foraging find a stray works   make stray your dog works  play with dog works  hunt with dog does not work.  I cut the item to be hunted   in this instance a hare to a minimum have working textures  but all starts to go  wrong  here:

 

recipe Hunt with Your Dog
    {
    keep MSYourdog,
        Twigs=4, 
    Result:Twigs,
        Time:2000.0,
        Category:Survivalist,
        OnCreate:getHuntMSHare,
    }

 

in game timer works but does  keep the dog and get a twig but it will not kick into the server lua  here:

 

--- HUNTING MOD LUAS ---
--Small Dog--
function getHuntMSHare (items, result, player)
    local skill1 = player:getPerkLevel(Perks.Aiming);
    local skill2 = player:getPerkLevel(Perks.Sneak);
    local skill3 = skill1+skill2;
    local hunt = skill3+ZombRand(40);

    if hunt >= 38 then
        
        player:getInventory():AddItem("MedievalSmithing.MSHare");

    elseif hunt < 38 then
        player:Say("Oh only a stick");
    end
end
    

I have obviously missed something really simple  but 12 hours of looking at this and still can not see it   any help much appreciated

 

 

Link to comment
Share on other sites

Hi Jal.

 

Two things:

First:

Put a line like this at the end of the file the lua code is in:

pline("MedievalSmithing.lua loaded");

then look for that line in console.txt to make sure it's getting loaded.

 

Second:

Where exactly is that file located? Full path and filename if you can.

Link to comment
Share on other sites

thanks for the reply and No it is not loading .even the new rewrites which are as follows :

recipe Walk Your Dog
    {
    keep MSYourdog,
        Twigs=4, 
    Result:Twigs,
        Time:2000.0,
        Category:Animals,
      OnCreate:MSWalkdog,
    }

 

and in C:\Users\Owner\Zomboid\mods\Medieval Smithing/media/lua/server MSextra    my new and even more simplified version of the script:

 

----walking the dog.

function MSWalkdog (items, result, player)
    

     x = ZombRand(51);

    if x >= 17 then
        
        player:getInventory():AddItem("MedievalSmithing.MSHare");

    elseif x < 17then
        player:getInventory():AddItem("Base.TreeBranch");
         end     
    
end

 

 

No idea why this isn`t loading it is fairly basic your thoughts would be appreciated
    

Edited by Jal D`aron
Link to comment
Share on other sites

Fixed it I was so busy concentrating on the content of the file  forgot to check how it had been saved was as a txt not a .lua  thanks for your advice put me on the track to find where I had gone wrong once I knew it wasn`t loading  ...Many thanks again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...