Add send_input api

This commit is contained in:
ChillerDragon 2023-09-17 19:42:47 +02:00
parent 2be15e49d7
commit 43bea26640
3 changed files with 29 additions and 17 deletions

View file

@ -81,4 +81,4 @@ Version v0.0.3
[#send_enter_game](classes/TeeworldsClient.md#send_enter_game)
[#send_input](classes/TeeworldsClient.md#send_input)
[#send_input(input = {})](classes/TeeworldsClient.md#send_input)

View file

@ -607,16 +607,28 @@ client.send_enter_game
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:**
```ruby
client = TeeworldsClient.new
# TODO: generated documentation
client.send_input
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
```

View file

@ -310,18 +310,18 @@ class TeeworldsClient
)
end
def send_input
def send_input(input = {})
inp = {
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
direction: input[:direction] || -1,
target_x: input[:target_x] || 10,
target_y: input[:target_y] || 10,
jump: input[:jump] || rand(0..1),
fire: input[:fire] || 0,
hook: input[:hook] || 0,
player_flags: input[:player_flags] || 0,
wanted_weapon: input[:wanted_weapon] || 0,
next_weapon: input[:next_weapon] || 0,
prev_weapon: input[:prev_weapon] || 0
}
data = []