Forum

> > Carnage Contest > Lua Scripts/Questions/Help
Forums overviewCarnage Contest overviewLog in to reply

English Lua Scripts/Questions/Help

89 replies
Page
To the start Previous 1 2 3 4 5 Next To the start

old Lua Scripts/Questions/Help

Nem
User Off Offline

Quote
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 ?
edited 1×, last 16.09.10 05:07:07 pm

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
Nemesis has written
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.

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
DC has written
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?
edited 3×, last 09.01.10 08:56:02 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Vectar666 has written
Will be server lua in the next version?
How should it work?
There is no server commands parsing.
Weapons Scripting Only

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

Nem
User Off Offline

Quote
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 ? :<
edited 2×, last 30.05.10 06:32:56 pm

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
× 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

old Re: Lua Scripts/Questions/Help

Nem
User Off Offline

Quote
DC has written
× 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

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
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
To the start Previous 1 2 3 4 5 Next To the start
Log in to replyCarnage Contest overviewForums overview