Skip to content

Commit

Permalink
get player object and object from id
Browse files Browse the repository at this point in the history
  • Loading branch information
Sreyas-Sreelal committed May 20, 2024
1 parent a70ef84 commit d39aa42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions omp-gdk/src/scripting/objects/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ native!(SetObjectRot, object: struct Object, rotation: Vector3);
native!(GetObjectRot, object: struct Object, rotation: mut Vector3);
native!(GetObjectModel, object: struct Object, -> isize);
native!(SetObjectNoCameraCol, object: struct Object);
native!(IsValidObject, object: struct Object, -> bool);
native!(MoveObject, object: struct Object, data: ObjectMoveData, -> isize);
native!(StopObject, object: struct Object);
native!(IsObjectMoving, object: struct Object, -> bool);
Expand All @@ -37,6 +36,7 @@ native!(IsObjectMaterialSlotUsed, object: struct Object, materialIndex: isize, -
native!(GetObjectMaterialData, object: struct Object, materialIndex: isize, modelid: mut isize, textureLibrary: mut str, textureName: mut str, materialColour: mut Colour, text: mut str, materialSize: mut isize, fontFace: mut str, fontSize: mut isize, bold: mut bool, fontColour: mut Colour, backgroundColour: mut Colour, textAlignment: mut isize);
native!(IsObjectNoCameraCol, object: struct Object, -> bool);
native!(GetObjectID, object: struct Object, -> isize);
native!(GetObjectFromID, id: isize, -> struct Object);

// player object functions

Expand Down Expand Up @@ -65,6 +65,7 @@ native!(IsPlayerObjectMaterialSlotUsed, object: struct PlayerObject, materialInd
native!(GetPlayerObjectMaterialData, object: struct PlayerObject, materialIndex: isize, modelid: mut isize, textureLibrary: mut str, textureName: mut str, materialColour: mut Colour , text: mut str, materialSize: mut isize, fontFace: mut str, fontSize: mut isize, bold:mut bool, fontColour: mut Colour , backgroundColour: mut Colour , textAlignment: mut isize);
native!(IsPlayerObjectNoCameraCol, object: struct PlayerObject, -> bool);
native!(GetPlayerObjectID, object: struct PlayerObject, -> isize);
native!(GetPlayerObjectFromID, player: struct Player, id: isize, -> struct PlayerObject);

#[doc(hidden)]
pub fn load_functions() {
Expand All @@ -79,7 +80,6 @@ pub fn load_functions() {
load_function!(GetObjectRot);
load_function!(GetObjectModel);
load_function!(SetObjectNoCameraCol);
load_function!(IsValidObject);
load_function!(MoveObject);
load_function!(StopObject);
load_function!(IsObjectMoving);
Expand All @@ -97,6 +97,7 @@ pub fn load_functions() {
load_function!(GetObjectMaterialData);
load_function!(IsObjectNoCameraCol);
load_function!(GetObjectID);
load_function!(GetObjectFromID);

// player object functions

Expand Down Expand Up @@ -125,4 +126,5 @@ pub fn load_functions() {
load_function!(GetPlayerObjectMaterialData);
load_function!(IsPlayerObjectNoCameraCol);
load_function!(GetPlayerObjectID);
load_function!(GetPlayerObjectFromID);
}
5 changes: 5 additions & 0 deletions omp-gdk/src/scripting/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ impl Object {
pub fn get_id(&self) -> isize {
functions::GetObjectID(self)
}

/// Get Object from an id
pub fn from_id(id: isize) -> Option<Object> {
functions::GetObjectFromID(id)
}
}

pub struct PlayerObject {
Expand Down
6 changes: 6 additions & 0 deletions omp-gdk/src/scripting/players/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,12 @@ impl Player {
pub fn edit_player_object(&self, object: &PlayerObject) {
objects::functions::EditPlayerObject(self, object)
}

/// Get PlayerObject from an id
pub fn get_player_object_from_id(&self, id: isize) -> Option<PlayerObject> {
objects::functions::GetPlayerObjectFromID(self, id)
}

pub fn create_player_text_draw(&self, position: Vector2, text: &str) -> Option<PlayerTextDraw> {
textdraws::functions::CreatePlayerTextDraw(self, position, text)
}
Expand Down

0 comments on commit d39aa42

Please sign in to comment.