Forum

> > Stranded II > Scripts > Storage Script- return unused space
Forums overviewStranded II overview Scripts overviewLog in to reply

English Storage Script- return unused space

7 replies
To the start Previous 1 Next To the start

old Storage Script- return unused space

JasJack67
Super User Off Offline

Quote
So i can not figure out how to write the storage command. After many attempts I can not get it to work.

if I want to return the unused space left in the campfire...how would I write that, so I can make something happen when the space is at a certain level.

I have tried writing it like these, assuming you have opened the campfire to add wood, but the command returns "there is not enough space" so it makes the fire go out:

1
2
3
4
5
6
$i=current();
if (storage("object", $i, 1)<=10,000) {
msg "The campfire has smothered, there is too much wood!";
freestate "self",4;
freestate "self",5;
}

and this line i tried instead:

1
if (storage($i,1)<=10000){

I have tried 100 variations of the 2 lines above, but I may be way off in how I am writing the script.

in the command description it says "modes" are 0 freespace...1 unused space, and 2 to return the max capacity. I been trying 0 or 1. So can you tell me how to write the storage command to return the "unused" space?

thank you in advance for any input.

old Re: Storage Script- return unused space

Hurri04
Super User Off Offline

Quote
line 1: what the hell is this "current"-command?!
replace it with s2 cmd currentid!
also you shouldnt use variable names that short, at least call it "$id".


line 2: the "mode" parameter of the s2 cmd storage command does NOT mean "unused" when set to 1 but "used"! therefore you want to set it to 0 to get the free space.

old Re: Storage Script- return unused space

JasJack67
Super User Off Offline

Quote
eh, yeah Hurry that was a typo in this thread, i didnt do that in the real script $i=currentid();

ok to the using the 0 and not 1....but i have tried them both.

that will cause error? using a 1 digit variable? hmm, i didnt know that.

can you write a correct line off my script above referring to the "storage" command...assuming the $i=currentid() typo was corrected?

if so thank you!

i have even tried moving the parentheses around:

if (storage("object", $i, 0)<=10,000) {

if ((storage "object", $i, 0)<=10,000) {

old Re: Storage Script- return unused space

Hurri04
Super User Off Offline

Quote
no, using short varible names is not an error but it is not very good to read. variables should always be "speaking" so you know what they stand for.


but I just noticed another error:
in line 2 remove the "," in the "10,000".
though it is common to write large numbers with separators each 1000 steps S2 cant handle this.

old Re: Storage Script- return unused space

JasJack67
Super User Off Offline

Quote
hahaha...thats another typo in this thread, i didnt do that in the script (double checked)

so im on the right track in "how" i wrote that line huh? let me try again and maybe i'll get it to work.

it's surly not like:
1
if (storage($i,0)<10000) {

huh?

old Re: Storage Script- return unused space

Hurri04
Super User Off Offline

Quote
no, there definitely need to be 3 parameters.

I dont see a problem with it then anymore. what's the actual problem again?
> does something happen or not?
> is this supposed to happen?
> is there a script error message?

old Re: Storage Script- return unused space

JasJack67
Super User Off Offline

Quote
ok Hurry i got it!

it was the parentheses:

1
if (storage ("object", $i, 0)<=10000) {

i probably had trouble because i was trying to use "mode 1" at times and then trying "mode 0" and probably just missed the right combination.

anyways...THANK YOU! for trying to help me. I am using this script in combination with a:
1
2
3
4
5
if ((count"object",$i,"charcoal")>=1000) {
freestate "self",4;
freestate "self",5;
freestate "self",23;
msg "The campfire is over loaded with charcoal!",3;

What this does is not let the campfire overload with charcoal where it will spawn in the center of the island, when the campfire maxweight is maxed from charocoal being made from burning material. It also makes the player have to remove charcoal from the campfire to continue a fire. The other way i fixed it temporarily was to increase the maxweight of the campfire to 9999999...but that was not a fix, just buying me some time.

old Re: Storage Script- return unused space

Nova
User Off Offline

Quote
The command s2 cmd storage has a bug: If you use mode 1, it returns the negative value!

So if you store 1 stone, s2 cmd storage("self", 1) returns "-1500". (If you store a butterfly, you get the value "500" and not "-500" back.)

Just multiply the return value with -1 and it works like intended:
1
2
3
4
5
[...]
$stored = storage("self", 1);
$stored = $stored * -1;
if ($stored <= 10000) {
[...]


Or you could negate the value in the if command:
1
2
3
[...]
if (storage("object", $i, 1) <= (-10000)) {
[...]
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview