Defense, table issue

Post Reply
icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Defense, table issue

Post by icesteruk »

I seem to be having an issue with my defense table, some skills require certain things like 5 spark, 10 devotion etc which I track from gmcp but I am at a lost on how to put that into the defup.
Code: [show] | [select all] lua
class.def.Priest = {
fireblock = {
action = "evoke fireblock",
need = "5 spark",
balance = "needbalance",
},
nightsight = {
action = "nightsight",
need = "nothing",
balance = "none",
},
inspiration = {
action = "perform inspiration strength",
balance = "balance",
need = "none",
	},
}
Any one have an idea?

I thought maybe I could use something like..

reqs = function() tonumber(gmcp.Char.Vitals.spark > 5) then return true end,

in my defense tracking but im unsure how to put that into my defup :/

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Defense, table issue

Post by demonnic »

Code: [show] | [select all] lua
-- assuming defToPutUp = class.def.Priest.<something>. Also assumes you used class.def.Priest.<something>.req for the
-- dependency check and that the dependency check returns true if the needed dependencies are in place, and false otherwise, and .action is able to be fed into your queuing mechanism. You'll certainly have to adjust this code 
-- to your individual situation
local dependencyMet = false
if defToPutUp.req == nil then 
  dependencyMet = true
else 
  dependencyMet = defToPutUp.req()
end
if dependencyMet then
  --queue() here just stands in for however you want to queue up the defense to be put up... it's not a real function I'm aware of
  queue(defToPutUp.action)
end
I have not tested this, but something similar to the above should do it for you.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Defense, table issue

Post by icesteruk »

icesteruk wrote:reqs = function() tonumber(gmcp.Char.Vitals.spark > 5) then return true end,
can I use that in the code?? and just run deftoputup.reqs() like I would a script?

If so, thank you so much I didnt now that

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Defense, table issue

Post by demonnic »

You forgot the leading if part but in general yes

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Defense, table issue

Post by icesteruk »

yeah if deftop.reqs() then .. ?


Thanks dude your the best - not told you in months :P lol

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Defense, table issue

Post by demonnic »

No in the function declaration.
Though I would just do
Code: [show] | [select all] lua
req = function() return (tonumber(gmcp.Char.Vitals.spark) > 5) end

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Defense, table issue

Post by icesteruk »

soo, Having a huge issue, this suppose to be coming back false but its coming back true

reqs = function() return hasSkill("ReflexiveDiversion") and hasSkill("Dodging") end,

doing lua hasSkill("ReflexiveDiversion") and same for dodging, both return false, but it keeps putting it up :/
Code: [show] | [select all] lua
for skill, avoid in pairs(defenses.avoidance) do
if CanDef(skill) and not my.defenses[skill] then
send(avoid.action)
end
end -- end of avoidance
Code: [show] | [select all] lua
function CanDef(name)

if type(name.reqs) == "function" and not name.reqs() then return false end

return true
end

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Defense, table issue

Post by demonnic »

use reqs = function() return ( hasSkill("ReflexiveDiversion") and hasSkill("Dodging") ) end

Tested using lua REPL:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> myTable={}
> myTable.reqs = function() return (hasSkill("ReflexiveDiversion") and hasSkill("Dodging") ) end
> function hasSkill(str)
>> return false
>> end
> print(myTable.reqs())
false
>

Post Reply