Forum

> > CS2D > Scripts > Multiplication by the variable
Forums overviewCS2D overview Scripts overviewLog in to reply

English Multiplication by the variable

5 replies
To the start Previous 1 Next To the start

old Multiplication by the variable

orkin2913
User Off Offline

Quote
Hi,
i must multiplied a variable xyz[id] by variable zyx
it looks like this:
1
2
3
4
5
zyx = 15
if unknow[id]==1 then
unknowxyz[id]=xyz[id]*zyx
msg2(id,"Your number is '..unknowxyz[id]..'!@C")
end
However I can not multiply by zyx, I have to multiply by 15.
I have to write it that multiplied by zyx
Any suggestions on how to fix this?

old Re: Multiplication by the variable

EngiN33R
Moderator Off Offline

Quote
Unless you have some kind of error in the xyz table, this should work. I tested this code:

1
2
3
4
5
6
zyx=15
xyz={1,2,3,4,5}

for i=1,5 do
	print(xyz[i]*zyx)
end

And it worked perfectly.

old Re: Multiplication by the variable

uaiek
User Off Offline

Quote
user orkin2913 has written
Spoiler >


There is a wrong string usage at line 4.
it should be
1
msg2(id,"Your number is "..unknowxyz[id].."!@C")
or
1
msg2(id,'Your number is '..unknowxyz[id]..'!@C')

old Re: Multiplication by the variable

EngiN33R
Moderator Off Offline

Quote
user orkin2913 has written
hmm, why you use "print"?
I need to a variable unknowxyz multiplied xyz and zyx but no print...


I use it to see the answer. You can as well set it, it won't make a difference.

Also, user uaiek has a fair point. Maybe that's why it doesn't work.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview