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 2114 115 116121 122 Next To the start

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
well, you could write this into the definition script of such a book:
1
2
3
4
5
6
7
on:use {
	$book_text=inputwin("Enter a name!", 0, "Cancel", "Okay");
}

on:attack1 {
	msg "$bok_text";
}

this is a very simple script which allows you to use the book in the inventory by selecting it and pressing 'E', so the inputwin opens.
then you have to write a name in there and press ok.
when you take the book into your hand then and attack something by pressing the left mouse button you receive the name you typed into the inputwin as a message on the left side of the screen.

you can modify this little script if you want it to also do other things, like e.g. giving the thing you jsut hit the name you wrote into the book by using the command s2 cmd text3d.
More >

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
Ok that helped alot. Thanks! I will set it so that when you type the name of something (lets say raptor) then all the raptors on the island die. Shouldn't be too hard. I could just make it that when it shows the text it also kills the unit. Thanks again! You're a big help!

Edit: Sorry to ask so many questions, but in the Adventure mode, there are towers that shoot at the player. The way these work is through the areal trigger underneath them. Is there anybody who could possibly write that same script, except have it that the object automatically places these areal triggers (with their scripts) right where the tower is? It is probably quite simple but I can't seem to figure it out. Thanks if anyone can!
edited 1×, last 07.12.10 04:22:36 am

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
1
2
3
4
5
6
7
on:create {
	local "$x", "$z", "$id";
	$x=getx("self");
	$z=getz("self");
	$id=create("info", [TYPE OF THE AREAL TRIGGER], $x, $z);
	addscript "info", $id, [SOURCE, e.g. "sys\scripts\areal_trigger.s2s"];
}
you have to repeat this script 2 more times right underneath this example, but with the events "on:build_finish" and "on:edset".

also, you hava to create a file (which you named in the part with the source where you also have to define a location for it) and write the script of the areal trigger from the adventure mode into this.

I dont know exactly how to set the parameters of the areal trigger by a script but you could instead of that also do this:
let the script create a normal info, e.g. a flag and then modify the script I wrote by using the commands s2 cmd timer and s2 cmd playerdistance to check each second (1000 ms) whether the player is in range.
s2 cmd if this is the case use the command s2 cmd projectile to create an arrow or something that goes right into the direction of the player (mode 4).

Edit: sorry, I wrote "playerinrange" instead of s2 cmd playerdistance for the command...
edited 2×, last 08.12.10 05:25:17 pm

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
Thanks! Could I also just do this (what you said):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
on:create {
	local "$x", "$z", "$id";
	$x=getx("self");
	$z=getz("self");
	$id=create("info", [TRIGGER], $x, $z);
	addscript "info", $id, "sys/scripts/battletower.txt"];
}
on:build_finish {
	local "$x", "$z", "$id";
	$x=getx("self");
	$z=getz("self");
	$id=create("info", [TRIGGER], $x, $z);
	addscript "info", $id, "sys/scripts/battletower.txt"];
}
on:edset {
	local "$x", "$z", "$id";
	$x=getx("self");
	$z=getz("self");
	$id=create("info", [TRIGGER], $x, $z);
	addscript "info", $id, "sys/scripts/battletower.txt";
}

...and then just manually adjust the range of the areal trigger in the editor?

EDIT: Wow... I just realized... I am over complicating things so much. I could just take the script from the defense tower and make it shoot the player instead of other units.... I fail. All I need now is a script that says if the player is in range of the object by 300, then it shoots.

The script is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
on:start {
		timer "self",3000,0;
		addstate "self",22;
		statesize "self",22,15;
	}
	on:create {
		timer "self",3000,0;
		addstate "self",22;
		statesize "self",22,15;
	}
	on:build_finish {
		event "defensetowerbuild",0,0;
	}
	on:use {
		msgbox "Defense Tower","sys/scripts/defensetower.s2s";
	}
	on:timer {
		local $x,$y,$z;
		$x=getx("self");
		$y=gety("self");
		$z=getz("self");
		$y+=28;
		projectile 53,$x,$y,$z,6,350,15,59;
	}
edited 2×, last 08.12.10 10:54:25 am

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
Jesterhead37 has written
...and then just manually adjust the range of the areal trigger in the editor?

EDIT: Wow... I just realized... I am over complicating things so much. I could just take the script from the defense tower and make it shoot the player instead of other units.... I fail. All I need now is a script that says if the player is in range of the object by 300, then it shoots.

yes, that's exactly what I meant with this:
Hurri04 has written
I dont know exactly how to set the parameters of the areal trigger by a script but you could instead of that also do this:
let the script create a normal info, e.g. a flag and then modify the script I wrote by using the commands s2 cmd timer and s2 cmd playerdistance to check each second (1000 ms) whether the player is in range.
s2 cmd if this is the case use the command s2 cmd projectile to create an arrow or something that goes right into the direction of the player (mode 4).



well, you can use parts of the script which you postet from the defense tower but you have to edit some things with the commands I wrote in my post:
More >


this code here should work pretty well, you can just write it into the definition script of that battle tower and in this case you dont need the script I wrote in my last post:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
on:start {
	local "$x", "$y", "$z";
	$x=getx("self");
	$y=gety("self");
	$z=getz("self");
	$y+=28;
	timer "self", 1000, 0;
}

on:create {
	local "$x", "$y", "$z";
	$x=getx("self");
	$y=gety("self");
	$z=getz("self");
	$y+=28;
	timer "self", 1000, 0;
}

on:build_finish {
	local "$x", "$y", "$z";
	$x=getx("self");
	$y=gety("self");
	$z=getz("self");
	$y+=28;
	timer "self", 1000, 0;
}

on:timer {
	if(playerdistance("self")>[VALUE FOR THE SHOOTING-RANGE]) {
		projectile [TYPE OF AMUNITION], $x, $y, $z, 4, 350, 15, 59;
	}
}
this, as you can see, is a mixture of the script you posted and the script I wrote before. I just used the different events which are needed to start the timer, removed some unnecessary stuff and copied the script for the timer from the defense tower script to the commands that are executed with the different events so they wont be executed every time when the timer is being triggered which would be too much as the variables are saved in the tower for once at the start and that's just enough. then I just wrote a 4 instead of a 6 for the mode at the projectile command and an if-query in front of it to check the distance between the player and the tower so it wont shoot at the player at any distance.
edited 2×, last 08.12.10 06:27:27 pm

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
Simple, yet brilliant! Thank you so much! Seems that you always know how to answer my questions. You have got to be one of the most helpful people on the whole forum. Now I will be making a set of defensive towers and offensive towers using different arrow types. Maybe even one using rockets. Perhaps I should make some sort of alternative tower defense game. Anyway, thanks again!!

Terribly sorry for all the questions, but when I look at the description of the projectile command (on the site) it says that there are changeable things like damage, speed, and drag. How do i switch the "weapon" thing on or off so that I can change the drag, speed, or damage of the projectile? It only shows a few parameters but there should be more right?
edited 1×, last 09.12.10 01:45:03 am

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
oh, sorry, forgot to check the other parameters of the projectile command, I'm not using it that much in fact

writing this for the command line with the projectile command in the script should solve the poblem:
1
projectile [TYPE OF AMMUNITION], $x, $y, $z, 4, [TYPE OF WEAPON OR 0], [SPEED], [DAMAGE], [DRAG];
if you enter a number for the type of the weapon the values of the weapon will be used for speed, damage and drag and in this case you have to leave these parameters away.

but if you write a 0 there you can set your own values for speed, damage and drag.
however, if the ammunition has its own values for speed, damage and drag, these will be added to the values you wrote in the projectile command.

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
Oh alright. Simple enough. Thanks!!

Does anybody know a command for touch? Like, when the player touches a certain thing he catches fire (as an example)
edited 3×, last 18.12.10 03:38:32 am

old changing daylength?

galahad13
User Off Offline

Quote
Is it possible to change the length of day and night? and if so, could someone tell me how? preferably in the "for idiots" instructions?

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
> link to the following quote
Hurri04 has written
you could set the ingame hour to an other value using the commands s2 cmd hour and s2 cmd sethour and also the commands s2 cmd minute and s2 cmd setminute and, if necessary s2 cmd day and s2 cmd setday.

you could start a map where you just stand there for a while, like 10 minutes real-time which you clock on your watch or something and then you open the character menu to have a look at the day, open the inventory and use a watch to get the hours and minutes.
then you have to figure out how long one minute ingame is in real-time.
(I recommend to clock a very accurate value and use a map that you created in the editor, with an arcade-info on it so you wont get hungry/thirsty/tired while you wait, and you can also give yourself a watch to clock the hour and minute!)

next you can use the command s2 cmd timer and trigger an event every few seconds (the amount of seconds one ingame minute takes minus a certain factor to make the ingame minutes have less seconds which the player cant prove because he cant check the seconds ingame).

using this you can skip an ingame minute from 60 ingame-seconds (which are less than 60 real-time-seconds!) to a lower amount, just set the current minute +1, or if the current minute is 59 set it to 0 and set the current hour +1 (same with days).

so if you'd skip half of the minutes a day also would last half as long. the sun should automatically rise faster because it is connected to the current time that is.

at least I think that is how it should work, havent tested it myself yet but I'm pretty sure it will work

old Help

Dr Zhark
User Off Offline

Quote
I've tried for a few days now to make a working Weed Grandpa (Hemp Grandpa) to work in the Editor so I can have a custom map and sell him some of his "stuff". It doesn't let me make trade buttons, transactions or anything! Yes I have tried doing copy paste and all, but Editor doesn't like the main scripts
HELP!

old Re: Scripting Questions

Vectarrio
User Off Offline

Quote
Dr Zhark has written
I've tried for a few days now to make a working Weed Grandpa (Hemp Grandpa) to work in the Editor so I can have a custom map and sell him some of his "stuff". It doesn't let me make trade buttons, transactions or anything! Yes I have tried doing copy paste and all, but Editor doesn't like the main scripts
HELP!

Try not the global script, but Grandpa unit script (in editor, just click on him and there will be properties)

old Re: Scripting Questions

Dr Zhark
User Off Offline

Quote
What I meant was that the Grandpa Script wasn't working. As in that when I scripted him from his Script Unit, it didn't work. I didn't use the Global Script.
edited 1×, last 28.12.10 03:22:06 pm

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
you should post the script and where you wrote it in here, by this we can help you much better.


use code tags for the script:

[*code*] Script [*/code*]

write it like this but without those stars!

old Re: Scripting Questions

Dr Zhark
User Off Offline

Quote
Hurri04 has written
you should post the script and where you wrote it in here, by this we can help you much better.


use code tags for the script:

[*code*] Script [*/code*]

write it like this but without those stars!


Ok.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
page=start
title=Grandpa
text=start
Hey you. How's it going?
text=end
button=trade,I want to trade.
button=action:close,Don't bother me!

page=trade
title=Trade with grandpa
### Hempleaf -> Cookie
trade=start
sell=83,5
buy=66,1
trade=end
### Hempleaf -> Trunk
trade=start
sell=83,10
buy=7,1
trade=end
### Hempleaf -> Grapes
trade=start
sell=83,15
buy=45,3
trade=end
### Hempleaf -> Grain Pile
trade=start
sell=83,15
buy=42,3
trade=end
### Hempleaf -> Plums
trade=start
sell=83,15
buy=116,3
trade=end
### Hempleaf -> Coconut
trade=start
sell=83,20
buy=27,3
trade=end
### Hempleaf -> Banana
trade=start
sell=83,20
buy=14,3
trade=end
### Hempleaf -> Cacao Fruit
trade=start
sell=83,25
buy=67,3
trade=end
### Coffie Fruits -> Hempleaf
trade=start
sell=83,25
buy=3,70
trade=end
button=action:close,Cheers!

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
Hurri04 has written
you should post the script and where you wrote it in here, by this we can help you much better.

did you write it right into the grandpa's scriptbox?
or did you write it into a textcontainer?

actually, the script looks very correct for me (on the first sight).
my guess is that you wrote it into the wrong place.
you have to write a script like this into the gradpa's scriptbox:
1
2
3
on:use {
	dialogue "start", 1;
}
and then the script you wrote goes into a textcontainer with the ID 1 (as the dialogue command says '1' in it).

btw: I'm not sure whether lines like "### Hempleaf -> Cookie" will be shown in the tradebox or not. but that shouldnt be the big problem


Edit:
@amstel bier9:
well, the ammo is always rotating in Straned 2 and there isnt much that you can do about it because it is hardcoded in the source code.
in the normal game you just dont notice that it is rotating because all the ammunition looks very even from behind and is moving fast enough so the player wont see any rotation, at least not on the first sight.
edited 1×, last 28.12.10 09:24:57 pm

old Re: Scripting Questions

Dr Zhark
User Off Offline

Quote
Hurri04 has written
Hurri04 has written
you should post the script and where you wrote it in here, by this we can help you much better.

did you write it right into the grandpa's scriptbox?
or did you write it into a textcontainer?

actually, the script looks very correct for me (on the first sight).
my guess is that you wrote it into the wrong place.
you have to write a script like this into the gradpa's scriptbox:
1
2
3
on:use {
	dialogue "start", 1;
}
and then the script you wrote goes into a textcontainer with the ID 1 (as the dialogue command says '1' in it).

btw: I'm not sure whether lines like "### Hempleaf -> Cookie" will be shown in the tradebox or not. but that shouldnt be the big problem


Ummmm? I don't get it.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
place a gradpa on the map, click at him again and a window will appear with the gradpa's scriptbox in the lower section.
this is where you have to write this script:
1
2
3
on:use {
	dialogue "start", 1;
}
then you press the green ok-button(s) so that you can see the map again.

next you place a textcontainer which you can find at the infos right next to the grandpa and click on it again and write the script you wrote into the scriptbox of the textcontainer.
also, you have to look at the ID of the textcontainer which is being displayed in the upper part of the window that appears when clicking the textcontainer.
you have to write this ID into the script which is written in the grandpa's scriptbox instead of the "1".

after this is done confirm by pressing the green ok-button(s) again and press F12 to test the map.

old Re: Scripting Questions

Dr Zhark
User Off Offline

Quote
Hurri04 has written
place a gradpa on the map, click at him again and a window will appear with the gradpa's scriptbox in the lower section.
this is where you have to write this script:
1
2
3
on:use {
	dialogue "start", 1;
}
then you press the green ok-button(s) so that you can see the map again.

next you place a textcontainer which you can find at the infos right next to the grandpa and click on it again and write the script you wrote into the scriptbox of the textcontainer.
also, you have to look at the ID of the textcontainer which is being displayed in the upper part of the window that appears when clicking the textcontainer.
you have to write this ID into the script which is written in the grandpa's scriptbox instead of the "1".

after this is done confirm by pressing the green ok-button(s) again and press F12 to test the map.


I LOVE YOU! No homo.
To the start Previous 1 2114 115 116121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview