I was looking through the unpacked assets and online and I can't find a way to create a notification. I am modifying scripts/items/rotting.lua and trying to send a notification based on food rotTime I noticed that the global player isn't accessible from rotting.lua, so I can't use player.remoteMessage Does anyone now of any other ways to create notifications? I would really like to create notifications like the ones on the bottom when you pick up items if that's possible.
Probably with world.sendEntityMessage() Scanning through /items/ I can see that's used in some code so clearly it is accessible. But then you need to know the player's ID I suppose. I haven't tried to do this. world.playerQuery() would give you the players so I think that's how you'd find them. I need to look at player scripts to give you a better answer. Something is obviously already set up.
Sorry for taking so long to reply, been really busy. I tried using world.playerQuery, but I don't believe world is accessible. [18:50:29.323] [Error] Exception while invoking lua function 'ageItem'. (LuaException) Error code 2, [string "/scripts/items/rotting.lua"]3: attempt to index a nil value (global 'world') Here is what I tried local entityID = world.playerQuery(entity.position(), 15, {order = "nearest"}) local playerUUID = world.entityUuid(entityID) world.logInfo("playerUUID" + playerUUID)
I'm pretty sure my checking showed world was exposed. It isn't impossible that not all world functions are though. Now your code has an issue. I believe playerUUID would be a string already so no need to do tostring(playerUUID) but I don't think you can use + to joint strings together normally. The normal way is to use .. ...unless some metamethod voodoo is in effect or I just didn't know that would actually work. Code: world.logInfo("\nplayerUUID = " .. playerUUID .."\n") Now that should work. Try that.
world.logInfo('world-info-blah') on line 8 produces error (LuaException) Error code 2, [string "/scripts/items/rotting.lua"]:8: attempt to index a nil value (global 'world')