Main
Projects
Art
Music
Scripting
LiveJournal
Forum
Links
Look But Don't Walk
by James `SPAM Man' Paige

This script is an excellent example of the "key is pressed" command. When you run it, the player will only be able to face a direction, not walk, until he presses Enter or Space.


include,plotscr.hsd

define script(1,look but dont walk,none)

script, look but dont walk ,begin

  suspend player

  variable (loop)
  set variable(loop,true)

  while (loop) do,begin

    #75 is the scancode for left arrow
    if (key is pressed(75)) then, begin
      set hero direction(me,west)
    end

    #77 is the scancode for right arrow
    if (key is pressed(77)) then, begin
      set hero direction(me,east)
    end

    #72 is the scancode for up arrow
    if (key is pressed(72)) then, begin
      set hero direction(me,north)
    end

    #80 is the scancode for down arrow
    if (key is pressed(80)) then, begin
      set hero direction(me,south)
    end

    #57 is space bar, 28 is enter
    if (key is pressed(58),or,key is pressed(28)) then, begin
      #break the loop
      set variable(loop,false)
    end

    wait (1)
  end # bottom of while loop

  resume player

end

Site layout (c)2000 Jennifer Raby. Used by permission.