PDA

View Full Version : Need some help with a script that used to work fine.



Glaves
04-20-2016, 10:40 PM
I made this awhile ago with the help of rloot from Gib.




However now i get this error


>;condition_check
--- Lich: condition_check active.
--- Lich: error: condition_check:21: syntax error, unexpected keyword_end, expecting end-of-input
C:/Users/Nectom/Desktop/lich/lich.rbw:2535:in `eval'
C:/Users/Nectom/Desktop/lich/lich.rbw:2535:in `block (3 levels) in <class:Script>'
--- Lich: condition_check has exited.

Or if anyone knows of a script that handles these things i can use and or look at for reference?

Glaves
04-20-2016, 10:41 PM
Not sure why the first part of code wont go into quotes.

RangerZ
04-20-2016, 11:35 PM
This is what I did to get it to work for me:


Remove one of the 'end' lines after the rloot def block
Change gcast to cast, because I don't have that method or whatever.
Assemble the string in the cast line to add a '#' so the cast target was valid.

(I only changed the first condition, cloud->wastebasket, for testing)


Seemed to work for me in the trophy room. Let me know what you think.


def rloot(what = nil)
return nil if GameObj.loot == nil
if what.to_i != 0
return nil unless GameObj.loot.find{|shit| shit.id.to_i == what.to_i}
return(GameObj.loot.find{|shit| shit.id.to_i == what.to_i}) if GameObj.loot.find{|shit| shit.id.to_i == what.to_i}
elsif what =~ /\s/
return(nil) unless GameObj.loot.find{|shit| shit.name =~ /#{what}/i}
return(GameObj.loot.find{|shit| shit.name =~ /#{what}/i}) if GameObj.loot.find{|shit| shit.name =~ /#{what}/i}
elsif what =~ /\w+/i
return nil unless GameObj.loot.find{|shit| shit.noun =~ /#{what}/i}
return(GameObj.loot.find{|shit| shit.noun =~ /#{what}/i}) if GameObj.loot.find{|shit| shit.noun =~ /#{what}/i}
end
return(GameObj.loot)
end


def condition_check
if rloot("wastebasket")
effect = rloot("wastebasket")
if checkmana > 6
cast(1007, "#" + rloot('wastebasket').id)
end
elsif rloot("void")
effect = rloot("void")
if checkmana > 18
gcast(417, rloot('void').id)
end
elsif rloot("tempest")
effect = rloot("tempest")
if checkmana > 13
gcast(417, rloot('tempest').id)
end
elsif rloot("swarm")
effect = rloot("swarm")
if checkmana > 18
gcast(417, rloot('swarm').id)
end
elsif rloot("vine")
effect = rloot("vine")
if checkmana > 18
gcast(417, rloot('vine').id)
end
elsif rloot("web")
effect = rloot("web")
if checkmana > 18
gcast(417, rloot('web').id)
end
end
end

loop{

pause 1
condition_check

}

Donquix
04-21-2016, 12:23 AM
Not sure why the first part of code wont go into quotes.

You're missing the closing right bracket on the opening QUOTE tag, you have "[quote", not "[quote]" In fact it looks like you pasted your text before it, instead of after it, because it's next to the closing [ /quote] tag :D

Glaves
04-21-2016, 11:14 PM
@RangerZ Fuck yeah dude, thank you! I've been gone for like 2 years and now my ruby is super rusty!

Glaves
04-21-2016, 11:19 PM
Totally didn't realize i wasn't defining gcast either. Here is the code that works if anyone would like to use this IMO very helpful script.



#
#
#

def gcast(spell, target = false, empbase = false)
unless empbase
if [Wounds.head, Scars.head, Wounds.nsys, Scars.nsys].max >= 2
respond "head or nerves issue, returning"
return
elsif [Wounds.rarm, Wounds.larm, Wounds.rhand, Wounds.lhand, Scars.rarm, Scars.larm, Scars.rhand, Scars.lhand].max == 3
respond "Severed arm issue, returning"
return
elsif ( [Wounds.rarm, Wounds.rhand, Scars.rarm, Scars.rhand].max >= 2 && ([Wounds.larm, Wounds.lhand].max >= 1 || [Scars.larm, Scars.lhand].max >= 2) ) || ( [Wounds.larm, Wounds.lhand, Scars.larm, Scars.lhand].max >= 2 && ([Wounds.rarm, Wounds.rhand].max >= 1 || [Scars.rarm, Scars.rhand].max >= 2) )
respond "both arms injured and preventing casting, returning."
return
end
end

waitrt?
waitcastrt? unless checkspell(515)
if target
if target.to_i == 0
multifput("prep #{spell}","cast #{target}") if prepped? =~ /none/i
fput "cast #{target}" unless prepped? =~ /none/i
elsif target.to_i > 0 || target.to_i < 0
multifput("prep #{spell}","cast ##{target}") if prepped? =~ /none/i
fput "cast ##{target}" unless prepped? =~ /none/i
end
else
multifput("prep #{spell}","cast") if prepped? =~ /none/i
fput "cast" unless prepped? =~ /none/i
end
end

def rloot(what = nil)
return nil if GameObj.loot == nil
if what.to_i != 0
return nil unless GameObj.loot.find{|shit| shit.id.to_i == what.to_i}
return(GameObj.loot.find{|shit| shit.id.to_i == what.to_i}) if GameObj.loot.find{|shit| shit.id.to_i == what.to_i}
elsif what =~ /\s/
return(nil) unless GameObj.loot.find{|shit| shit.name =~ /#{what}/i}
return(GameObj.loot.find{|shit| shit.name =~ /#{what}/i}) if GameObj.loot.find{|shit| shit.name =~ /#{what}/i}
elsif what =~ /\w+/i
return nil unless GameObj.loot.find{|shit| shit.noun =~ /#{what}/i}
return(GameObj.loot.find{|shit| shit.noun =~ /#{what}/i}) if GameObj.loot.find{|shit| shit.noun =~ /#{what}/i}
end
return(GameObj.loot)
end


def condition_check
if rloot("cloud")
effect = rloot("cloud")
if checkmana > 6
gcast(505, rloot('cloud').id)
end
elsif rloot("void")
effect = rloot("void")
if checkmana > 18
gcast(417, rloot('void').id)
end
elsif rloot("tempest")
effect = rloot("tempest")
if checkmana > 13
gcast(417, rloot('tempest').id)
end
elsif rloot("swarm")
effect = rloot("swarm")
if checkmana > 18
gcast(417, rloot('swarm').id)
end
elsif rloot("vine")
effect = rloot("vine")
if checkmana > 18
gcast(417, rloot('vine').id)
end
elsif rloot("web")
effect = rloot("web")
if checkmana > 18
gcast(417, rloot('web').id)
end
end
end

loop{

pause 1
condition_check

}