Data Realms Fan Forums http://45.55.195.193/ |
|
Lua AddInventoryItem Error *FIXED* http://45.55.195.193/viewtopic.php?f=73&t=20019 |
Page 1 of 1 |
Author: | blargiefarg [ Sun Oct 24, 2010 1:12 pm ] |
Post subject: | Lua AddInventoryItem Error *FIXED* |
I'm quite new to Lua, and I'm making a gun that teleports what it hits. The main problem right now is that I set the round to add a MOPixel to the actor it hits, but when the Round hits, it spits out this error This is the script Code: function Create(self) for actor in MovableMan.Actors do actor:AddInventoryItem("Teleporter Particle") end end I also tried this Code: function Create(self) self.TeleParticle = Teleporter Particle for actor in MovableMan.Actors do actor:AddInventoryItem(self.TeleParticle) end end Any ideas? |
Author: | Lizardheim [ Sun Oct 24, 2010 1:13 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Get a proper imagehost. |
Author: | Petethegoat [ Sun Oct 24, 2010 1:18 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Your picture is too small for us to see the error. The actual script would also be really helpful, but I'd guess you've got the wrong kind of arguments for AddInventory. |
Author: | blargiefarg [ Sun Oct 24, 2010 1:19 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Ok, fixed the image and added the script. Sorry about that |
Author: | Petethegoat [ Sun Oct 24, 2010 1:23 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Doesn't look like you can add MOPixels to an actors inventory via AddInventory. Not sure how you'd go about solving that, to be honest. |
Author: | blargiefarg [ Sun Oct 24, 2010 1:25 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Really? But I think Shook managed to do it with his Gazooka/Bloating bomb. Is there any alternative? |
Author: | findude [ Sun Oct 24, 2010 1:32 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Is that a goddamn global variable? A string without quotation marks? Or what is it? What are you smoking man? Quote: AddInventoryItem Adds an inventory item to this Actor. Arguments: * An pointer to the new item to add. Ownership IS TRANSFERRED! Pointer. You should atleast create said particle first, with CreateMOPixel("name") Well, if it actually works by a presetname as well, whatever, try the function ToMovableObject(pointer) Adittionally, the loop you are using right now will add it to every single actor that exists. You might need to create a new particle seperately each time the for loop runs. |
Author: | blargiefarg [ Sun Oct 24, 2010 1:46 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Could you possibly post some sample code to show what you mean? |
Author: | findude [ Sun Oct 24, 2010 2:15 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
I find it hard to believe that the code you posted results in the error you captured. "Teleporter Particle" is a string, line of characters. Not a particle, mopixel, squid, or anything else but a string. if you do Code: local part part = CreateMOPixel("Teleporter Particle") then part would be a pointer to MOPixel. if actor:AddInventoryItem(part) fails, try actor:AddInventoryItem(ToMovableObject(part)) If adding a particle to every single actors inventory is what you want to do, then you'd need to: Code: function Create(self) local part for actor in MovableMan.Actors do part = CreateMOPixel("Teleporter Particle") actor:AddInventoryItem(part) end end Why you'd want to do this, is beynond me, since no Lua updates are run outside MovableMan's direct ownership. (Ie. in an inventory) Get your s... stuff straight, man. |
Author: | blargiefarg [ Sun Oct 24, 2010 2:25 pm ] |
Post subject: | Re: Lua AddInventoryItem Error |
Okay, I understand now. I do not want to do this for every actor on the scene, I'm just trying to take this one step at a time. What would I do in order to add the MOP to only the actor the bullet hits? EDIT: Nevermind, I fixed it on my own. Thanks for the local part bit though |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |