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



Reply to topic  [ 15 posts ] 
 Inventory copying/pasting 
Author Message
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Inventory copying/pasting
I made & butchered a script that, when pressing a certain button, is written to:
1. Create a certain actor, but not spawn it in the game
2. Copy the weapon being held by the controlled actor and give it to the unspawned actor
3. Delete the controlled actor and switch control to the new actor (which is created at the original actor's exact location)
4. Play a little sound and have the new actor FlashWhite() for a brief time.

The script has no initial errors in the console, but when I press the activation button I get the error:
Code:
"WWM.rte/******/************.lua:16: attempt to index global 'target' (a nil value)"


Here is the script, I appreciate any help I get with this.
http://pastebin.com/f1fd173be


Sat Jan 09, 2010 1:24 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Inventory copying/pasting
you explicitly have "target" defined as nil

what the ♥♥♥♥ did you expect to happen

you need to actually set the variable to a value in order to use it

gasp, lua does not read minds

EDIT: holy god this code is
literally
lafe-level

you arbitrarily set variables to local or global, randomly decide to omit the self prefix from semi-locals, have the object set to delete in your keypress statement such that the thing's going to remove itself before it finishes the code and oh my god this is comical


Sat Jan 09, 2010 2:25 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Inventory copying/pasting
90% of that code isn't by me, so, suck it.
Also, the object deleting itself where it does works perfectly and is intended.


Sat Jan 09, 2010 3:51 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Inventory copying/pasting
then you are absolutely terrible at copying code

your variable naming is all kinds of ♥♥♥♥ up and inconsistent as all hell

you also haven't even acknowledged that I found your problem in the first ten seconds of looking at your code

how exactly do you expect lua to know what self.target is
bonus: how exactly do you expect lua to know what just plain target is, when you haven't defined either of them


Sat Jan 09, 2010 4:02 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Inventory copying/pasting
OH GOD! All the unnecessary for loops! I can just hear CC screaming...excuse me while I clean this mess up...

EDIT:
Now that's how it's done. Quick and clean. 8) loadstring() for the win.
http://pastebin.com/m2883f5fc

So...umm....care to explain what self.target is supposed to be?


Last edited by Kyred on Sat Jan 09, 2010 4:39 am, edited 1 time in total.



Sat Jan 09, 2010 4:08 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Inventory copying/pasting
Kyred wrote:
So...umm....care to explain what self.target is supposed to be?

Dunno, I saw it in the original code and copied that out of it.


Thanks Kyred.


Sat Jan 09, 2010 4:37 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Inventory copying/pasting
the code won't work btw. It won't compile because I left self.target in there.

So does this script run on an actor? If so, I can fix this script up really quick for ya.


Sat Jan 09, 2010 4:39 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Inventory copying/pasting
Yes, it does. It's run on two of them, so that when one actor runs it, it turns into the other.


Sat Jan 09, 2010 4:41 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Inventory copying/pasting
whitty wrote:
Yes, it does. It's run on two of them, so that when one actor runs it, it turns into the other.
Gotcha. Will take me a few minutes to fix.

Edit: And by few I mean several...gotta test some stuff


Sat Jan 09, 2010 4:42 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Inventory copying/pasting
You're a lifesaver, unlike some.
Thanks man.


Sat Jan 09, 2010 4:51 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Inventory copying/pasting
This should work. I don't have the files to actually test it though. But it looks alright.

http://pastebin.com/m56d5b8f3


Sat Jan 09, 2010 5:03 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Inventory copying/pasting
whitty wrote:
You're a lifesaver, unlike some.
Thanks man.


Quote:
I appreciate any help I get with this.


very appreciative yeah

I told you what was wrong is it my fault you don't know enough to fix it


Sat Jan 09, 2010 5:10 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Inventory copying/pasting
Changed it up to this:
http://pastebin.com/m75d15c32
And getting an error on line 16: ")" expected near 'gun'


Sat Jan 09, 2010 5:12 am
Profile
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Inventory copying/pasting
Just caught some errors of mine. Quick fix:

http://pastebin.com/m4dc1a494


Sat Jan 09, 2010 5:16 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Inventory copying/pasting
Still the ")" expected near 'gun' error on line 16.
http://pastebin.com/m7f33bd7f

And if it's all possible, could you make the edits to what I have here instead of your version? It's a hassle to keep changing it back and forth every time.


Sat Jan 09, 2010 6:05 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 15 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.178s | 13 Queries | GZIP : Off ]