Home   Help Search Login Register  

Author Topic: RUG Inventory 0.6 BETA  (Read 18113 times)

0 Members and 1 Guest are viewing this topic.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG Inventory 0.4 BETA
« Reply #15 on: 08 May 2008, 18:42:10 »
Hi there!

The fremove function is a little different to the add one, in that it returns TWO things: one is the new, modified inventory (which needs to be updated to the parent inventory, just as with the fadd function) and the other is a boolean variable which tells you whether or not the removing was successful. If I remember correctly the return value select 0 is the variable (true/false) and the select 1 is the actual inventory. It should tell you so in the RUG_Inventory_fremove.sqf script header :) I think that by default it removes ALL of the items, unless you tell it to remove less (the third entry in the arguments array, if I remember correctly - check the script header)

As to showing the SPON money in the inventory dialog : you're right, it goes both ways doesn't it, so you'd still have to update your SPON money in the RUG Inventory for it to work properly, whenever you buy something using the SPON money system. So basically you'd have to have a little function for that, maybe one that runs whenever you open the RUG Inventory dialog window and adds/removes cash depending on SPON_PlayerCashBalance. Well, assuming SPON_PlayerCashBalance is a simple global var with a number in it, you'd just do something like:

Note: Not tested! Do not know if it works! Might have wrong variables! Also: needs to have the scripts precompiled! (done automatically once RUG_Inventory.sqf gets to run once).

Code: [Select]
_money = SPON_Playercashbalance;
_inv = Player getvariable "RUG_Inventory";
_noMoneyInv = [_inv, "Money"] call RUG_Inventory_fremove;
_newInv = [(_noMoneyinv select 1), "Money", _money] call RUG_Inventory_fadd;
Player setvariable ["RUG_Inventory", _newInv];

I don't remember the exact wording of the functions, so you'll have to check those, but what basically happens up there is that the script first removes any mention of the object named "Money" from the player's inventory, and then adds the amount of money that is in the Spon_Playercashbalance variable. Finally it updates the player's inventory again. This little script would have to be run for instance before everything else is run in the RUG_Inventory.sqf script. :)

Glad you like the rifle holders - checked out the "ammo bag" object too? It works - if not as well as I'd like (since you can't count ammo in individual magazines, it could easily be used as a cheat to refill half-empty mags if used for anything but one-shot items).

Wolfrug out.


 
"When 900 years YOU reach, look as good you will not!"

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #16 on: 09 May 2008, 00:30:39 »
thanks I'll try this out. Yea I saw the ammo bag it is cool as well. I really like how this whole thing works and is really not hard to begin to understand, where you can create your own objects. Very cool :D


where do I run this from exactly?

and when I create an inventory item is it possible to have it give the player a magazine?

I think I know how, I'll just try some stuff out.
« Last Edit: 09 May 2008, 01:10:35 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG Inventory 0.4 BETA
« Reply #17 on: 09 May 2008, 01:41:37 »
Giving a player a magazine is built into the ammo-bag script (which is under ItemActions). It's a very messy script I'm sorry to say, but still. I meant to create a dummy item that shows a magazine for 0.4 Beta, but I might've forgotten. :) Anyway, all you need to do to get the exact code necessary for creating a magazine item is to open up the ammocontrol script (something like ammocontrol.sqf under RUG_Inventory/ItemActions), and then scroll down to the very bottom of it. There will be a place there where a new item is being created as per Item = [[blah blah...]]; just copy that and change a couple of the important things...can't remember which exactly are what, but you should get a pretty good idea from the name of the local variables. The most important is basically the class name of the magazine, which I think comes straight after the "item name" of the item...anyway, check it out for a good idea.

And yes, it's meant to be fairly easy to create new items ^^ no good having an inventory system that only has a couple of items in it from default and no way to create new ones! Of course it can be used for other things as well, and once I get back to a computer with ArmA I might go about creating a PROPER demo mission that showcases some of the potential of the system...

Glad you're liking it!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #18 on: 09 May 2008, 01:51:49 »
thanks.  :)

so where do I add that SPON money code in? Rug_inventory or my Init.sqf?
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG Inventory 0.4 BETA
« Reply #19 on: 09 May 2008, 02:09:23 »
Oh, right. Hum. I would saaay...add it right in the start of the script, before everything else, BUT : place it under an if {} do, such as this:

Code: [Select]
if {!RUG_Inventory_Open} do
{
_money = SPON_Playercashbalance;
_inv = Player getvariable "RUG_Inventory";
_noMoneyInv = [_inv, "Money"] call RUG_Inventory_fremove;
_newInv = [(_noMoneyinv select 1), "Money", _money] call RUG_Inventory_fadd;
Player setvariable ["RUG_Inventory", _newInv];
};

Since the way things currently work is that whenever the inventory is updated (i.e., an object is moved up/down or used) the filler script is run again via the RUG_Inventory.sqf script. As long as the inventory is open, the variable RUG_Inventory_Open (I think, maybe without the _ for the last part...) will be true. So by making that check it should run only once. For this whole to work you of course need to have the other script working as well that continually keeps SPON_Playercashbalance on par with the amount of money actually in the inventory...

Hmm. But you're right, I didn't get what you asked earlier. You just wanted an object that tells you how much money you have - which doesn't let you really move it around using RUG Inventory, but still lets you check how much you have. That's very easy - just edit for instance the default money object to do something like: {ctrlSetText [500, format ["Money left: %1", SPON_Playercashbalance]}; in the Action screen, and nothing at all ([{}]) in the drop/take screens. Also make it weigh and cost less than 0 to make it undroppable and untakeable, and just name it something like "wallet" :D

Wolfrug out.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #20 on: 09 May 2008, 02:14:44 »
thanks!  ;)

Theres an error in your BuyVehicle.sqf

line 28

 :dunno:
« Last Edit: 09 May 2008, 03:49:12 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG Inventory 0.4 BETA
« Reply #21 on: 10 May 2008, 22:53:42 »
Huh...are you sure it's an error with the script and not with your custom item?  :scratch: Remember all of the ItemAction scripts are essentially "demo" scripts that are supposed to show you the potential of the system as opposed to being some kind of built-in features (with the possible exception of the guncontrol and ammocontrol scripts, since they were pretty involved to get working the way I wanted...). If something doesn't work, feel free to figure out a more useable item or system for what you want. :) Anyway I suggest you stick with SPON Money for buying vehicles and weapons and the like :D The trade system with RUG Inventory isn't that advanced, yet at least. :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #22 on: 11 May 2008, 05:21:51 »
Well I didn't actually change an Item. I just tried to test the BuyVehicle.sqf and got an error  :scratch:

How can I add a certain amount of one item?

more than one.  :dunno:

I am trying to make a paycheck script with RUG Inventory.

What value would I use to add the money?

Player setVariable ["RUG_Inventory", ([Item1])];
then the amount of Item1 I want to add?

and how would I call it in a formatted message?

i.e. $%3? what would the value be?
« Last Edit: 11 May 2008, 09:02:47 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Wolfsbane

  • Former Staff
  • ****
  • Rubber Duckie! Mah rubber duckie!!
    • OFP Editing Center
Re: RUG Inventory 0.4 BETA
« Reply #23 on: 11 May 2008, 19:56:44 »
DaChevs, please read our Signatures Guidelines Here
Thanks. :)
« Last Edit: 12 Nov 2008, 14:34:50 by bedges »
The greatest days, with the greatest people.. OFPEC.. The friends are never forgot.

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #24 on: 11 May 2008, 20:20:31 »
erm... :-[

sorry.  :good:
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG Inventory 0.4 BETA
« Reply #25 on: 11 May 2008, 23:14:49 »
Adding items is done via the rug_inventory_fadd.sqf function found in the main rug_inventory folder. The main point of this function is actually to STACK the item itself to avoid having a whole inventory full of items with the same name and purpose. Now, in the demo mission and by default, this function is precompiled into the global variable RUG_Inventory_fadd   (if I remember correctly - you can check what precompiles where from RUG_Inventory.sqf). I believe that there is a description of how to use the fadd function in the script header of said script, so you might want to look there. However it goes something like this:

Code: [Select]
Player setvariable ["rug_inventory", ([(player getvariable "rug_inventory"), "MONEY", 1000] call RUG_Inventory_fadd)];
Or in a more readable form:

Code: [Select]
_newInv = [(player getvariable "rug_inventory"), MoneyItem, 1000] call RUG_Inventory_fadd;
player setvariable ["rug_inventory", _newInv];

MoneyItem being the global variable assigned to the item and the number (in this case 1000) being the amount. NOTE: for the above to work the script has to be precompiled (RUG_Inventory_fadd = compile loadfile "RUG_Inventory\RUG_Inventory_fadd.sqf"), which is done automatically in my demo mission or when RUG_Inventory.sqf is run for the first time (such as when opening your inventory). Furthermore, MoneyItem has to be assigned to a global variable as well - I think if you look through TemplateInventor1.sqf (or something like that) you should find examples on how it works.

And also note: my syntax might not be correct! Verify it yourself. But here's the short version of how things work:

Your inventories, stored in the "RUG_Inventory" variable, is simply an array of arrays. Each entry in the array is an item, which in itself is an array (as you've noticed when you've tried adding your own items). That is how you can easily create inventories by binding the items to global variables, as so: YourInv = [Item1, Item2, CrowBar, FunkyShoes1]; Player setvariable ["rug_inventory", YourInv]. However, the problems come when you start to stack items (as in more than one FunkyShoes, or more than one item of "money"). This is solved internally in the default Use/Take/Drop scripts -> and also when using the fadd and fremove functions. So basically, if it weren't for stacking, adding items would be a lot easier (removing them is a whole different matter though..).

Aaanyway...point of the whole thing is: I suggest you use the functions that come with the scripts. They should save you a lot of trouble :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #26 on: 12 May 2008, 04:30:56 »
ah ok thanks  :)

Yea I looked at the header but couldn't really tell if it was a code to just add one or if it was multiple.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: RUG Inventory 0.4 BETA
« Reply #27 on: 30 May 2008, 22:25:53 »
 :good:
oh yeah.. this is really nice... great job and thanks for the outstanding cleanness in the scripts.. i have been wanting to learn about dialogs for some time now.
« Last Edit: 30 May 2008, 22:28:02 by loki72 »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG Inventory 0.4 BETA
« Reply #28 on: 31 May 2008, 00:21:05 »
You're welcome, but...cleanness of scripts?  :whistle: Aw man, if you think those are "clean" scripts, check out Spooner's. They're so clean you can't really even read them. :D Unless you're some kind of C++ geek I guess. Heh.

Note that the dialogs are made using the OFP Dialog maker (available in the Ed.Depot), but the actual functions surrounding them are of course made and figured out by yours truly. There are plenty of other ways to make dialogs tick, especially now with ArmA (such as dialog eventhandlers), what I've used is just one. Oh, and the only actual script that deals with the filling of dialogs and such is the RUG_Inventory_Filler.sqf ;)

Maybe the rest of the script can be of some use too :D

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ModestNovice

  • Members
  • *
Re: RUG Inventory 0.4 BETA
« Reply #29 on: 02 Jun 2008, 06:41:57 »
Yep I love this Wolfrug, thanks a whole bunch. I am using that tool too, its really nice, though I can't make something like this, I could do the actions, but not how you do, sweet  :good:

Though I am still not getting how I remove stuff from the inventory. I looked in the remove script, used the line, but kept getting an error message.

Well, I'll look through your drop script and see how you use that and will try to pull something together.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley