Skip to content

Commit

Permalink
LNX-178 Add printing only for user which created agent (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
EasyJB authored Aug 26, 2023
1 parent 52d33ca commit dd6b7c2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions entity/action/error_log/ErrorLog.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
extends LynxAction

var _text: String
var _user_id: String

@onready var _output_console = get_node("/root/Scene/CanvasLayer/UI/AgentCreator/ColorRect/OutputConsole")

func _init():
self.accepted_attributes = ["text"]
self.accepted_attributes = ["text", "user_id"]

func _execute():
self._output_console.print(self._text, Color.DARK_RED)
if _user_id == Globals.USER_ID:
self._output_console.print(self._text, Color.DARK_RED)
6 changes: 4 additions & 2 deletions entity/action/print/Print.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
extends LynxAction

var _text: String
var _user_id: String
@onready var _output_console = get_node("/root/Scene/CanvasLayer/UI/AgentCreator/ColorRect/OutputConsole")

func _init():
self.accepted_attributes = ["text"]
self.accepted_attributes = ["text", "user_id"]

func _execute():
self._output_console.print(self._text, Color.WHITE)
if _user_id == Globals.USER_ID:
self._output_console.print(self._text, Color.WHITE)
1 change: 1 addition & 0 deletions globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ var DEFAULT_ACTION_SPEED: float = 0.5
var ACTION_SPEED_MULTIPLIER: int
var OBJECTS_IN_CREATION: Array[int] = []
var BUSY_HTTP_STATUSES: Array[int] = [HTTPClient.STATUS_CONNECTING, HTTPClient.STATUS_REQUESTING]
var USER_ID: String = str(RandomNumberGenerator.new().randi())
2 changes: 1 addition & 1 deletion scene/AgentCreator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func post_agent(new_agent):

func create_agent(_code, _position = Vector2(0, 0), _id = randi(), _owner = ""):
var new_agent = Agent.instantiate()
new_agent.init(_position, _id, _owner, _code)
new_agent.init(_position, _id, Globals.USER_ID, _code)
post_agent(new_agent)
new_agent.queue_free()

Expand Down

0 comments on commit dd6b7c2

Please sign in to comment.