diamond-lang 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a816bc76009b376879f5701b08383fdf4ff4fa2
4
- data.tar.gz: 7ba525b2610ded9f516d6383cea1fd0ff8016084
3
+ metadata.gz: eaa5da9142de0f8ec4609f1d6d444149eb2a550b
4
+ data.tar.gz: 182aa5acf12b0dea919de22caab131f0a0a87d5c
5
5
  SHA512:
6
- metadata.gz: 259b7b425a2fa1db817a49bca407b6807ed63b4060a33b0021cfd6daf64a88f174e62e92820f89a7b91874096c0449e0e114f855b3c2d90b9acf985908470e4f
7
- data.tar.gz: f2c1d554438a5d17ee170900f442e3901808a18b4f6a4927d155dfdf23ad4ef464197c5891f0bdfa2de646864ea15ccee7e00673b6d3cd23aaa70311d272504a
6
+ metadata.gz: b423e2fd595def543fba036d34947af35136162fd68c4b7864b28bb80b3b4b5a827ee0cfe5241818a6fe8f2808cf2347b0ecba85f6ea768d5dbd45ee92714733
7
+ data.tar.gz: f8ab2f9137752db32b4d711be285fe9fde90ae334c59e1ffb1e49d74d178100f2dc3a5e4d99fd9fc93df8931f759165d16671fb4f8fb65cae8f265d743907885
data/Gemfile CHANGED
@@ -11,6 +11,10 @@ group :development do
11
11
  gem "bundler", "~> 1.0"
12
12
  gem "jeweler", "~> 2.0"
13
13
  gem "simplecov", "~> 0.11"
14
+
15
+ gem "pry", "~> 0.10"
16
+ gem "pry-doc", "~> 0.8"
17
+ gem "byebug", "~> 8.2"
14
18
  end
15
19
 
16
20
  gem 'require_all', "~> 1.3"
@@ -9,6 +9,8 @@ GEM
9
9
  tzinfo (~> 1.1)
10
10
  addressable (2.4.0)
11
11
  builder (3.2.2)
12
+ byebug (8.2.1)
13
+ coderay (1.1.0)
12
14
  descendants_tracker (0.0.4)
13
15
  thread_safe (~> 0.3, >= 0.3.1)
14
16
  docile (1.1.5)
@@ -36,6 +38,7 @@ GEM
36
38
  rdoc
37
39
  json (1.8.3)
38
40
  jwt (1.5.2)
41
+ method_source (0.8.2)
39
42
  mini_portile2 (2.0.0)
40
43
  minitest (5.8.3)
41
44
  multi_json (1.11.2)
@@ -49,6 +52,13 @@ GEM
49
52
  multi_json (~> 1.3)
50
53
  multi_xml (~> 0.5)
51
54
  rack (~> 1.2)
55
+ pry (0.10.3)
56
+ coderay (~> 1.1.0)
57
+ method_source (~> 0.8.1)
58
+ slop (~> 3.4)
59
+ pry-doc (0.8.0)
60
+ pry (~> 0.9)
61
+ yard (~> 0.8)
52
62
  rack (1.6.4)
53
63
  rake (10.4.2)
54
64
  rdoc (3.12.2)
@@ -65,16 +75,21 @@ GEM
65
75
  json (~> 1.8)
66
76
  simplecov-html (~> 0.10.0)
67
77
  simplecov-html (0.10.0)
78
+ slop (3.6.0)
68
79
  thread_safe (0.3.5)
69
80
  tzinfo (1.2.2)
70
81
  thread_safe (~> 0.1)
82
+ yard (0.8.7.6)
71
83
 
72
84
  PLATFORMS
73
85
  ruby
74
86
 
75
87
  DEPENDENCIES
76
88
  bundler (~> 1.0)
89
+ byebug (~> 8.2)
77
90
  jeweler (~> 2.0)
91
+ pry (~> 0.10)
92
+ pry-doc (~> 0.8)
78
93
  rdoc (~> 3.12)
79
94
  require_all (~> 1.3)
80
95
  shoulda (~> 3.5)
data/README.md CHANGED
@@ -141,7 +141,7 @@ test #=> coords(9, 5, 6)
141
141
  ##Coordinate:
142
142
  A single coordinate on the x, y, or z axis.
143
143
 
144
- You can run `+` or `-`, which adds/substracts to the coordinate respectivly.
144
+ You can run `+` or `-`, which adds/substracts to the coordinate respectively.
145
145
 
146
146
  ###Examples:
147
147
 
@@ -153,10 +153,11 @@ DiamondLang::Helpers::Coordinate(:x, 6) + 5 #=> 11
153
153
  ~~~
154
154
 
155
155
  ##Conditions:
156
+ *Coming soon!*
156
157
  To make commands run on success, attach a block:
157
158
 
158
159
  ~~~rb
159
- c.test_for s(a: {r: 10}) do |c|
160
+ c.test_for s(a: {r: 10}) do |c| # conditionals coming soon!
160
161
  c.tell s(a: {r: 10}), 'hello'
161
162
  end
162
163
  #=> Command Block: test_for @a[r=10]
@@ -168,7 +169,7 @@ Diamond Lang is just a Ruby framework, so you can have awesome things, like vari
168
169
 
169
170
  ~~~rb
170
171
  close_players = s(a: {r: 10})
171
- c.test_for close_players do |c|
172
+ c.test_for close_players do |c| # conditionals coming soon!
172
173
  c.tell close_players, 'hello'
173
174
  end #=> @a[r=10]
174
175
  ~~~
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 1.0.0
@@ -0,0 +1,93 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: diamond-lang 1.0.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "diamond-lang"
9
+ s.version = "1.0.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Ben (@penne12_)"]
14
+ s.date = "2015-12-28"
15
+ s.description = "Making Minecraft 1 Command Creations with ruby. It's as easy as `c.say 123`"
16
+ s.email = "ben@bensites.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "diamond-lang.gemspec",
30
+ "examples/hello_world.rb",
31
+ "lib/diamond-lang.rb",
32
+ "lib/diamond-lang/command_chain.rb",
33
+ "lib/diamond-lang/helpers/block.rb",
34
+ "lib/diamond-lang/helpers/command.rb",
35
+ "lib/diamond-lang/helpers/command_block.rb",
36
+ "lib/diamond-lang/helpers/command_block_minecart.rb",
37
+ "lib/diamond-lang/helpers/constants.rb",
38
+ "lib/diamond-lang/helpers/coordinate.rb",
39
+ "lib/diamond-lang/helpers/coordinates.rb",
40
+ "lib/diamond-lang/helpers/entity.rb",
41
+ "lib/diamond-lang/helpers/errors/invalid_axis.rb",
42
+ "lib/diamond-lang/helpers/errors/invalid_coordinate_value.rb",
43
+ "lib/diamond-lang/helpers/errors/relative_cordinate_converted_to_argument.rb",
44
+ "lib/diamond-lang/helpers/errors/too_small.rb",
45
+ "lib/diamond-lang/helpers/falling_sand.rb",
46
+ "lib/diamond-lang/helpers/target_selector.rb",
47
+ "lib/diamond-lang/minecraft/commands/say.rb",
48
+ "lib/diamond-lang/one_command.rb",
49
+ "test/helper.rb",
50
+ "test/test_diamond-lang.rb"
51
+ ]
52
+ s.homepage = "http://bensites.com/diamond-lang/"
53
+ s.licenses = ["MIT"]
54
+ s.rubygems_version = "2.4.5.1"
55
+ s.summary = "A Ruby Framework for creating Minecraft 1 Command Creations."
56
+
57
+ if s.respond_to? :specification_version then
58
+ s.specification_version = 4
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_runtime_dependency(%q<require_all>, ["~> 1.3"])
62
+ s.add_development_dependency(%q<shoulda>, ["~> 3.5"])
63
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
64
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
65
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
66
+ s.add_development_dependency(%q<simplecov>, ["~> 0.11"])
67
+ s.add_development_dependency(%q<pry>, ["~> 0.10"])
68
+ s.add_development_dependency(%q<pry-doc>, ["~> 0.8"])
69
+ s.add_development_dependency(%q<byebug>, ["~> 8.2"])
70
+ else
71
+ s.add_dependency(%q<require_all>, ["~> 1.3"])
72
+ s.add_dependency(%q<shoulda>, ["~> 3.5"])
73
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
76
+ s.add_dependency(%q<simplecov>, ["~> 0.11"])
77
+ s.add_dependency(%q<pry>, ["~> 0.10"])
78
+ s.add_dependency(%q<pry-doc>, ["~> 0.8"])
79
+ s.add_dependency(%q<byebug>, ["~> 8.2"])
80
+ end
81
+ else
82
+ s.add_dependency(%q<require_all>, ["~> 1.3"])
83
+ s.add_dependency(%q<shoulda>, ["~> 3.5"])
84
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
85
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
86
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
87
+ s.add_dependency(%q<simplecov>, ["~> 0.11"])
88
+ s.add_dependency(%q<pry>, ["~> 0.10"])
89
+ s.add_dependency(%q<pry-doc>, ["~> 0.8"])
90
+ s.add_dependency(%q<byebug>, ["~> 8.2"])
91
+ end
92
+ end
93
+
@@ -60,13 +60,14 @@ require 'diamond-lang'
60
60
 
61
61
  class HelloWorld < DiamondLang::OneCommand
62
62
  def setup(c)
63
- c.say "hello world"
63
+ c.say "Hello World" #=> /say Hello World
64
64
  end
65
65
  def tick(c)
66
- c.testfor s(e: {name: "woof"}) do |c|
67
- c.say "<woof> woof"
66
+ c.say "Hello World! I can count to 10:" #=> /say Hello World! I can count to 10:
67
+ (1..10).each do |n|
68
+ c.say n #=> 10 times: /say n
68
69
  end
69
70
  end
70
71
  end
71
72
 
72
- HelloWorld.create_not_strict
73
+ HelloWorld.create
@@ -1,3 +1,4 @@
1
+ require 'byebug'
1
2
  require 'json'
2
3
  require 'require_all'
3
4
  require_rel 'diamond-lang'
@@ -10,5 +10,8 @@ module DiamondLang
10
10
  def method_missing(name, *args, &block)
11
11
  @commands << Helpers::Command.new(name.to_s.downcase, args, &block)
12
12
  end
13
+ def to_minecarts
14
+ self.commands.map{|command| command.to_minecart}
15
+ end
13
16
  end
14
17
  end
@@ -29,7 +29,7 @@ module DiamondLang
29
29
  CommandBlockMinecart.new self
30
30
  end
31
31
  def to_block(type=:chain)
32
- CommandBlock.new self, type
32
+ CommandBlock.new self, type, 0
33
33
  end
34
34
  end
35
35
  end
@@ -4,7 +4,7 @@ module DiamondLang
4
4
  Types = {
5
5
  chain: 'chain_command_block',
6
6
  impulse: 'command_block',
7
- repeat: 'repeating_command_block'
7
+ repeating: 'repeating_command_block'
8
8
  }.freeze
9
9
  def direction
10
10
  conditional? ? @data_value - 8 : @data_value
@@ -11,7 +11,7 @@ module DiamondLang
11
11
  def value=(value)
12
12
  @value = if value.is_a? Integer
13
13
  value
14
- elsif value.is_a?(String) && /^(?<rel>~)?(?<number>\d+)?$/ =~ value
14
+ elsif value.is_a?(String) && /^(?<rel>~)?(?<number>-?\d+)?$/ =~ value
15
15
  @relative = rel
16
16
  number.to_i
17
17
  else
@@ -4,21 +4,17 @@ module DiamondLang
4
4
  @@instance
5
5
  end
6
6
  def self.create(*args)
7
- @@instance = self.new(*args)
8
- puts @@instance.to_command
9
- end
10
- def self.create_not_strict(*args)
11
7
  @@instance = self.new(*args)
12
8
  puts @@instance.to_command.to_s.gsub(/\\?"(\w+?)\\?":/, '\1:')
13
9
  end
14
- def initialize(hieght=5, length=6, width=5, offset=coords(2, 2, 0), surrond=Helpers::Block.new('stained_hardened_clay', 13))
15
- @height = hieght # y
10
+ def initialize(height=5, length=6, width=5, offset=coords(2, 2, 0), surrond=Helpers::Block.new('stained_hardened_clay', 13))
11
+ @height = height # y
16
12
  @width = width # z
17
13
  @length = (length / 2).floor * 2 # x
18
- puts "WARNING: The length of your command block needs to be even. Rounding down to #{@length}." unless length % 2 == 0
19
- @offset = offset
14
+ puts "WARNING: The length of your command block needs to be even. Rounding down to #{@length}." unless length.even?
15
+ @offset = offset.freeze
20
16
  @corner1 = coords("~#{@offset.x}", "~#{@offset.y}", "~#{@offset.z}").freeze
21
- @corner2 = coords("~#{@offset.x + @length}", "~#{@offset.y + @height}", "~#{@offset.z + @width}").freeze
17
+ @corner2 = coords("~#{@offset.x._value + @length}", "~#{@offset.y._value + @height}", "~#{@offset.z._value + @width}").freeze
22
18
  @surrond = surrond
23
19
  end
24
20
  def startup(c)
@@ -35,22 +31,37 @@ module DiamondLang
35
31
  tick chain
36
32
  commands = chain.commands.map do |command|
37
33
  command.to_block
38
- end.reverse
39
- command_lines = commands.each_slice(@length - 2).each_with_index.map do |line, z|
40
- direction = 4 + (z % 2)
41
- end_block = line[-1]
42
- end_block.direction = direction - 2
43
- line[0..-2].map{|command|command.direction = direction}.push end_block
44
- end.reverse
45
- command_levels = command_lines.each_slice(@width - 2).map do |level|
46
- level.last.last.direction = 1 unless level == command_levels.to_a[-1]
47
- level
48
- end.reverse
34
+ end
35
+ command_lines = commands.each_slice(@length - 1).each_with_index.map do |line, z|
36
+ direction = z.even? ? 5 : 4
37
+ line.map! do |c|
38
+ c.direction = direction
39
+ c
40
+ end
41
+ end
42
+ command_levels = command_lines.each_slice(@width - 1).each_with_index.map do |level, y|
43
+ level = level.map! do |line|
44
+ line.last.direction = y.even? ? 3 : 2
45
+ line
46
+ end
47
+ level.last.last.direction = 1
48
+ level = level.each_with_index.map do |line, z|
49
+ z.even? ? line : line.reverse
50
+ end
51
+ y.even? ? level : level.reverse
52
+ end
53
+ command_levels.first.first.first.type = :repeating
49
54
  raise Errors::TooSmall if command_levels.to_a.length > (@height - 2)
50
55
  command_levels.each_with_index do |level, y|
51
- level.each_with_index do |row, z|
52
- row.each_with_index do |command, x|
53
- c.setblock coords("~#{@offset.x + x - 1}", "~#{@offset.y + y - 1}", "~#{@offset.z + z - 1}"), command.to_s(:replace)
56
+ level.each_with_index do |line, z|
57
+ z += @width - 1 - level.length if y.odd?
58
+ line.each_with_index do |command, x|
59
+ x += @length - 1 - line.length unless y.odd? == z.odd?
60
+ c.setblock coords(
61
+ "~#{x + @corner1.x._value + 1}",
62
+ "~#{y + @corner1.y._value + 1}",
63
+ "~#{z + @corner1.z._value + 1}"
64
+ ), command.to_s(:replace)
54
65
  end
55
66
  end
56
67
  end
@@ -66,7 +77,7 @@ module DiamondLang
66
77
  def to_command
67
78
  activator_rail = b('activator_rail').to_falling_sand
68
79
  redstone_block = b('redstone_block').to_falling_sand
69
- activator_rail.passengers.push(*chain.commands.map{|command| command.to_minecart})
80
+ activator_rail.passengers.push *chain.to_minecarts
70
81
  redstone_block.passengers << activator_rail
71
82
  redstone_block.summon coords('~', '~1', '~')
72
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diamond-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben (@penne12_)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-26 00:00:00.000000000 Z
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -94,6 +94,48 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.11'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-doc
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
125
+ - !ruby/object:Gem::Dependency
126
+ name: byebug
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '8.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '8.2'
97
139
  description: Making Minecraft 1 Command Creations with ruby. It's as easy as `c.say
98
140
  123`
99
141
  email: ben@bensites.com
@@ -110,6 +152,7 @@ files:
110
152
  - README.md
111
153
  - Rakefile
112
154
  - VERSION
155
+ - diamond-lang.gemspec
113
156
  - examples/hello_world.rb
114
157
  - lib/diamond-lang.rb
115
158
  - lib/diamond-lang/command_chain.rb