Skip to content

Commit 28b6b78

Browse files
committed
Some little changes
1 parent 2f44603 commit 28b6b78

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Sources/Items.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Items.hpp"
22

3+
#include <cstring>
34
#include "string_hash.hpp"
45

56
#include "Minecraft.hpp"
@@ -19,7 +20,7 @@ Core::Game::ItemData *Core::Game::Items::SearchItemByName(const std::string& nam
1920
while (actualPtr <= endAddr) {
2021
Core::Game::ItemData *itemData = GetItemData((u32)actualPtr);
2122
if (itemData != NULL) {
22-
if (name.compare(itemData->idName2))
23+
if (std::strcmp(name.c_str(), itemData->idName2) == 0)
2324
return itemData;
2425
}
2526
actualPtr++;

examples/scripts/camera_zoom.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local playerCamera = Game.LocalPlayer.Camera
22
local Gamepad = Game.Gamepad
3-
local originalFOV = playerCamera.FOV
3+
local originalFOV = 70
44
local isZoom = false
55

66
Game.Event.OnKeyPressed:Connect(function ()

examples/scripts/change_item_in_hand.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
local player = Game.LocalPlayer
22
local gamepad = Game.Gamepad
3-
local coalId = Game.Items.findItemIDByName("coal")
4-
local diamondId = Game.Items.findItemIDByName("diamond")
3+
local coalId = nil
4+
local diamondId = nil
55

66
Game.Event.OnKeyPressed:Connect(function ()
77
if Game.World.Loaded then
88
if gamepad.isDown(gamepad.KeyCodes.DPADDOWN) then
9+
if coalId == nil then -- You cannot use findItem when the game isn't loaded, wait until World is loaded to prevent nil results
10+
coalId = Game.Items.findItemIDByName("coal") -- Make sure to not call this function many times as it can lag the game, use one time and store the value
11+
diamondId = Game.Items.findItemIDByName("diamond")
12+
end
913
local playerHand = player.Inventory.Slots["hand"]
1014
if playerHand.ItemID == coalId and playerHand.ItemData == 0 then
1115
playerHand.ItemID = diamondId

0 commit comments

Comments
 (0)