attempting to make a plugin to spawn giants - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: attempting to make a plugin to spawn giants (/thread-3366.html) |
attempting to make a plugin to spawn giants - Code_Blue - 07-14-2021 Hi, I am new to Lua and I wanted to modify the tutorial code a bit to create a plugin to spawn giants (1.12.2). I think I got most of it down, but I am having an issue with two different parts of it. Console Errors: [12:58:58] LUA: Plugins/SpawnGiants/spawngiants.lua:28: attempt to call method 'SpawnMob' (a nil value) [12:58:58] Stack trace: [12:58:58] Plugins/SpawnGiants/spawngiants.lua(28): (no name) [12:58:58] [C](-1): FindAndDoWithPlayer [12:58:58] Plugins/SpawnGiants/spawngiants.lua(35): (no name) [12:58:58] Stack trace end [12:58:58] Error in <attached> calling function <callback>() Code: Code: PLUGIN = nil I am new to Lua and new to programming in general. Any help would be appreciated (This is running on a raspberry pi, I am not sure if that makes any difference.) RE: attempting to make a plugin to spawn giants - 12xx12 - 07-14-2021 Hi, The Player doesn't contain a SpawnMob Method. You need to get the world object from the player and call the spawn method from there. Code: Player:GetWorld():SpawnMob(Player:GetPosition(), mtGiant, false) Edit: This wall cause the giant to spawn at the position of the player using the command. If you replace "Player" with "Giantee" you should get your desired result RE: attempting to make a plugin to spawn giants - NiLSPACE - 07-14-2021 Hi, welcome to the forum! The reason it's giving an error is because you're calling 'SpawnMob' on a player object. What you want is the world object, probably the world of the player on which you're trying to spawn a monster on. So this line: Player:SpawnMob(giant) would have to be replaced with something like this: Giantee:GetWorld():SpawnMob(Giantee:GetPosX(), Giantee:GetPosY(), Giantee:GetPosZ(), mtGiant, false); RE: attempting to make a plugin to spawn giants - 12xx12 - 07-14-2021 (07-14-2021, 03:15 AM)NiLSPACE Wrote: Hi, welcome to the forum! Doesn't the SpawnMob method take a vector as a position parameter? RE: attempting to make a plugin to spawn giants - NiLSPACE - 07-14-2021 I thought so as well, but the documentation showed individual coordinates: https://api.cuberite.org/cWorld.html#SpawnMob_1 But perhaps it's out of date. RE: attempting to make a plugin to spawn giants - 12xx12 - 07-14-2021 It should still work. The vector object just pushes three integers and then the API takes just three integers. I don‘t think anyone took the time to add this explicitly RE: attempting to make a plugin to spawn giants - Code_Blue - 07-14-2021 Success! Giant spawned. Thanks for your help everybody! |