Add send_input api
This commit is contained in:
parent
2be15e49d7
commit
43bea26640
|
@ -81,4 +81,4 @@ Version v0.0.3
|
||||||
|
|
||||||
[#send_enter_game](classes/TeeworldsClient.md#send_enter_game)
|
[#send_enter_game](classes/TeeworldsClient.md#send_enter_game)
|
||||||
|
|
||||||
[#send_input](classes/TeeworldsClient.md#send_input)
|
[#send_input(input = {})](classes/TeeworldsClient.md#send_input)
|
||||||
|
|
|
@ -607,16 +607,28 @@ client.send_enter_game
|
||||||
|
|
||||||
client.connect('localhost', 8303, detach: false)
|
client.connect('localhost', 8303, detach: false)
|
||||||
```
|
```
|
||||||
### <a name="send_input"></a> #send_input
|
|
||||||
|
|
||||||
**Parameter: TODO**
|
### <a name="send_input"></a> #send_input(input = {})
|
||||||
|
|
||||||
|
**Parameter: Hash**
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```ruby
|
```ruby
|
||||||
client = TeeworldsClient.new
|
client = TeeworldsClient.new
|
||||||
|
|
||||||
# TODO: generated documentation
|
|
||||||
client.send_input
|
|
||||||
|
|
||||||
client.connect('localhost', 8303, detach: false)
|
client.connect('localhost', 8303, detach: false)
|
||||||
|
|
||||||
|
loop do
|
||||||
|
client.send_input(
|
||||||
|
direction: -1,
|
||||||
|
target_x: 10,
|
||||||
|
target_y: 10,
|
||||||
|
jump: rand(0..1),
|
||||||
|
fire: 0,
|
||||||
|
hook: 0,
|
||||||
|
player_flags: 0,
|
||||||
|
wanted_weapon: 0,
|
||||||
|
next_weapon: 0,
|
||||||
|
prev_weapon: 0)
|
||||||
|
end
|
||||||
```
|
```
|
||||||
|
|
|
@ -310,18 +310,18 @@ class TeeworldsClient
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_input
|
def send_input(input = {})
|
||||||
inp = {
|
inp = {
|
||||||
direction: -1,
|
direction: input[:direction] || -1,
|
||||||
target_x: 10,
|
target_x: input[:target_x] || 10,
|
||||||
target_y: 10,
|
target_y: input[:target_y] || 10,
|
||||||
jump: rand(0..1),
|
jump: input[:jump] || rand(0..1),
|
||||||
fire: 0,
|
fire: input[:fire] || 0,
|
||||||
hook: 0,
|
hook: input[:hook] || 0,
|
||||||
player_flags: 0,
|
player_flags: input[:player_flags] || 0,
|
||||||
wanted_weapon: 0,
|
wanted_weapon: input[:wanted_weapon] || 0,
|
||||||
next_weapon: 0,
|
next_weapon: input[:next_weapon] || 0,
|
||||||
prev_weapon: 0
|
prev_weapon: input[:prev_weapon] || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
Loading…
Reference in a new issue