Anisu2008-10-15 22:03:33
So with the treant system for mush being out I tried (and bare with me as this is my second attempt at lua, the first having failed for now because I need to learn more about the xml stuff in mush) to make an influencing thing similar as I have for cmud. The idea here was that I can use this script regardless of my level in influencing. The debating part is not attached since I am going to keep that secret for now. (eg. it is an example of how not to code )
like with treant, I simply made a require "influencer" in my main script file.
- my questions are, is the usage of arrays wise in this instance, or will it add up to the variables and databases used in treant (and in the future a powerlogging script) and come back to haunt me
- I sometimes like to overwrite my aliases, so is there a reason why using '/influencer_inftarget = "kethuru"' in the command line is not working.
- Is there an advantage to adding these kind of scripts to a plugin rather then using a require statement (keeping in mind that in the future it will be using treant's balance variables for automisation)
like with treant, I simply made a require "influencer" in my main script file.
CODE
--]--
if not influencer then
influencer = {}
end
-- Like all things in life, let us declare the variables
influencer_inftarget = "moo"
influencer_debtarget = "moo"
influencer_inftype = "begging"
influencer_mark = "me"
influencer_infstage = 1
influencer_begging = { ="begging", = "supplication", = "wheedling"}
influencer_empower = { = "compliments", = "admiration", = "praise"}
influencer_mocking = { = "teasing", = "mockery" , = "derision"}
influencer_paranoid= { = "rumours", = "distrust", = "conspiracies"}
influencer_lust= { = "flattery", = "charm", = "beguiling"}
influencer_village = { = "lectures", = "recitation", = "oration"}
-- the important part, the influencing function
function influencer:influ()
if influencer_inftype == "amnesty" then
  Send("influence " .. influencer_inftarget .. " with amnesty for" .. influencer_mark)
elseif influencer_inftype == "begging" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_begging)
  if influencer_begging == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "empower" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_empower)
  if influencer_empower == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "mocking" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_mocking)
  if influencer_mocking == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "paranoid" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_paranoid)
  if influencer_paranoid == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "lust" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_lust)
  if influencer_lust == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "village" then
  influencer:mindset()
  Send("influence " .. influencer_inftarget .. " with " .. influencer_village)
  if influencer_village == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
end
end
--now just some variable changing functions
function influencer:xi(name)
influencer_inftarget = name
Note("Influence target is now: " .. influencer_inftarget)
end
function influencer:chngtype(name)
influencer_inftype = name
Note("Influence type is now: " .. influencer_inftype)
end
function influencer:mark(name)
influencer_mark = name
Note("Amnesty mark is now: " .. influencer_mark)
end
function influencer:debtarget(name)
influencer_debtarget = name
Note("Debate target is now: " .. influencer_debtarget)
end
-- added so all functions are declared
function influencer:mindset()
end
return influencer
if not influencer then
influencer = {}
end
-- Like all things in life, let us declare the variables
influencer_inftarget = "moo"
influencer_debtarget = "moo"
influencer_inftype = "begging"
influencer_mark = "me"
influencer_infstage = 1
influencer_begging = { ="begging", = "supplication", = "wheedling"}
influencer_empower = { = "compliments", = "admiration", = "praise"}
influencer_mocking = { = "teasing", = "mockery" , = "derision"}
influencer_paranoid= { = "rumours", = "distrust", = "conspiracies"}
influencer_lust= { = "flattery", = "charm", = "beguiling"}
influencer_village = { = "lectures", = "recitation", = "oration"}
-- the important part, the influencing function
function influencer:influ()
if influencer_inftype == "amnesty" then
  Send("influence " .. influencer_inftarget .. " with amnesty for" .. influencer_mark)
elseif influencer_inftype == "begging" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_begging)
  if influencer_begging == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "empower" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_empower)
  if influencer_empower == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "mocking" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_mocking)
  if influencer_mocking == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "paranoid" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_paranoid)
  if influencer_paranoid == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "lust" then
  Send("influence " .. influencer_inftarget .. " with " .. influencer_lust)
  if influencer_lust == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
  elseif influencer_inftype == "village" then
  influencer:mindset()
  Send("influence " .. influencer_inftarget .. " with " .. influencer_village)
  if influencer_village == nil then
    influencer_infstage = 1
  else
    influencer_infstage = influencer_infstage + 1
  end
end
end
--now just some variable changing functions
function influencer:xi(name)
influencer_inftarget = name
Note("Influence target is now: " .. influencer_inftarget)
end
function influencer:chngtype(name)
influencer_inftype = name
Note("Influence type is now: " .. influencer_inftype)
end
function influencer:mark(name)
influencer_mark = name
Note("Amnesty mark is now: " .. influencer_mark)
end
function influencer:debtarget(name)
influencer_debtarget = name
Note("Debate target is now: " .. influencer_debtarget)
end
-- added so all functions are declared
function influencer:mindset()
end
return influencer
- my questions are, is the usage of arrays wise in this instance, or will it add up to the variables and databases used in treant (and in the future a powerlogging script) and come back to haunt me
- I sometimes like to overwrite my aliases, so is there a reason why using '/influencer_inftarget = "kethuru"' in the command line is not working.
- Is there an advantage to adding these kind of scripts to a plugin rather then using a require statement (keeping in mind that in the future it will be using treant's balance variables for automisation)
Unknown2008-10-15 22:11:16
Your target variables should be world variables, so you don't have to initialize them anew each time you load your session.
Your temporary variables can be stored inside your influencer table, as I do in all my Treant modules.
If you put them into a plugin, you won't be able to (easily) take advantage of Treant functionality, which is why I don't generally do plugins.
I'll eventually build a similar module that I use for Treant, so your code might help give me an idea of what to include, though it will be coded a little differently when I do it.
Your temporary variables can be stored inside your influencer table, as I do in all my Treant modules.
If you put them into a plugin, you won't be able to (easily) take advantage of Treant functionality, which is why I don't generally do plugins.
I'll eventually build a similar module that I use for Treant, so your code might help give me an idea of what to include, though it will be coded a little differently when I do it.
Unknown2008-10-16 14:38:37
I haven't completed it, obviously, but just for a comparison with your own module, here's how I started mine for Treant:
CODE
--]
require "display"
if not influence then
  influence = {
    = { "begging", "supplication", "wheedling" },
    = { "compliments", "admiration", "praise" },
    = { "teasing", "mockery", "derision" },
    = { "rumours", "distrust", "conspiracies" },
    = { "flattery", "charm", "beguiling" },
    = { "lectures", "recitation", "oration" }
  }
end
-- Allow overrides of the influencing types for different orgs or skill ranks
if my_influence then
  for k,v in pairs(my_influence) do
    influence = v
  end
end
-- Use your influence on a target
function influence:sway(targ, att)
  -- The type of influencing may be passed as a argument, retrieved from the world file, or just defaulted
  local attack = att or GetVariable("treant_influence_attack") or "charity"
  local methods = self
  if not methods then
    display.Error("Invalid influencing category. Valid options are: charity, empower, weaken, paranoid, seduce, village")
    return
  end
  SetVariable("treant_influence_attack", attack)
  -- The current method is indexed either by a world variable or starting at the first
  local index = GetVariable("treant_influence_index") or 0
  index = (index % table.getn(methods)) + 1  -- Wrap around after the last is used
  SetVariable("treant_influence_index", index)
  Send("influence " .. targ .. " with " .. methods)
end
return influence
require "display"
if not influence then
  influence = {
    = { "begging", "supplication", "wheedling" },
    = { "compliments", "admiration", "praise" },
    = { "teasing", "mockery", "derision" },
    = { "rumours", "distrust", "conspiracies" },
    = { "flattery", "charm", "beguiling" },
    = { "lectures", "recitation", "oration" }
  }
end
-- Allow overrides of the influencing types for different orgs or skill ranks
if my_influence then
  for k,v in pairs(my_influence) do
    influence = v
  end
end
-- Use your influence on a target
function influence:sway(targ, att)
  -- The type of influencing may be passed as a argument, retrieved from the world file, or just defaulted
  local attack = att or GetVariable("treant_influence_attack") or "charity"
  local methods = self
  if not methods then
    display.Error("Invalid influencing category. Valid options are: charity, empower, weaken, paranoid, seduce, village")
    return
  end
  SetVariable("treant_influence_attack", attack)
  -- The current method is indexed either by a world variable or starting at the first
  local index = GetVariable("treant_influence_index") or 0
  index = (index % table.getn(methods)) + 1  -- Wrap around after the last is used
  SetVariable("treant_influence_index", index)
  Send("influence " .. targ .. " with " .. methods)
end
return influence