View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:26 am



Reply to topic  [ 10 posts ] 
 Lua AddInventoryItem Error *FIXED* 
Author Message
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post 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
Image

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?


Last edited by blargiefarg on Sun Oct 24, 2010 3:28 pm, edited 3 times in total.



Sun Oct 24, 2010 1:12 pm
Profile YIM
DRL Developer
DRL Developer

Joined: Fri May 15, 2009 10:29 am
Posts: 4107
Location: Russia
Reply with quote
Post Re: Lua AddInventoryItem Error
Get a proper imagehost.


Sun Oct 24, 2010 1:13 pm
Profile
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post 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.


Sun Oct 24, 2010 1:18 pm
Profile WWW
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post Re: Lua AddInventoryItem Error
Ok, fixed the image and added the script. Sorry about that


Sun Oct 24, 2010 1:19 pm
Profile YIM
User avatar

Joined: Mon Jun 15, 2009 4:02 pm
Posts: 905
Reply with quote
Post 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.


Sun Oct 24, 2010 1:23 pm
Profile WWW
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post Re: Lua AddInventoryItem Error
Really? But I think Shook managed to do it with his Gazooka/Bloating bomb. Is there any alternative?


Sun Oct 24, 2010 1:25 pm
Profile YIM
User avatar

Joined: Tue Dec 12, 2006 3:10 pm
Posts: 495
Location: Uncertain quantum state
Reply with quote
Post 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.


Sun Oct 24, 2010 1:32 pm
Profile
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post Re: Lua AddInventoryItem Error
Could you possibly post some sample code to show what you mean?


Sun Oct 24, 2010 1:46 pm
Profile YIM
User avatar

Joined: Tue Dec 12, 2006 3:10 pm
Posts: 495
Location: Uncertain quantum state
Reply with quote
Post 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.


Sun Oct 24, 2010 2:15 pm
Profile
User avatar

Joined: Mon Apr 05, 2010 8:04 am
Posts: 149
Location: Under your bed
Reply with quote
Post 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


Sun Oct 24, 2010 2:25 pm
Profile YIM
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.059s | 13 Queries | GZIP : Off ]