Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (25 sloc) 0.605 kb
8d119c9 @mcantelon Made read a shared command.
authored
1 syntax:
f1467d7 Made read command work for doors as well as props.
Mike Cantelon authored
2 - "read <prop:noun>"
3 - "read <door:noun>"
8d119c9 @mcantelon Made read a shared command.
authored
4
5 logic: |
6
f1467d7 Made read command work for doors as well as props.
Mike Cantelon authored
7 noun = arg['noun']
8
8d119c9 @mcantelon Made read a shared command.
authored
9 output = ''
10
f1467d7 Made read command work for doors as well as props.
Mike Cantelon authored
11 if noun.traits['text']
b4fc755 Changed the way reading and prop text work.
Mike Cantelon authored
12
f1467d7 Made read command work for doors as well as props.
Mike Cantelon authored
13 text = noun.traits['text']
395e370 Added logic so read can also read from files.
Mike Cantelon authored
14
15 # if text begins with ">" use text as filename
16 if text[0] == ?>
17
18 file = text[1..-1]
19
20 File.open("#{@game.path}#{file}", 'r') { |f|
21 output << f.read
22 }
23
24 else
25
f1467d7 Made read command work for doors as well as props.
Mike Cantelon authored
26 output << noun.traits['text']
395e370 Added logic so read can also read from files.
Mike Cantelon authored
27
28 end
478802c Fixed read command even triggering.
Mike Cantelon authored
29
f1467d7 Made read command work for doors as well as props.
Mike Cantelon authored
30 on_read_output = @game.event(noun, 'on_read')
8781524 Fixed issue with read.
Mike Cantelon authored
31
32 if on_read_output.class == String
478802c Fixed read command even triggering.
Mike Cantelon authored
33
34 output << on_read_output
35
36 end
37
8d119c9 @mcantelon Made read a shared command.
authored
38 else
478802c Fixed read command even triggering.
Mike Cantelon authored
39
8d119c9 @mcantelon Made read a shared command.
authored
40 output << "You look for words, but find none.\n"
478802c Fixed read command even triggering.
Mike Cantelon authored
41
8d119c9 @mcantelon Made read a shared command.
authored
42 end
43
44 output
Something went wrong with that request. Please try again.