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 231 32 33121 122 Next To the start

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
it's a bit wong (typology)
It should be
1
2
3
4
5
6
7
on:hit {
	if(getplayerweapon()==id of the knife){
		if(random(1,3)==1){
			find idleaf,random(1,2);
			}
		}
	}

old Re: Scripting Questions

Gregg
User Off Offline

Quote
Thanks you two, but where abouts would I put it? This is the current item script:

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
script=start
          on:attack2{ 
          $sakcur+=1; 
          if($sakcur>=9){ 
               $sakcur=0; 
          } 
     } 
     on:attack1{ 
          if($sakcur==0){ 
               msg "Closed"; 
          } 
          elseif($sakcur==1){ 
               msg "Knife"; 
          } 
          elseif($sakcur==2){ 
               msg "Saw Blade"; 
          } 
	  elseif($sakcur==3){ 
               msg "Magnifying Glass"; 
          } 
	  elseif($sakcur==4){ 
               msg "Tweezers"; 
          } 
	  elseif($sakcur==5){ 
               msg "Nail File"; 
          } 
	  elseif($sakcur==6){ 
               msg "Scissors"; 
          } 
	  elseif($sakcur==7){ 
               msg ""; 
          } 
	  elseif($sakcur==8){ 
               msg ""; 
          } 
     }
script=end

old Re: Scripting Questions

MrCowThing
User Off Offline

Quote
Wont you have to also check if the player is hitting a tree, or a bush?
EDIT:
I'm not sure if this will work...

1
2
3
4
5
6
7
8
9
10
11
12
on:attack1{
		$class=impact_class();
		$id=impact_id();

		if($sakcur==1){
			if(compare_material($class,$id,"wood")==1){
				if(random(3)==1){
					find 15,random(1,3);
				}
			}
		}
	}

EDIT2:
Ok it does work, but it will give extra on ALL wood materials. Is there a script that will check if an object is in the group "trees" or "bushes" instead of there material?
edited 2×, last 13.06.08 07:45:07 pm

old Re: Scripting Questions

ESKARN
User Off Offline

Quote
is there anyway to not bring up a diary entry when you load up a map if you already have the diary entry i relay have no idea


if someone can tell me they can have this cookie cookie

old Re: Scripting Questions

CN
User Off Offline

Quote
Make a trigger. the diary will be load when the player enters the trigger. with s2 cmd stoptrigger you can stop the trigger, so the diary will be only load once.
Sorry for my bad englisch! i hope you understand it...

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
stoptrigger is not necessary. Enough would be just put as the end of the script free "self";
It will delete the trigger once it is triggered

old Re: Scripting Questions

ESKARN
User Off Offline

Quote
i know how to do that



map 1 > map 2

map 1 has a diary entry map 2 doesn't

map 2 > map 1

you are going back to the same map but you already have the diary entry i want to know how to stop it coming up a second, third... time

old Re: Scripting Questions

GreyMario
User Off Offline

Quote
It's the simple variable-as-a-switch solution.

When you trigger the code that gives you the diary entry, check it against a variable. Immediately after the line that gives you the diary entry, set the variable in such a manner that the check returns false.

old Re: Scripting Questions

MrCowThing
User Off Offline

Quote
I need some help. I'm working on a shield, it will protect you from 20 hits before its broken. But it doesn't work, there is no errors, and the message that says I've been hit doesn't show up.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$wep=currentid();

	on:ai_attack{
		if(getplayerweapon()==$wep){
			$hit+=1;
			msg "hit $hit times";
		}
	}
	on:inhand{
		if($hit<=20){
			if(getplayerweapon()==$wep){
				heal "unit",1,2000;
			}
		}elseif($hit>20){
			free "self",1;
			msg "The shield broke!",3;
			$hit=0;
		}
	}

old Re: Scripting Questions

dragoana
User Off Offline

Quote
getplayerweapon()==$wep ?
= getplayerweapon()==currentid()

it should be
getplayerweapon()==*defined item shild id*

maybe I wrote rubbish
but the code is not very evident...

old Re: Scripting Questions

dragoana
User Off Offline

Quote
ok then write an echo in ai_attack:
1
2
3
4
5
6
7
on:ai_attack {
	echo "trigger ai_attack event";
	if(getplayerweapon()==$wep){ 
		$hit+=1; 
		msg "hit $hit times"; 
	} 
}
when it does not appear, it really doesn't work...

old Re: Scripting Questions

Raven Shadow
User Off Offline

Quote
MrCowThing has written
I need some help. I'm working on a shield, it will protect you from 20 hits before its broken. But it doesn't work, there is no errors, and the message that says I've been hit doesn't show up.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$wep=currentid();

	on:ai_attack{
		if(getplayerweapon()==$wep){
			$hit+=1;
			msg "hit $hit times";
		}
	}
	on:inhand{
		if($hit<=20){
			if(getplayerweapon()==$wep){
				heal "unit",1,2000;
			}
		}elseif($hit>20){
			free "self",1;
			msg "The shield broke!",3;
			$hit=0;
		}
	}


Having the player healed by such an amount to counter
an attack would also undo damage the player should
have legitimately have to deal with.

Try Schnapsidee's test code as a global script instead of
a local script.
I.E. put it in it's own file and name it game_testscript.inf
and the game will load it as a global script.

old Re: Scripting Questions

Raven Shadow
User Off Offline

Quote
MrCowThing has written
Wont you have to also check if the player is hitting a tree, or a bush?
EDIT:
I'm not sure if this will work...

1
2
3
4
5
6
7
8
9
10
11
12
on:attack1{
		$class=impact_class();
		$id=impact_id();

		if($sakcur==1){
			if(compare_material($class,$id,"wood")==1){
				if(random(3)==1){
					find 15,random(1,3);
				}
			}
		}
	}

EDIT2:
Ok it does work, but it will give extra on ALL wood materials. Is there a script that will check if an object is in the group "trees" or "bushes" instead of there material?


Using attack2 would give much greater control over
what is found and how much.

old Re: Scripting Questions

Raven Shadow
User Off Offline

Quote
1
spawn=item-type [, time to grow in days][,X-radius][,y-radius][,y-offset][,objects][,number per object]
I really do need to know how [,X-radius][,y-radius][,y-offset][,objects] affect fruit placement on the tree.

Does [,number per object] control max fruit to spawn?

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
number per object control how often the thing will appear.
I have a problem...
$id=create("info_sprite",5,"flare0_a.bmp",20,400,255,255,0,128,0,1);

Why this doesn't work please??

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
It worked fine. $Id is now equal to "create("info_sprite",5,"flare0_a.bmp",20,400,255,255,0,128,0,1);", you just never told it to do anything else. Mabey
     $Id=("info_sprite",5,"flare0_a.bmp",20,400,255,255,0,128,0,1);
     create "$Id";

old Re: Scripting Questions

DC
Admin Off Offline

Quote
no thats wrong. you can't use create this way. you have to use 2 different commands. first s2 cmd create to create the info which handles the sprite and afterwards s2 cmd info_sprite to setup the sprite itself.

info_sprite Info-ID [,"File"][,X,Y][,R,G,B][,Alpha][,Blend][,Fix]
file=sprite image (enter nothing to remove the sprite!)
x/y= size (default 1)
r,g,b=color (each 0-255)
alpha=0.0-1.0
blend=glow (1) or not (0)
fix=fix vertically (1) or not (0)
To the start Previous 1 231 32 33121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview