Sha256: 1db4aa44492174615af2e2ea9b2e78fe89da26214287c299d8278281ee5cbcbb

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

# @gamefic.script standard/openable

module Openable
  attr_writer :openable
  def open= bool
    @open = bool
  end
  def open?
    @open ||= false
  end
  def closed?
    !open?
  end
  def accessible?
    open?
  end
end

respond :open, Use.available do |actor, thing|
  actor.tell "You can't open #{the thing}."
end

respond :open, Use.available(Openable) do |actor, thing|
  if thing.open?
    actor.tell "#{The thing} is already open."
  else
    actor.tell "You open #{the thing}."
    thing.open = true
  end
end

respond :close, Use.available do |actor, thing|
  actor.tell "You can't close #{the thing}."
end

respond :close, Use.available(Openable) do |actor, thing|
  if thing.open?
    actor.tell "You close #{the thing}."
    thing.open = false
  else
    actor.tell "#{The thing} is already open."
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gamefic-sdk-1.7.0 scripts/standard/openable.plot.rb