Log in

View Full Version : Live Streaming code discussion



Tgo01
09-04-2015, 11:34 PM
Here are the codes we discussed in the live stream coding discussion on Twitch TV tonight:



room = nil
if Spell[213].known? && Spell[213].affordable? && room != Room.current.id
Spell[213].cast
room = Room.current.id
end




loop{
GameObj.npcs.each{ |npc|
if npc.status !~ /frozen/ && npc.type =~ /aggressive/
Spell.cast[316]
break
end
}
sleep 0.5
}




name = nil
guess = nil
result = nil

while line = get
if line =~ /^(.*) whispers\, \"Coin flip (.*)/
name = $1
guess = $2
fput "toss coin"
while line = get
if line =~ /You toss your coin and catch it deftly with your other hand. It comes up (.*)\!/
result = $1
break
end
end
if guess =~ /#{result}/i
fput "whisper #{name} Congratulations! You're a winner!"
fput "give #{name} 1 silver"
else
fput "whisper #{name} Sorry, you lost."
end
end
end




name = nil
second_name = nil
guess = nil
result = nil
bet = nil

while line = get
if line =~ /(.*) just gave you (.*) coins? which you quickly pocket\./
name = $1
bet = $2.to_i
fput "whisper #{name} Whisper me 'heads' or tails' to make your guess."
while line = get
if line =~ /^(.*) whispers\, \"(heads|tails).*/i
second_name = $1
guess = $2
while line = get
if second_name != name
break
else
fput "toss coin"
while line = get
if line =~ /You toss your coin and catch it deftly with your other hand. It comes up (.*)\!/
result = $1
break
end
end
if guess =~ /#{result}/i
fput "whisper #{name} Congratulations! You're a winner!"
win_amount = (bet * 2)
fput "give #{name} #{win_amount} silver"
break
else
fput "whisper #{name} Sorry, you lost."
break
end
break
end
end
break
end
end
end
end




target = nil
renew_1013 = nil
renew_count = 0

renew_1013 = proc{
result = dothistimeout "renew 1013", 2, /Your concentration on unravelling the threads of mana is broken\.|Sing Roundtime 3 Seconds\.|But you are not singing anything\.|But you are not singing that spellsong\./i
if result =~ /Your concentration on unravelling the threads of mana is broken\.|But you are not singing anything\.|But you are not singing that spellsong\./
nil
elsif result =~ /Sing Roundtime 3 Seconds\./
renew_count += 1
if renew_count < 2
renew_1013.call
end
end
}

target = GameObj.npcs.find { |npc| npc.name =~ /kobold/ && npc.status !~ /dead/ }

if target
Spell[1013].cast(target)
waitrt?
waitcastrt?
renew_count = 0
renew_1013.call
end




steal = nil
person = nil

steal = proc{
result = dothistimeout "look #{person}", 2, /the Empath/i
if result =~ /the Empath|the Wizard/
fput "steal #{person}"
elsif result =~ /the Ranger/
nil
elsif result.nil?
result = dothistimeout "gld rank #{person}", 2, /is not part of your guild\./i
if result =~ /is not part of your guild\./
fput "steal #{person}"
elsif result.nil?
nil
end
end
}

GameObj.pcs.each{ |pc|
person = pc
steal.call
}




silver = nil

fput "wealth"
while line = get
if line =~ /You have no silver coins with you\./
break
elsif line =~ /You have but one coin with you\./
silver = 1
break
elsif line =~ /You have (\d+) coins? with you\./
silver = $1.to_i
break
end
end

if silver
fput "give Akono #{silver} silver"
end

fput "turn #{Char.name} disk"

container = GameObj.inv.find { |item| item.name =~ /backpack/ }
fput "look in my #{container}"
container.contents.each { |item|
if item.type =~ /box/
fput "get ##{item.id}"
fput "drop ##{item.id}"
end
}




while line = get
if line =~ /(.*) whispers "I need healing"/
person = $1
fput "heal #{person}"
elsif line =~ /(.*) dies/
person = $1
fput "skin #{person}"
elsif line =~ /(.*) waves at you./
person = $1
fput "wave #{person}"
end
end

ylandra
09-05-2015, 08:25 AM
It turns out I had to tweak it a bit... it was trying to cast 316 again when the critter got stunned, killed, or somehow managed to escape.


loop{
#break if ($my_target.status =~ /dead|gone/)
GameObj.npcs.each{ |npc|
if npc.status !~ /frozen|dead|stunned|gone/ && npc.type =~ /aggressive/
Spell[316].cast
break
end
}
sleep 0.5
}

Gnomad
09-05-2015, 09:38 AM
No vig? I'm disappointed.

Tgo01
09-06-2015, 11:10 PM
Answering scripting questions LIVE! RIGHT NOW!

http://www.twitch.tv/lord_dreaven

Whirlin
09-06-2015, 11:29 PM
Is this your attempt to counter my streaming Excel work? baahhh

Tgo01
09-06-2015, 11:30 PM
Is this your attempt to counter my streaming Excel work? baahhh

Damn right! I have to one up you :p

Tgo01
09-07-2015, 08:32 PM
Watch Whirlin and I LIVE! http://www.twitch.tv/lord_dreaven

http://www.twitch.tv/lordwhirlin