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



Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
 Upgrade, Enhancement Items 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Upgrade, Enhancement Items
After detecting the gun and if there exist any corresponding upgrades, you use
Code:
gun:SetNextMagazineName("Magazine Name")


Seeing the code you posted before, you might work the rest of the script with more ease now.


Mon Jun 25, 2012 10:17 pm
Profile
User avatar

Joined: Sun May 23, 2010 7:11 pm
Posts: 193
Reply with quote
Post Re: Upgrade, Enhancement Items
This will probably be a very stupid question but the gun in the code gets replaced with the PresetName of the actual gun? and does my above listed code actually work?


Mon Jun 25, 2012 10:22 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Upgrade, Enhancement Items
BrainChild wrote:
This will probably be a very stupid question but the gun in the code gets replaced with the PresetName of the actual gun?


I didn't get the question =P


BrainChild wrote:
and does my above listed code actually work?


It doesn't look wrong at all, so I think it will work. Maybe you'll have to make some small changes, but I'm pretty sure you'll get it right after some tries.


Mon Jun 25, 2012 10:25 pm
Profile
User avatar

Joined: Sun May 23, 2010 7:11 pm
Posts: 193
Reply with quote
Post Re: Upgrade, Enhancement Items
Your code snippet

gun:SetNext....

the gun gets replaced with whatever guns mag is going to be replaced?

And for the code working (even with some tweaking) is seriously unexpected, those are some half code bits I stole... it's not suppose to work

Also thanks for all the help, especially staying patient through all my questions and ideas


Mon Jun 25, 2012 10:30 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Upgrade, Enhancement Items
No, the 'gun' in this case is storing the name/ID of the weapon in question, and SetNextMagazineName tells it to change the magazine specified after reloading.


Mon Jun 25, 2012 10:38 pm
Profile YIM
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Upgrade, Enhancement Items
Oh yeah, about gun, that is just a variable. Name it as you want, but be sure to define it as local before so it isn't a global variable (local gun = actor.EquippedItem or something like it).


Mon Jun 25, 2012 10:42 pm
Profile
User avatar

Joined: Sun May 23, 2010 7:11 pm
Posts: 193
Reply with quote
Post Re: Upgrade, Enhancement Items
I have absolutely no idea what I am doing.

What I have:

What it does: NOTHING.

Some help please.
Actual code would be a great help (Especially how the variables get their values). I don't have the slightest clue what to do.


Tue Jun 26, 2012 12:11 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Upgrade, Enhancement Items
Code:
function Create(self)

         for actor in MovableMan.Actors do
             if actor:HasObject("Perioticum Shotgun") then
                local gun = actor.EquippedItem
                gun:SetNextMagazine("MagSniperRifle")
                break
             end
         end
end


That's the code with some things corrected. Now, the thing that I think is complicating this is that if you use actor.EquippedItem it would store the currently held item (which is the upgrade item) in the gun variable, hence, doing nothing but errors.

I think that the item would have to swap to the next inventory item until it finds the gun, and then storing it in gun.
Hmm... I haven't got much knowledge about inventories. You should ask about this on the lua scripting sub-forum.


Tue Jun 26, 2012 12:24 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 23 posts ]  Go to page Previous  1, 2

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.055s | 13 Queries | GZIP : Off ]