Forum

> > Stranded II > Scripts > Scripting Questions
Forums overviewStranded II overview Scripts overviewLog in to reply

English Scripting Questions

2,429 replies
Page
To the start Previous 1 2101 102 103121 122 Next To the start

old Re: Scripting Questions

ab6100
User Off Offline

Quote
Dear Anyone who can Script

this script ceeps causeing errors : (
Spoiler >


now thats not the full script just the problematic part please help

old Re: Scripting Questions

DEATHSHEAD
User Off Offline

Quote
you have to use this script:
1
on:use{dialogue "start",XX} //set for XX the ID of the textcontainer or the file in wich the dialogue is

Now you have to write in the Textcontainer / File :
1
2
3
4
5
6
7
8
9
10
page=start  //dont set here a semicolon (;)
title=Trader   // The title of the dialogue
text=start  //dont forget this
I'm this islands native trader .
What may i get you?
text=end;
button=buy,I want to buy!
button=sell,I want to sell!
button=info,What can you tell about this island?
button=action:close,Nothing, thank you!

MfG DEATHSHEAD
edited 1×, last 18.06.10 09:53:25 pm

old Re: Scripting Questions

ab6100
User Off Offline

Quote
ware dose
1
on:use{dialogue "start",XX} //set for XX the ID of the textcontainer or the file in wich the dialogue is
go ... in the unit or before the script?

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
Guys-
Is there a way to make player defined times to do actions instead of fixed processes? that he chooses inside the game? E.g. player wants to study a research. he doesnt have much time though he needs to complete a part of it. how do i make something that when he starts to research,it doesnt write the time but when he wants to stop he does something and it stops instantly. how i do that?
edited 2×, last 19.06.10 04:36:57 pm

old Re: Scripting Questions

deimors
User Off Offline

Quote
Ok, so I'm having no end of trouble trying to add an on:use event to a Message-in-a-Bottle.

Of course, I've tried adding:

1
2
3
on:use {
	msg "foo!";
}

to the object, but when I go to use it in inventory, I get told I can't use that object.

I'm able to get an on:collect event to fire when I pick it up off the ground, but when I have a message bottle that I want the user to dig up, this doesn't seem to fire, so I figure getting the one:use to work would be the more robust solution (makes more sense from a game-logic perspective, too).

Well, I eventually decided to go edit the .inf with the message bottle definition, and adding an on:use event there appears to work, but of course it's for all message bottles. Trying to overload this event for individual bottles (as I'd like different bottles to hold different messages) didn't work, however.

Any thoughts?

old Re: Scripting Questions

pupp3tStudios
User Off Offline

Quote
deimors has written
Ok, so I'm having no end of trouble trying to add an on:use event to a Message-in-a-Bottle.

Of course, I've tried adding:

1
2
3
on:use {
	msg "foo!";
}

to the object, but when I go to use it in inventory, I get told I can't use that object.

I'm able to get an on:collect event to fire when I pick it up off the ground, but when I have a message bottle that I want the user to dig up, this doesn't seem to fire, so I figure getting the one:use to work would be the more robust solution (makes more sense from a game-logic perspective, too).

Well, I eventually decided to go edit the .inf with the message bottle definition, and adding an on:use event there appears to work, but of course it's for all message bottles. Trying to overload this event for individual bottles (as I'd like different bottles to hold different messages) didn't work, however.

Any thoughts?

In the original adventure mode, try checking the script of the bottle message in the amp. That should help you a bit

old Re: Scripting Questions

deimors
User Off Offline

Quote
Pupp3t has written
In the original adventure mode, try checking the script of the bottle message in the amp. That should help you a bit


Sorry, I'm not entirely sure what you mean by 'in the amp'...

Though, I have gone through each of the adventure mode maps, and the only message bottles are standalone (not in storage), and use the on:collect event to trigger the message (which I've not had a problem with, except that on:collect doesn't appear to trigger when you dig up an item, ie: receive something from in-storage).

Are there maybe properties that prevent adding on:use events to certain objects? I've checked through the .inf's, but those don't appear to define anything like that...

old Re: Scripting Questions

pupp3tStudios
User Off Offline

Quote
-off topic- i meant map. Slip of a finger, cuz I have long skeletal fingers
-on topic- have you tried using this script?
on:use {
add "(your text here.)";
msgbox "(title here)";
}

old Re: Scripting Questions

deimors
User Off Offline

Quote
Heh, no worries :]

Actually, the use of 'msg' in the example was purely for brevity, I'm actually using the 'diary' command. Nonetheless (and even with msgbox), I get a 'I cannot use that' in red in the inventory when I try to use the bottle, no matter what the script.

It's like the local def'n of on:use isn't being recognized when testing for whether an item is usable, because the global def'n of on:use (in the .inf) executes fine.

....

Now that I've run some tests on a few different objects (those that are normally usable, and those that aren't), it seems that on:use for items just isn't working in local scripts. Is this just a "feature" of s2?

old Code Help

CPG
User Off Offline

Quote
I am taking my first steps into real coding and have hit a snag. I am trying to make it so that when a planted tree is hit with the axe before it is ready to produce logs a message would appear warning that the tree is not fully grown. I have added the following sections of code to a sample tree and the axe definitions respectively.
1
2
3
4
5
6
7
8
9
10
11
12
Tree addendum
	on:changeday {
		local $growthtime=spawntimer;
	}

Axe addendum contained in on:impact script of axe
	$tmp5=getlocal($tmp,$tmp2,$growthtime);
	if (compare_behaviour($tmp,$tmp2,"tree")==1){
		if ($tmp5<0){
			msg "This tree is not ready to be felled"
		}
	}
When I hit a tree that has been planted but not fully grown it doesn't play the message. I intentionally left the variable $tmp5 intact so that I could check if the script worked the first time around by using msg $tmp5 in game to check its value. It is reported as 0 so I am sure that there is something wrong with my syntax. The debug mode indicates that there is no significant error reports so I am at a lose as to what is wrong. Any help would be appreciated.

old Re: Scripting Questions

pupp3tStudios
User Off Offline

Quote
Have you tried putting that script into the game? It shows you the cycle each day whenever a planted tree is not big enough.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
@ deimors:
the script doenst work because in S2 all items of one type are united in the inventory if there are more than 1 and therefore the script of that single item you wrote the on:use script into is deleted.

to avoid this you could use the command s2 cmd extendscript with on:collect to extend the script of the item which is used when on:use in the inventory is triggered.
some items also have a function that is triggered on:use. in this case you probably should use the command s2 cmd addscript with on:collect.

next you either have to set a textcontainer which contains the script which is supposed to be the script that is triggered at the item on on:use
or you create a seperate file outside of S2 with the ending *.s2s which you can open with a normal text-editor and write the script into this file.
but I think the way with the textcontainer is the easier one for maps.

however when working on a mod you could just write the script which is executed when triggered into the definition-scriptfiles which are the sys/ folder and end with *.inf.

old Re: Scripting Questions

CPG
User Off Offline

Quote
Pupp3t has written
Have you tried putting that script into the game? It shows you the cycle each day whenever a planted tree is not big enough.

I have put this code in game and even waited until after a change day event to test the code but even though the tree is still way to young the message refuses to play and msg $tmp5 command still shows a zero in the $tmp5 variable. I can find no explanation as to why the variable is not reading the age of the trees. The debug mode still shows no major errors so I am at a lose as to what is causing the failure in the code. Any help is greatly appreciated.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
@ CPG:
I think it's because of the command s2 cmd getlocal.
it appears that this command is a little bit bugged and therefore doesn't always work correctly
(this at least is the experience I made)

if you have a look at the command s2 cmd setlocal you'll see that it has 2 additional parameters. I experimented a little bit with the s2 cmd getlocal command and found out that it helps in some cases if you add 2 commas in front of the semicolon at the end of the command:
1
tmp5=getlocal($tmp,$tmp2,$growthtime),,;
but this, however, doesn't appear to work always either... so there's no guarantee ...


Edit:
I had a more detailed look at your script and I hope for you that this is just a part of it. otherwise it doesn't suprise me that it doesnt work.
e.g. this seems to me to be totally wrong:
1
2
3
on:changeday {
          local $growthtime=spawntimer;
     }
I don't think you can set a variable as local and put a certain value into it at the same time...

old Re: Scripting Questions

CPG
User Off Offline

Quote
@Hurri04
The code I posted were in addition to the already present code. The axe code is placed within the on:impact portion of the code. I added the extra commas you suggested to the getlocal portion of the script but the debug mode labels this as a problem (expecting semicolon when it is already present after the commas. I also changed the tree portion of the code to this
1
2
3
on:changeday {
local $growthtime;
$growthtime=spawntimer ("self");
These changes however don't seem to get any better results. I was unaware to the problems in the getlocal script. Can you suggest any other way allowing the axe script to read the local trees $growthtime variable? Thanks for the suggestions.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
CPG has written
I added the extra commas you suggested to the getlocal portion of the script but the debug mode labels this as a problem (expecting semicolon when it is already present after the commas.

yes, that's the problem I was talking about.
sometimes it works, sometimes not.
More >

CPG has written
I also changed the tree portion of the code to this
1
2
3
on:changeday {
local $growthtime;
$growthtime=spawntimer ("self");
These changes however don't seem to get any better results.

this however seems to be better now. just leave it like that as long as it works

CPG has written
I was unaware to the problems in the getlocal script. Can you suggest any other way allowing the axe script to read the local trees $growthtime variable? Thanks for the suggestions.

well, you could try to use another way, kind of "bypassing" the s2 cmd getlocal command.

unless the s2 cmd local command works fine you still can use it.
so I think the best way is to define these local variables and put a value into it, like you already did before.
next, instead of using s2 cmd getlocal, you can start an event by using the command s2 cmd event, this command has to start a local event at the current object from which you wish to get the local variable. then, because of the local event, you can transfer the value of the local variable to a global variable.
so e.g. you wirte the following into the object:
1
2
3
4
5
6
7
8
on:changeday {
	local $growthtime;
	$growthtime=spawntimer ("self");
}

on:globalize {
	$glob_growthtime=$growthtime;
}
so in this example you have to trigger the event "globalize" via the command s2 cmd event at the object which has this code in it.
then you can go on with your normal script just like before, maybe you should put a second s2 cmd event command at the end of the on:globalize event to start a new event (a global one this time) and then put the rest of your script (which is supposed to be executed afterwards you've got the value of the local variable) into it.
this, in general, is the whole trick to bypass the s2 cmd getlocal command
To the start Previous 1 2101 102 103121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview