Page 1 of 1

Special LUA scripts

Posted: Sun Aug 18, 2013 11:43 am
by John Adams
FooF, I have a feeling I never told you about this either ;) so here's some info for anyone scripting LUA going forward.

In the Spells folder (not sure why...) are 2 scripts: commands.lua and gm_spells.lua. Scat and I used these to perform repeated tasks or special commands, for example:

Code: Select all

function cast(Caster, Target, Type)
    if Type == "Examine" then
        Examine(Caster, Target)
    elseif Type == "Grab Soil" then
        GrabSoil(Caster, Target)
    elseif Type == "Plant Seeds" then
        PlantSeeds(Caster, Target)
    elseif Type == "Burn Tent" then
        BurnTent(Caster, Target)
    elseif Type == "Destroy Totem" then
        DestroyTotem(Caster, Target)
    elseif Type == "Smack Hive" then
        SmackHive(Caster, Target)
    elseif Type == "Help Down" then
        HelpDown(Caster, Target)
    elseif Type == "Read Gravestone" then
        ReadGravestone(Caster, Target)
    elseif Type == "ClimbTheBench" then
        ClimbTheBench(Caster, Target)
    elseif Type == "PullYourselfThroughTheFoliage" then
        PullYourselfThroughTheFoliage(Caster, Target)
    elseif Type == "InspectBox" then
        InspectBox(Caster, Target)
        elseif Type == "ThrowSnowball" then
                ThrowSnowball(Caster, Target)
    end
end
Use case is my Snowball spell will call the commands.lua script and pass "ThrowSnowball" as a parameter... and you get hit with a snowball.

In the old DB Milestone 1 content, BurnTent, HelpDown, etc... those were put in 1 common place so we're not hunting for special actions in thousands of script files.

gm_spells.lua was to handle things like Moonjump, silly little things for GMs to play with that are not part of the normal scripting.


I'd like theFoof to tell me how he handled things like this in FfS, so maybe we can archive these scripts if he doesn't want to use the same method going forward.

Re: Special LUA scripts

Posted: Sun Aug 18, 2013 5:39 pm
by thefoof
For these kind of updates I typically just create an entity command and use the casted_on function on the affected spawn to check the command_name, and do whatever should be done for that quest step.

Re: Special LUA scripts

Posted: Sun Aug 18, 2013 7:08 pm
by John Adams
Cool. Evolution is a good thing :) If your way of doing it makes more sense, then we can dismiss these older scripts. I'll keep them around for reference for now.

Thanks