Results 1 to 4 of 4

Thread: Learning to Write Basic Scripts

  1. #1

    Default Learning to Write Basic Scripts

    I was playing around with writing a basic script for shattered that will ask for Alfred to make some bread while I'm burning down in TSC and castings buffs.

    The intent is to have it look and see if Alfred is in the room. If he is then ask for some bread and grab it when it drops. That part works fine. I also want to add a little redundancy to it such that. If he is not in the room instead of ending the script like it does now it waits a certain amount of time and checks again. Lets say it waits 15 seconds between checks. If Alfred is in the room but otherwise engaged in an activity and is unable to make bread at that time it wont get hung up looking for the bread to be dropped and instead times out from the waitfor after say 30 seconds. In this case the script could just end so that it isnt getting hung up. I tried to establish a label that i could use as a reference for a goto command to bound back to the top of the script. My attempt looked like so. Any thoughts from the experienced writers out there. I'm still very new at this but i imagine i will pick it up quickly. Still learning arrays.

    label 'MainLabel'
    if checkpcs.include?('Alfred')
    fput 'whisper alfred bread'
    waitfor "Alfred drops a spinach-paste steamed dumpling."
    multifput "get dumpling", "gobble my dumpling", "gobble my dumpling", "gobble my dumpling"
    else
    pause '15s'
    goto 'MainLabel'
    end

  2. #2

    Default

    Avoid labels and use proper loops instead.

    Code:
    while true
        if checkpcs.include?('Alfred')
            # the 30 here is the time to wait for the response in the third part
            res = dothistimeout 'whisper alfred bread', 30, /Alfred drops a .*\./
            if res.nil?
                # unknown result (alfred didn't make bread)
                # do what you want here
            else
                # alfred made bread
                multifput "get dumpling", "gobble my dumpling", "gobble my dumpling", "gobble my dumpling"
                
                # the break says "exit the loop" which will effectively end the script
                break
            end
        end
        
        # you need some sleep delay in loops to avoid maxing our your CPU
        sleep 0.25
    end
    Last edited by SpiffyJr; 03-06-2014 at 06:27 PM.
    It must be hard to type with ghostcrawlers penis lodged in your ass. - g++

  3. #3

    Default

    restbread-gsf should be on the repo and work for that purpose. I'm not playing anymore, so it won't get updated for newer bots, but it wouldn't be hard to add to it.

  4. #4

    Default

    Thank you for the advice. I take it the labels command doesn't work as well as just making a loop. I will remember that and use that for future scripts.

    Thank you as well for the alternate bread script. I didn't realize their was already on the repo.

Similar Threads

  1. Anyone else write poetry?
    By Vimp in forum Social Forum
    Replies: 126
    Last Post: 07-06-2010, 06:16 PM
  2. Write the future.
    By Sean of the Thread in forum Sports
    Replies: 2
    Last Post: 05-22-2010, 12:44 PM
  3. Finally wanna learn to write scripts
    By HSB in forum The Lich Project
    Replies: 15
    Last Post: 05-04-2010, 11:00 AM
  4. Write (and right) Like Palin
    By ClydeR in forum Politics
    Replies: 2
    Last Post: 12-04-2009, 08:18 AM
  5. Most basic of Lich scripts, help
    By Frozen Rope in forum The Lich Project
    Replies: 10
    Last Post: 01-10-2008, 09:27 AM

Posting Permissions

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