Forum

> > Carnage Contest > Lua Scripts/Questions/Help
ForenübersichtCarnage Contest-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

89 Antworten
Seite
Zum Anfang Vorherige 1 2 3 4 5 Nächste Zum Anfang

alt Lua Scripts/Questions/Help

Nem
User Off Offline

Zitieren
I am newbie at lua scripting, i not dumb to understand it, but to lazy to do it.
So, i need make the SSG shoot 8 bulets instead of 3

The SSG code:
Spoiler >


may anyone help me pls ?
1× editiert, zuletzt 16.09.10 17:07:07

alt Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Zitieren
Nemesis hat geschrieben
I am newbie at lua scripting, i not dumb to understand it, but to lazy to do it.
So, i need make the SSG shoot 8 bulets instead of 3

The SSG code:
Spoiler >


may anyone help me pls ?


The changed things are marked big.

I use same for my Quake-Shotgun, but you have to change dmg because 8 bullets are powerfull.

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
you can actually do it much easier and better. the original script already is not the best solution

like
1
2
3
4
for i=-3,4,1 do
	...
	rot=getplayerrotation(0)+i
	...
etc.
so you don't need all that if crap.
instead of +i you can do +(i*3) for example to increase the spread

alt Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Zitieren
I also need a small lua help (and I don't wat to open one more thread):

I tried it 10 times, but it will not function, can someone explain me how to make a "Grenade Launcher"?

Would be great if someone would make it.

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
I think it must be like Mortar.(original) just change energy, damage, explosion power(and range) and projectile picture.

I have question too:
Is there hook "start" or "startgame", and if yes, will that be working in weapon, and player must have that weapon for hook working or just including in weapons options(even 0)?

P.S.: I think this thread must be rename to "lua help" like thread"lua/questions/help" in CS2D

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
simply take the grenade code and allow to throw multiple grenades...

moreover use another image for cc cmd drawinhand in the weapon draw function

moreover you should remove the charging part and "shoot" the grenades with a constant speed.

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
DC hat geschrieben
moreover you should remove the charging part

Thats why I said about mortar. It has no charging part.
Like mortar in Worms

EDIT: Can script from some weapon work, if this weapon isn't used CURRENT turn?
3× editiert, zuletzt 09.01.10 20:56:02

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Vectar666 hat geschrieben
Will be server lua in the next version?
How should it work?
There is no server commands parsing.
Weapons Scripting Only

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
with variables and conditions (simply count down or count up).
note that CC runs with 50 fps.
this means: count to 20 (variable +/- 1 each frame) = 1 second

once (countdown setup):
countdown=10

each frame (increase/decrease countdown, check):
countdown=countdown-1
if (countdown==0) then ...

p.s.: no, you can't/shouldn't "stop" a Lua script and just wait for a certain time because this would stop the whole game (including all animations etc.) and this would be pretty bad.

alt Re: Lua Scripts/Questions/Help

Nem
User Off Offline

Zitieren
I am dumb to recognize where to add 'em
any basic example please ?
Anyway, i'll try to do some, if i done, i post.


Blazz helped meh, delay work perfect, but i got new problem, sound.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function cc.bfg.attack(attack)
	if (weapon_shots == 0) then cc.timer = 0 end
	if (attack == 1 and weapon_shots == 0) then
		weapon_shots = weapon_shots + 1
		cc.timer = os.clock()
	end
		playsound(cc.bfg.sfx_attack)
	if (weapon_shots > 0 and cc.timer > 0 and os.clock() > cc.timer + 1) then
		cc.timer = 0
			id=createprojectile(cc.bfg.ball.id)
			projectiles[id]={}
			projectiles[id].ignore=playercurrent()
			projectiles[id].x=getplayerx(0)+(6*getplayerdirection(0))+math.sin(math.rad(getplayerrotation(0)))*10.0
			projectiles[id].y=getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)))*10.0
     		projectiles[id].sx=math.sin(math.rad(getplayerrotation(0)))*15.0
	    	projectiles[id].sy=-math.cos(math.rad(getplayerrotation(0)))*15.0
			recoil(2)
			endturn()
		end
	end
wtf i need to do, to make           playsound(cc.bfg.sfx_attack) play just once ? :<
2× editiert, zuletzt 30.05.10 18:32:56

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
× never use os.clock() for action related stuff in your Carnage Contest weapon scripts because os.clock() is different on each PC. it will make your scripts asynchronous (run different for all players) which CAN result in strange bugs. all CC weapon scripts have to be written in a way that guarantees that they run equally on all PCs every time they are executed.
that's why I suggested to use a counter variable. it has to be incremented/decremented in the weapon update or attack (not draw!) function!
most scripts which allow you to shoot multiple projectiles are using such a timer. just check them (pistol for example). it's really simple! you can use the global weapon_timer variable for it.

for a sample of a looping sound check the dynamite script.
principle:
• use cc cmd playsound and assign a channel with the optional channel parameter
• use cc cmd channelplaying to check if the sound is still playing
• play it again (step 1) if it is not playing anymore

alt Re: Lua Scripts/Questions/Help

Nem
User Off Offline

Zitieren
DC hat geschrieben
× never use os.clock() for action related stuff in your Carnage Contest weapon scripts because os.clock() is different on each PC

Like math.random i used once with ammo, its different on each PC, lol

Anyway, thx DC, i'll try use Pistol and TNT as examples

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
yes, exactly. random values are bad as well. always set the random seed to a value which is equal at all PCs before using it
Zum Anfang Vorherige 1 2 3 4 5 Nächste Zum Anfang
Einloggen, um zu antwortenCarnage Contest-ÜbersichtForenübersicht