Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2179 180 181338 339 Next To the start

old Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Quote
The conjunction operator and returns its first argument if this value is false or nil; otherwise, and returns its second argument. The disjunction operator or returns its first argument if this value is different from nil and false; otherwise, or returns its second argument. Both and and or use short-cut evaluation, that is, the second operand is evaluated only if necessary.



Why would you wanna use this for fucks sake..

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
YellowBanana has written

Why would you wanna use this for fucks sake..

well sometimes it can lessen the effort and time put into a script or a chunk of code

Example:
1
2
3
4
5
6
7
function factorial(n)
	if n == 1 or n == 0 then
		return 1
	else
		return n * factorial(n - 1)
	end
end
I could also do it this way:
1
2
3
function factorial(n)             
  	return n == 0 and 1 or n * factorial(n - 1)
end
see there is a difference in characters between the two functions, but each do the exact same operation

old Re: Lua Scripts/Questions/Help

Decks
User Off Offline

Quote
Pikachu_Lv85 has written
Decks has written
Decks has written
someone clever can help me with my problem?

its very important for me how create lua scrypt for other specmode for spectators or simple player

someone help me?

Ehm, what do you mean?
I doubt anyone can help you like that.

i mean, i think about scrypt lua which create other spectator mode for spectators than the rest, but i dont know how that do

old Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

Quote
Decks has written
Pikachu_Lv85 has written
Decks has written
Decks has written
someone clever can help me with my problem?

its very important for me how create lua scrypt for other specmode for spectators or simple player

someone help me?

Ehm, what do you mean?
I doubt anyone can help you like that.

i mean, i think about scrypt lua which create other spectator mode for spectators than the rest, but i dont know how that do

Let me guess... Impossible?
(Since no one gave a reply for months)

EDIT: I think I get it, he wants a script which allows individual spectator modes per spectator (Or am I wrong? )
edited 1×, last 25.03.10 10:54:30 am

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
I don't think it's impossible (I didn't understand what he meant neither) but maybe nobody answered because no one wants to do his job?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Decks has written
but that scrypt can be very helpful in matches

Make it by yourself and claim the infinite honour (and therefore, print your name in the humanity's history) for making a useful script for CS2D.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Here
info.txt has written
build(id,type,x,y,mode,objectid)               on (effective) build
-id: player id
-type: building type
-x: building x (tiles)
-y: building y (tiles)
-mode: building mode
-objectid: id of new building object
>return:     0 - proceed normally
          1 - don't build


However, I don't know how would you get the id of a building you have created through parsing/command line.
Edit:
Maybe
1
2
3
--parse(make some building)
local asd = object(0,"table")
local building_id = asd[#asd] --The last item should be the newest building, right?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
building_id will store the last dynamic object(asd[#asd]) in the dynamic objects table, so if you call it in the build hook, you will be calling it inmediatly and therefore, before any other building gets built.
edited 1×, last 23.03.10 11:11:03 pm

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Well, I made some functions. I do not know if anyone will be able to use them, but here they are.
Spoiler >

I am not sure if anyone needs them but you might beable to use io.copy for quickly backing up data
use them as you please but at least have the dignity to give me credit

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
You could improve your io.copy by reading all the file at once and writing it. Instead of reading line per line, concatenating and then writing.
Like this:
1
2
3
4
5
6
7
8
9
10
11
12
function io.copy(old,new)
	old = assert(io.open(old,"r"),"FILE NOT FOUND")
	new = io.open(new,"r")
	if not new then
		new=io.open(new,"w")
	else
		error("FILE ALREADY EXISTS")
	end
	new:write(old:read("*a"))
	old:close()
	new:close()
end
edited 1×, last 25.03.10 05:18:06 am

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
I want to spawn a player with a M4A1 .
But i don't want that he has full ammo.
Can I strip ammo in Lua?

The Code:
1
2
3
4
5
addhook("spawn","mspawn")
function mspawn(id)
	parse("equip "..id.." 42")
	--How to strip ammo?
end

old Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

Quote
Patasuss has written
I want to spawn a player with a M4A1 .
But i don't want that he has full ammo.
Can I strip ammo in Lua?

The Code:
1
2
3
4
5
addhook("spawn","mspawn")
function mspawn(id)
	parse("equip "..id.." 42")
	--How to strip ammo?
end

Ugh, you can't strip ammo (I am not sure how). And 42 isn't M4A1. It's 32.

old Re: Lua Scripts/Questions/Help

Szkieletor
User Off Offline

Quote
I'd like a script with another money container, so I can have more than 16,000$ at a time. Like the script in [CC]RolePlay server. I've searched the forums for it, but couldn't find one. Can someone help me please?

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
Here you can have my script (i know that it's buggy)
It also haves a weapon store.
Spoiler >

You are allowed to edit it.
But please do not claim as your own and if you
modify this script and give it to another person please give credits and do not cut out the information at the top of the file.

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
where i can download the cc rp script theres alot of ppl with it , i did enter on alot of servers with it

but isnt the same have less things but i want to have it ...

old Re: Lua Scripts/Questions/Help

0ito
User Off Offline

Quote
someone help me for sound environmental and shopping menu with infection bomb, rage zombie , antidote , armors and weapons?
please help-me FAST!

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Need help.How to make 1 times use button ? here is my script:
Spoiler >
To the start Previous 1 2179 180 181338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview