Forum

> > Stranded II > Scripts > portable storage object
Forums overviewStranded II overview Scripts overviewLog in to reply

English portable storage object

8 replies
To the start Previous 1 Next To the start

old portable storage object

aimeewilbury
User Off Offline

Quote
I'm having trouble with this one and I'm not gonna post my code as its a terrible spaghetti-mess and I don't want to embarrass myself

But heres what I want to do: I have an object that I can assemble as an item and build like a tent. It looks like a little treasure chest. But it's a portable storage. I've got the assembling & building part done OK.

I also got the part with the s2 cmd exchange done OK. But my main issue is trying to pack up the storage, but only if its empty. (I was using s2 cmd countstored).

Basically: When you click the object, a menu will come up asking you if you want to put things in it or pack up the storage. If you try to pack up the storage with items in it it'll give you a red text.

Any suggestions?

old Re: portable storage object

Hurri04
Super User Off Offline

Quote
I dont think this can able to be solved easily in s2s.

one of the main problems I see would be that the player could build multiple of those storages and collect them.

even though it might be posible to check every single item with s2 cmd countstored and save the returned value into a different variable for each item, this would get messed up when having multiple storages at hand:
if you e.g. put a number of sticks into one storage and a number of sticks into another storage, when collecting both storages and building a new one, all the sticks might be put into this one storage.
this might lead to another problem; what will possibly happen when both storages are almost filled? is the part that doesnt fit into the storage volume dropped outside of that storage? or does it disappear or create another problem?


further, this would be some kind of cheating, since the player could carry endless amounts of items with him.

I think it'll be better if you create a storage kinda like the chests in minecraft which throw all the stuf out that is in them when they are being destroyed so the player has to pick all the items up again.

old Re: portable storage object

Hurri04
Super User Off Offline

Quote
use s2 cmd count_stored to count how many items of every type are stored and then create this amount of items at the location of the storage.

you can use s2 cmd loop and s2 cmd loop_id in order to run through all the type-numbers of the items. just set the mode for the loop command to "count" and put the type-number of the last item as number into the next parameter.

afterwards use s2 cmd freestored to delete all stored items from the storage.
edited 1×, last 31.07.11 10:15:52 pm

old Re: portable storage object

aimeewilbury
User Off Offline

Quote
Well I tried that and failed. So I just removed everything about the items inside and if you pack it up without taking the items out you lose them. I'm a bit lazy

old Re: portable storage object

Hurri04
Super User Off Offline

Quote
I dont think this is a proper solution...

this script is somewhat easy, I can write it within a mere couple of minutes!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
on:hit {
	local "$storage_x", "$storage_z";
	$storage_x=getx("self");
	$storage_z=getz("self");
	loop("count", [HIGHEST ITEM-TYPE-NUMBER]) {
		$check_item_type=loop_id();
		$items_stored=count_stored("self", $check_item_type);
		if($items_stored>0) {
			create("item", $check_item_type, $storage_x, $storage_z, $items_stored;
		}
	}
	freestored "self", "all";
	find [ITEM-TYPE-NUMBER OF STORAGE IN ITEM-FORM];
	free "self";
}

there you go.

so when hitting the storage (the event can be tweaked) the script loops through all possible items and checks how many of them are stored in the storage and if the amount is grater than 0 it creates this amount of items outside of the storage.
afterwards all items in the storage and the storage iteself are deleted and the player finds the storage as an item.

old Re: portable storage object

aimeewilbury
User Off Offline

Quote
Well I tried that code and replaced the values and then I got "parameter must be greater than 0." So I searched the site for that and I got stuff that either was unrelated or in German.

old Re: portable storage object

Hurri04
Super User Off Offline

Quote
have you tried to write "debug" into the console and test it then?
usually this gives you an error message which is a little more detailed.

also, you didnt wirte the [ and ], or did you?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview