assistance please

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: assistance please

Post by Israafiyl »

Thank you again Mork. I had actually tried something similar and get the error:
<[string "function Alias226()..."]:3: bad argument #1 to 'pairs' (table expected, got nil)>
with both mine and your code. I am just not sure how else I could do this, do you have any ideas?

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: assistance please

Post by Belgarath »

I just noticed that in my code was a spelling error... tempExactMathTrigger should be tempExactMatchTrigger.
As for that error there, it seems that no table was given, hence the nil. I'm not too familiar with gmcp, so what does the output look like in display(gmcp.Room.Info.exits)?

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: assistance please

Post by Israafiyl »

exits in gmcp::
Room = {}
Info = {}

exits = {
ne = 11104,
u = 11095,
e = 12453,
d = 11089,
w = 13229,
nw = 11142
}

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: assistance please

Post by Belgarath »

Perhaps you have something misspelled or not set?

This worked fine for me:
Code: [show] | [select all] lua
local exits = {
   ne = 11104,
   u = 11095,
   e = 12453,
   d = 11089,
   w = 13229,
   nw = 11142
}

target = "Israafiyl"

for x in pairs(exits) do
   lastArrowDir = x
   send(string.format("shoot %s %s", target, x))
   tempArrowTrig = tempExactMatchTrigger("Your arrow strikes true!", [[
      send("say " .. target .. " Shot: " .. lastArrowDir)
      lastArrowDir = nil
      killTrigger(tempArrowTrig)
      ]])
   break
end

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: assistance please

Post by Israafiyl »

It seems because my snipe command sends all directions at once lastSnipeDir is set to the last room it tries to shoot even if I am off balance having shot in another direction

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: assistance please

Post by Belgarath »

What is your snipe command sending? It should stop at the first direction using 'break'.
Also, if it is doing it while you're off balance, make sure you actually have the checks in there to see if you have balance..

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: assistance please

Post by Israafiyl »

Ahh it seems I had taken out the break. As it is in your code it will only let me fire one directon, that being the first one on the gmcp.exits list. I tried to place it within the tempTrigger and that didn't seem to work either. I am unsure what the logical solution to this would be.

Again thank you for all your help Mork. I am a novice programmer who has just starting taking classes on such and this discussion has really been helping me with Java as well. I love how coding really makes you think! Cheers mate Ill keep playing with all you have helped me with

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: assistance please

Post by Israafiyl »

Also if anyone could. How would I go about making this work?

tempExactMatchTrigger("You prick "..target.." twice in rapid succession with your dirk.", [[
phase1Counter = phase1Counter % #phase1Commands + 1
killTrigger(tempDstabTrigg)
]]
the tempExactMatch wont match my target. I am unsure how else I may do such. I also tried
tempExactMatchTrigger("You prick \w+ twice in rapid succession with your dirk.", [[

and it did not seem to work either

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: assistance please

Post by Belgarath »

Make sure it matches the correct case! What I would suggest is make it into a regex trigger like this:
Code: [show] | [select all] lua
tempStabTrig = tempRegexTrigger("^You prick (.+) twice in rapid succession with", [[
   local target = string.lower(target)
   local match = string.lower(matches[2])
   if match == target then
      phaseCounter = phaseCounter % #phaseCommands + 1
      killTrigger(tempStabTrig)
   end
]])
Happy that you're learning, mate :)

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: assistance please

Post by Israafiyl »

Okay I have ran into another issue I cannot seem to solve...
I have a function:

function ill(ills)
if illusions[ills] ~= nil then
send("conjure "..target.. " illusion ".. illusions[ills],false)
end
end
This function pulls from my illusion database.
e.g. ill("hallucinations")

I want to make an alias that sends a random illusion from the list:

command = {
ill("hallucinations"),
ill("hypersomnia"),
ill("masochism"),
}

which = math.random(#command)
send(command[which])

But it keeps repeating the first function in the list and I get the error: bad argument #1 to 'random' (interval is empty)>

How may I get this to function properly?
Thank you!

Post Reply