ATCP demo scripts

Share your scripts and packages with other Mudlet users.
Ilithyia
Posts: 43
Joined: Wed Mar 10, 2010 11:04 pm

Re: ATCP demo scripts

Post by Ilithyia »

The debug and error consoles didn't really have that much useful to say.

"LUA: ERROR running script CharVitals (CharVitals) ERROR:"

and

"[ERROR:] object:<event handler function> function
<>"

Ilithyia
Posts: 43
Joined: Wed Mar 10, 2010 11:04 pm

Re: ATCP demo scripts

Post by Ilithyia »

I wonder if maybe I should put the autosipping part in another script? Would that work?

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: ATCP demo scripts

Post by naftali »

Did you look where I said for the missing line? I realize now that nothing bolded but it looks like there should be something in between:
if currenthealth < siphealth then
send ("sip health")[/b]

It looks like you've repeated things to allow yourself to prioritize health, mana, or ego without actually putting the priority variable in there. I'm fairly sure that if the code you posted is the actual code it won't work because of that. Check out my ATCP autosipper for Achaea to see how prioritizing works - you need something like:

if healbalance == 1 and priority == 2 then
sip health or mana or ego
elseif healbalance == 1 and priority == 1 then
sip mana or health or ego
elseif healbalance == 1 then
sip ego or health or mana
end

Ilithyia
Posts: 43
Joined: Wed Mar 10, 2010 11:04 pm

Re: ATCP demo scripts

Post by Ilithyia »

So, I took out the redundancy in the sipping part of the script which leaves the following as the new script:

Code: Select all

status = {}

function CharVitals(event, arg)
		local r = rex.new( "NL:(\\d+)/100 H:(\\d+)/(\\d+) M:(\\d+)/(\\d+) E:(\\d+)/(\\d+) P:(\\d+)/(\\d+) N:(\\d+)/(\\d+) W:(\\d+)/(\\d+)" )
		if r:match( arg ) then
			status.next_level,
			status.current_health, status.max_health, 
			status.current_mana, status.max_mana, 
			status.current_ego, status.max_ego, 
			status.current_power, status.max_power, 
			status.current_endurance, status.max_endurance, 
			status.current_willpower, status.max_willpower = r:match( arg )
		end

siphealth = status.max_health*0.75
sipmana = status.max_mana*0.75
sipego = status.max_ego*0.75
berryhealth = status.max_health*0.50
berrymana = status.max_mana*0.50

currenthealth = status.current_health
currentmana = status.current_mana
currentego = status.current_ego

display(status)

echo("\nsiphealth = " .. siphealth)
echo("\nsipmana = " .. sipmana)
echo("\nsipego = " .. sipego)
echo("\nberryhealth = " .. berryhealth)
echo("\nberrymana = " .. berrymana)

echo("\ncurrenthealth = " .. currenthealth)
echo("\ncurrentmana = " .. currentmana)
echo("\ncurrentego = " .. currentego)
echo("\n\nhealbalance = " .. healbalance)
echo("\nberrybalance = " .. berrybalance)

if healbalance == 1 then
		if currenthealth < siphealth then
            send("sip health")
            healbalance = 0.5
		elseif currentmana < sipmana then
            send("sip mana")
            healbalance = 0.5
		elseif currentego < sipego then
            send("sip bromides")
            healbalance = 0.5
		end
end

if berrybalance == 1 and (currenthealth < berryhealth or currentmana < berrymana) then
        send("outr sparkleberry")
        send("eat sparkleberry")
        berrybalance = 0.5
end
end
The sipping is still not working, and I'm pulling my hair out. I have no idea why it won't work.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: ATCP demo scripts

Post by naftali »

Ok, another problem I've encountered a number of times (normally shows up in debug, but the other thing might have been blocking it). Try changing your currenthealth = status.current_health lines to this:

Code: Select all

currenthealth = tonumber(status.current_health)
currentmana = tonumber(status.current_mana)
currentego = tonumber(status.current_ego)

Ilithyia
Posts: 43
Joined: Wed Mar 10, 2010 11:04 pm

Re: ATCP demo scripts

Post by Ilithyia »

Now, it won't even parse. I went back to the code I first posted with the screenshot, and no luck. I feel like screaming. Why the heck will it not parse with the exact same code where it parsed before? I even added the script to a brand-spanking-new profile to see if there's something else interfering with it and no luck. ARGH!

------------
EDIT: OK, calmed down a bit.

This is what I get from the debug console:

Code: Select all

LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
new line arrived:There's water ahead of you. You'll have to swim in that direction to make it 

new line arrived:through.

new line arrived:3120h, 4800m, 4350e, 10p, 13144en, 22150w ex-

new line arrived:

LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
new line arrived:You pull a cosmic web down around your feet, and you sense that gravity will be 

new line arrived:your ally when entering water.

new line arrived:3120h, 4780m, 4350e, 10p, 13150en, 22149w x-

new line arrived:

LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
new line arrived:You have recovered equilibrium.

new line arrived:3120h, 4800m, 4350e, 10p, 13150en, 22149w ex-

new line arrived:

LUA: ERROR running script ATCP Sipper (ATCP Sipper) ERROR:
new line arrived:Seagulls wheel far overhead, letting out harsh squawks as they fly over.

new line arrived:3120h, 4800m, 4350e, 10p, 13150en, 22150w ex-

new line arrived:
So it looks like it's trying to run the script everytime the CharVitals event is raised. I wish it would tell me what the error -is-. *mutter, mutter*

This is the script I have now on a brand new profile.

Code: Select all

status = {}

function CharVitals(event, arg)
      local r = rex.new( "NL:(\\d+)/100 H:(\\d+)/(\\d+) M:(\\d+)/(\\d+) E:(\\d+)/(\\d+) P:(\\d+)/(\\d+) N:(\\d+)/(\\d+) W:(\\d+)/(\\d+)" )
      if r:match( arg ) then
         status.next_level,
         status.current_health, status.max_health, 
         status.current_mana, status.max_mana, 
         status.current_ego, status.max_ego, 
         status.current_power, status.max_power, 
         status.current_endurance, status.max_endurance, 
         status.current_willpower, status.max_willpower = r:match( arg )
      end

display(status)

end
Again, whenever I try to display(status), it shows that there's nothing in the table. I don't understand how this can be the case, when it was parsing before ......

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: ATCP demo scripts

Post by naftali »

restart mudlet? I dunno what went wrong, but when I was building mine similar things happen. Don't discard the code that seems to have broken everything until you can confirm that it's actually the cause. I can offer no explanation for this - re-initialize every variable the script uses, including the ones that should be local - make sure that the status table is empty, and everything else is nil. This is all black magic - when all else breaks, I try this crap and sometimes something I do fixes it. No reason any of this should, and if you want advice from someone knowledgeable ask Vadi or Demonnic or Ixokai on the #mudlet-help IRC channel.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: ATCP demo scripts

Post by Vadi »

Errors that happen inside event handler functions aren't properly reported in debug - to get a proper report, run the function directly and it'll tell you what's wrong.

Ilithyia
Posts: 43
Joined: Wed Mar 10, 2010 11:04 pm

Re: ATCP demo scripts

Post by Ilithyia »

Thanks, Naftali! I don't feel like such a dimwit now.

Thanks, Vadi, for the heads up! Unfortunately, I'm a dimwit, and I don't know what is meant by 'run the function directly'. Does that mean run the same script but without registering the CharVitals event handler?

Sorry about my confusion. I feel like I'm so close!

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: ATCP demo scripts

Post by Vadi »

Well, calling the function from an alias for a test would do it.

Post Reply