Page 8 of 10 FirstFirst ... 678910 LastLast
Results 71 to 80 of 99

Thread: my script questions

  1. #71

    Default

    It's because the heirloom is a pIN which is matching "in" much earlier than you want so the entire first group is "that an unfortunate citizen lost after being attacked by a lesser griffin in Griffin's Keen"

    This is a great website to use when you're having trouble with a regex: https://rubular.com/

    Just enter your regex and the line you are matching and it will show you if it is matching correctly and which groups are being matched and all that good stuff.

  2. #72

    Default

    Am I doing this right here? the original was working good until I came across critters that drag you to another room...

    original
    Code:
    if Char.prof == "Cleric"
    	loop{
    		if Spell[213].known? and Spell[213].affordable?
    			Spell[213].cast and waitcastrt?
    			fput "stance defensive", "You are now in a defensive stance."
    			fput "kneel"
    			fput "search"
    			sleep 1
    			if checkbounty =~ /and should bring it back to one of the guardsmen/
    				waitrt?
    				sleep 1
    				fput "loot room"
    				break
    			else
    				until standing?
    					waitrt?
    					fput "stand"
    					waitrt?
    					sleep 0.2
    				end
    				move direction[number]
    			end
    		end
    		number += 1
    		number = 0 if number >= direction.count
    	}
    elsif Char.prof == "Empath"
    yada yada yada....
    updated version incase a critter drags me to another room. also, is there a command to tell the script to start over? or start from the beginning again?
    Code:
    if Char.prof == "Cleric"
    	loop{
    		if Spell[213].known? and Spell[213].affordable?
    			Spell[213].cast and waitcastrt?
    			fput "stance defensive", "You are now in a defensive stance."
    			fput "kneel"
    			fput "search"
    			if line =~ /You intently search the area for the heirloom/
    				sleep 1
    				if checkbounty =~ /and should bring it back to one of the guardsmen/
    					waitrt?
    					sleep 1
    					fput "loot room"
    					break
    				else
    					until standing?
    						waitrt?
    						fput "stand"
    						waitrt?
    						sleep 0.2
    					end
    					move direction[number]
    				end
    			elsif line =~ /You don't find anything of interest here/
    				waitrt?
    				(start script over)
    			end
    		end
    		number += 1
    		number = 0 if number >= direction.count
    
    	}
    Last edited by onurb; 09-27-2022 at 10:06 PM.

  3. #73

    Default

    Code:
    if Char.prof == "Cleric"
    	loop{
    		if Spell[213].known? and Spell[213].affordable?
    			Spell[213].cast
    			fput "stance defensive"
    			fput "kneel"
    			fput "search"
    			while line = get
    				if line =~ /You intently search the area for the heirloom/
    					sleep 1
    					if checkbounty =~ /and should bring it back to one of the guardsmen/
    						waitrt?
    						sleep 1
    						fput "loot room"
    						break
    					else
    						until standing?
    							waitrt?
    							fput "stand"
    							waitrt?
    							sleep 0.2
    						end
    						move direction[number]
    					end
    				elsif line =~ /You don't find anything of interest here/
    					waitrt?
    				end
    			end
    		end
    		number += 1
    		number = 0 if number >= direction.count
    	}
    I don't know exactly what you mean by starting the script over again.

  4. #74

    Default

    well when you run a script, it starts at line 1, top of the page

    is there a way to like dump everything in memory (ex what direction it was going to go next) and start at line 1 again?

  5. #75

    Default

    You can do a loop and set any variables to nil or 0. So you could set number = 0

    Or you can make the entire thing a method or procedure and call it when you need to.

    Otherwise I'm not aware of a way for a script to restart itself. The other option would be to have a second script running that looks for a global variable being set to true, then set that global variable to true when you want it to reset. Then the other script will stop the first script and start it again and set the variable to nil and continue looking for when it is set to true.

  6. #76

    Default

    I am suprised as complex and diverse as ruby is, it is unable to restart a script.

    even the wizard FE code was able to restart..

    start:
    put "hello
    goto start

  7. #77

    Default

    Well how about this...

    earlier in the script I have this

    Code:
    if location_name == "Graveyard" && critter_name == "skeleton"
    	start_script("go2", [ "1234" ])
    	wait_while { Script.running?("go2") };
    	direction = ["ne", "ne", "s", "sw", "w"]
    is there a way I can save that 1234 as a variable to be used below?

    Code:
    elsif line =~ /You don't find anything of interest here/
    		waitrt?
    		start_script("go2", [ "????" ])
    		wait_while { Script.running?("go2") };
    		number = 0
    	end

  8. #78

    Default

    Quote Originally Posted by onurb View Post
    I am suprised as complex and diverse as ruby is, it is unable to restart a script.

    even the wizard FE code was able to restart..

    start:
    put "hello
    goto start
    You can do something similar to that in Ruby.

    You could do:

    Code:
    stuff_to_do = proc{
    	code here
    	code here
    }
    Then whenever you want to call this block of code do: stuff_to_do.call

    You could be sure to nil our or zero out all of your variables at the top of the code so everything is starting over fresh if that's what you need.

  9. #79

    Default

    Quote Originally Posted by onurb View Post
    Well how about this...

    earlier in the script I have this

    Code:
    if location_name == "Graveyard" && critter_name == "skeleton"
    	start_script("go2", [ "1234" ])
    	wait_while { Script.running?("go2") };
    	direction = ["ne", "ne", "s", "sw", "w"]
    is there a way I can save that 1234 as a variable to be used below?

    Code:
    elsif line =~ /You don't find anything of interest here/
    		waitrt?
    		start_script("go2", [ "????" ])
    		wait_while { Script.running?("go2") };
    		number = 0
    	end
    Yeah you could set the variable before this code.

    So you could do for example:

    skeleton_graveyard_room_number = 1234

    Then do: start_script("go2", [ skeleton_graveyard_room_number ])

  10. #80

    Default

    wracking my brain on this all evening... trying to give armor support to the chars that don't already have it. But I don't want the screen scroll for doing a "spell active" on each char which seems to be working but it's giving armor support to chars that already have it. need help


    Code:
    GameObj.pcs.each{ |pc|
    	silence_me unless undo_silence = silence_me
    	line = Lich::Util.quiet_command_xml("spell active #{pc}", /currently has the following active effects/)
    	if line =~ /Armor Support/
    		fput "smile"
    	else
    		fput "armor support #{pc}"
    		sleep 5
    		waitrt?
    	end
    	silence_me if undo_silence
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •