Looking for assistance learning FiveM development
Hello, Firstly, Thank you for taking the time to read this.
My friend & I have been working on trying to learn FiveM development for about a month now as we slowly build up a server. We have been learning mainly through reddit posts, discussions and youtube videos on how to do majority of things and it's gotten us quite far.
We're hoping this post will reach someone who has knowledge in building FiveM servers or is knowledgeable in Lua and is willing to mentor us on some of the more intricate obstacles we are struggling with such as learning how to properly use exports and integrate noscripts to communicate with each other such as notifications, MDT etc.
If this seems like something that might interest you or if you are willing to help please contact me via Discord @ dino0831 We are both eager to learn and catch on quickly. Hope to hear from you soon :)
Thank you
https://redd.it/1k2ef8j
@r_lua
Hello, Firstly, Thank you for taking the time to read this.
My friend & I have been working on trying to learn FiveM development for about a month now as we slowly build up a server. We have been learning mainly through reddit posts, discussions and youtube videos on how to do majority of things and it's gotten us quite far.
We're hoping this post will reach someone who has knowledge in building FiveM servers or is knowledgeable in Lua and is willing to mentor us on some of the more intricate obstacles we are struggling with such as learning how to properly use exports and integrate noscripts to communicate with each other such as notifications, MDT etc.
If this seems like something that might interest you or if you are willing to help please contact me via Discord @ dino0831 We are both eager to learn and catch on quickly. Hope to hear from you soon :)
Thank you
https://redd.it/1k2ef8j
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Okay so im reaching out im not sure how to look up what im about to ask
Ive been getting bored with the games that i have been playing and i was told to look up the lua game on roblox but it tells you how to do it but it is confusing me just wondering if im the only one ? If you have any info much appreciated
https://redd.it/1k31xt8
@r_lua
Ive been getting bored with the games that i have been playing and i was told to look up the lua game on roblox but it tells you how to do it but it is confusing me just wondering if im the only one ? If you have any info much appreciated
https://redd.it/1k31xt8
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Lua learning
I have wanted to learn lua for a while but have not had the time, but now I do, so I am just curious whether how do I start? Because I took a look at couple videos and I have to be honest I did not understand or keep in mind any of that. If you guys would send me some useful resources or a starting point to learn lua I would appreciate it.
https://redd.it/1k38fsn
@r_lua
I have wanted to learn lua for a while but have not had the time, but now I do, so I am just curious whether how do I start? Because I took a look at couple videos and I have to be honest I did not understand or keep in mind any of that. If you guys would send me some useful resources or a starting point to learn lua I would appreciate it.
https://redd.it/1k38fsn
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Compiling lua
Hello I have a game where the files for lua were in .lu so I decompiled them and the decompiler doesn't have an option to compile them back into .lu so I was wondering if anyone knows of a compiler that concerts lua into .lu, btw the Lua is 5.1
https://redd.it/1k3dk0s
@r_lua
Hello I have a game where the files for lua were in .lu so I decompiled them and the decompiler doesn't have an option to compile them back into .lu so I was wondering if anyone knows of a compiler that concerts lua into .lu, btw the Lua is 5.1
https://redd.it/1k3dk0s
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Can I use custom C API functions from Lua bytecode?
I'm thinking of precompiling Lua noscripts I upload to an unmanned vehicle that has a custom C API noscript runner thing. Would this be possible/feasible?
https://redd.it/1k3x9au
@r_lua
I'm thinking of precompiling Lua noscripts I upload to an unmanned vehicle that has a custom C API noscript runner thing. Would this be possible/feasible?
https://redd.it/1k3x9au
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Confused with OR operator
"if The logical operators are and, or, and not. Like control structures, all logical operators consider false and nil as false and anything else as true. The operator and returns its first argument if it is false; otherwise, it returns its second argument. The operator or returns its first argument if it is not false; otherwise, it returns its second argument:
print(4 and 5) --> 5
print(nil and 13) --> nil
print(false and 13) --> false
print(4 or 5) --> 4
print(false or 5) --> 5
Both and and or use short-cut evaluation, that is, they evaluate their second operand only when necessary."
I might be being dumb here, but as I understand OR in most operations, it evaluates true when either side is evaluated to be true, so shouldn't the last statement be printing false? I see that it says that they only evaluate the second operand when necessary, but wouldn't the first operand being false in an OR statement cause it to look at the second?
https://redd.it/1k42jt2
@r_lua
"if The logical operators are and, or, and not. Like control structures, all logical operators consider false and nil as false and anything else as true. The operator and returns its first argument if it is false; otherwise, it returns its second argument. The operator or returns its first argument if it is not false; otherwise, it returns its second argument:
print(4 and 5) --> 5
print(nil and 13) --> nil
print(false and 13) --> false
print(4 or 5) --> 4
print(false or 5) --> 5
Both and and or use short-cut evaluation, that is, they evaluate their second operand only when necessary."
I might be being dumb here, but as I understand OR in most operations, it evaluates true when either side is evaluated to be true, so shouldn't the last statement be printing false? I see that it says that they only evaluate the second operand when necessary, but wouldn't the first operand being false in an OR statement cause it to look at the second?
https://redd.it/1k42jt2
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I want to learn how to code with Lua - how do I start? where do I start?
For those who have experience with Lua, how did you start? where did you start?
All I know of Lua is that it is considered "simple" and that it is used for games - I really would like to somewhat grasp Lua so I can start considering making games myself.
https://redd.it/1k4ktdk
@r_lua
For those who have experience with Lua, how did you start? where did you start?
All I know of Lua is that it is considered "simple" and that it is used for games - I really would like to somewhat grasp Lua so I can start considering making games myself.
https://redd.it/1k4ktdk
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Do I need require for each TU?
I'm not super familiar with LUA. I have an entry point of so called main noscript -
https://redd.it/1k4lisq
@r_lua
I'm not super familiar with LUA. I have an entry point of so called main noscript -
entry.lua, I have a Logger.lua that has the tools for exactly what it says. Main noscripts has access to logger via require. Now I have to use logging tools in Events.lua - do I also need a require or because Events.lua is already "included" in main noscript the logging definitions are exposed higher up the chain and I can use them? And if I dont - any potentials side-effects form including them via require to appease luals?https://redd.it/1k4lisq
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
A simple noscript to generate html code.
I just wanted to share this code to generate html code from lua, i made this because i don't like writing html and for fun to do something in lua. Any sugestions to improve it?
https://gitlab.com/-/snippets/4836971
https://redd.it/1k5qng1
@r_lua
I just wanted to share this code to generate html code from lua, i made this because i don't like writing html and for fun to do something in lua. Any sugestions to improve it?
https://gitlab.com/-/snippets/4836971
https://redd.it/1k5qng1
@r_lua
GitLab
Generate html code from lua ($4836971) · Snippets · GitLab
Differences between Lua and LuaJIT?
Hi all. I've been a casual user of Lua for years and of LuaJIT for just a few months. I am not clear on all of the differences I need to know when writing code.
I know that integer division (//) is not implemented in LuaJIT and that LuaJIT has increased interoperability with C (which I haven't yet used). Yesterday I wrote a bit of code for LuaJIT that produces differently formatted output between Lua (5.4) and LuaJIT (5.1).
It worries me that there might be more gotchas lurking and a cheat sheet of everything a Lua programmer should know when switching to LuaJIT would be really useful (before I start diving into Lua version changes and seeing of this is a Lua version difference and not a Lua/LuaJIT difference).
Can anyone help?
https://redd.it/1k60myn
@r_lua
Hi all. I've been a casual user of Lua for years and of LuaJIT for just a few months. I am not clear on all of the differences I need to know when writing code.
I know that integer division (//) is not implemented in LuaJIT and that LuaJIT has increased interoperability with C (which I haven't yet used). Yesterday I wrote a bit of code for LuaJIT that produces differently formatted output between Lua (5.4) and LuaJIT (5.1).
It worries me that there might be more gotchas lurking and a cheat sheet of everything a Lua programmer should know when switching to LuaJIT would be really useful (before I start diving into Lua version changes and seeing of this is a Lua version difference and not a Lua/LuaJIT difference).
Can anyone help?
https://redd.it/1k60myn
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
simulate MicroLua on Mac?
Hi all,
I'm trying to make a DS game to be run via MicroLua DS on DSi. I'm using a 2020 MacBook Pro M1 computer.
To test my program, I first tried using MicroLua Simulator https://sourceforge.net/p/microlua/wiki/MicroLuaSimulator/ but I couldn't compile it.
Then I tried Desmume, using the instructions given here: https://sourceforge.net/p/microlua/wiki/DeSmuME/ but the gba slot it mentions was nowhere to be found.
what do?
https://redd.it/1k69cww
@r_lua
Hi all,
I'm trying to make a DS game to be run via MicroLua DS on DSi. I'm using a 2020 MacBook Pro M1 computer.
To test my program, I first tried using MicroLua Simulator https://sourceforge.net/p/microlua/wiki/MicroLuaSimulator/ but I couldn't compile it.
Then I tried Desmume, using the instructions given here: https://sourceforge.net/p/microlua/wiki/DeSmuME/ but the gba slot it mentions was nowhere to be found.
what do?
https://redd.it/1k69cww
@r_lua
is there a way i can make my noscript smaller?
i'm new to lua i just made a rock paper scissors game but i want to make the noscript smaller is there a way i can do that?
https://redd.it/1k83lvu
@r_lua
i'm new to lua i just made a rock paper scissors game but i want to make the noscript smaller is there a way i can do that?
math.randomseed(os.time())table = {"rock", "paper", "scissors"}number = math.random(1, 3)print ("Welcome to Rock Paper Scissors!\nChoose Your Move!")move = string.lower(io.read("*l"))if move == "rock" thenif number == 1 thenprint("Tie!")elseif number == 2 thenprint ("You Lose!")else print ("You Win!") endendif move == "paper" thenif number == 1 thenprint("You Win!")elseif number == 2 thenprint ("Tie!")else print ("You Lose!") endendif move == "scissors" thenif number == 1 thenprint("You Lose!")elseif number == 2 thenprint ("You Win!")else print ("You Lose!") endendprint (table[number])https://redd.it/1k83lvu
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
working on a laser targeting system. i am using a public lua radar that has the option to mark as a friendly(iff) or a target (lok) and i added a laser locking mode. it works except that it marks them as friendly's not target's. for stormworks
T={}F={}MT=10;MD=200;pi2=math.pi*2;p4=pi2/4;m=0;w,h=0,0;c=math.cos;r=table.remove;s=math.sin;srt=math.sqrt;tria=screen.drawTriangleF;sdc=screen.drawCircle;ot=output.setNumber;ip=input.getNumber;stc=screen.setColor;dL=screen.drawLine;function clr()for a,b in pairs(T)do b.lok=false end end;sb=output.setBool;function onTick()u,l=0,0;isP=input.getBool(2)tx=ip(23)ty=ip(24)cm=math.fmod((ip(22)+1.25)*pi2,pi2)Gx=ip(25)Gy=ip(26)rg=ip(28)alt=ip(29)ro=ip(30)*pi2;ptc=ip(31)*pi2;n=4;while n<12 do fx=ip(n)fy=ip(n+1)fz=ip(n+2)table.insert(F,{x=fx,y=fy,z=fz})n=n+3 end;if isP then t=idx(T,tx,ty)if t\~=nil then clr()sb(2,true)T[t\].lok=true else clr()sb(2,false)end end
\------------ laser mode start
select_x = input.getNumber(7)
select_y = input.getNumber(8)
if select_x \~= 0 and select_y \~= 0 then
local foundTarget = idx(T, select_x, select_y)
if foundTarget \~= nil then
clr()
T[foundTarget\].lok = true
sb(2, true)
end
end
\---------------laser mode end
;tg={tgt=input.getBool(1),d=ip(1),az=ip(2)*pi2,el=ip(3)*pi2,ttl=100,hd=0,spd=1,spdx=1,spdy=1,spdz=1,ti=m,br=0,lok=false,iff=false}h_dst=tg.d*c(tg.el)tg.tgx,tg.tgy,tg.tgz=cpT(Gx,Gy,alt,tg,ro,ptc,cm)if tg.tgt and h_dst>30 and h_dst<rg then e_t=nil;nrdst=math.huge;ni=nil;for e,f in ipairs(T)do px,py=nil,nil;dlt=(tg.ti-f.ti)/60;dist=srt((f.tgx-tg.tgx)\^2+(f.tgy-tg.tgy)\^2+(f.tgz-tg.tgz)\^2)if f.spd>50 then px=f.tgx+f.spdx*dlt;py=f.tgy+f.spdy*dlt;pz=f.tgz+f.spdz*dlt end;if px==nil or py==nil then if dist<=MD and dist<nrdst then nrdst=dist;e_t=f;ni=e end else sph=srt((tg.tgx-px)\^2+(tg.tgx-py)\^2+(tg.tgx-pz)\^2)if sph<=MD or dist<MD then e_t=f;ni=e end end end;if e_t then rz=tg.d/rg;tg.x=w/2+rz*w*2*math.cos(tg.az-p4)tg.y=h+rz*h*2*math.sin(tg.az-p4)dq=srt((tg.tgx-e_t.tgx)\^2+(tg.tgy-e_t.tgy)\^2+(tg.tgz-e_t.tgz)\^2)dlt=(tg.ti-e_t.ti)/60;spdx=(e_t.tgx-tg.tgx)/dlt;spdy=(e_t.tgy-tg.tgy)/dlt;spdz=(e_t.tgz-tg.tgz)/dlt;spd=srt(spdx\^2+spdy\^2)e_t.d=tg.d;e_t.az=tg.az;e_t.el=tg.el;e_t.x=tg.x;e_t.y=tg.y;e_t.ttl=100;e_t.iff=tg.iff;if dq>20 and math.abs(spd-e_t.spd)<200 then e_t.tgz=tg.tgz;e_t.tgy=tg.tgy;e_t.tgx=tg.tgx;e_t.spd=spd;e_t.spdx=spdx;e_t.spdy=spdy;e_t.spdz=spdz;hdg=cdH(e_t,tg)e_t.hd=hdg end;e_t.ti=tg.ti else if ni then r(T,ni)end;tg.id=#T+1;table.insert(T,tg)end end;if#T>MT then r(T,1)end;for a,tg in pairs(T)do for a,n in ipairs(F)do d=srt((tg.tgx-n.x)\^2+(tg.tgy-n.y)\^2+(tg.tgz-n.z)\^2)if d<50 then tg.iff=true end end;r_=tg.d/rg;h_dst=tg.d*c(tg.el)tg.x=w/2+r_*w*2*c(tg.az-p4)tg.y=h+r_*h*2*s(tg.az-p4)tg.ttl=tg.ttl-1;if tg.ttl<=0 then r(T,a)end;if h_dst>rg then r(T,a)end;if tg.lok then ot(7,tg.spd)ot(8,math.deg(tg.hd))ot(1,tg.tgx)ot(2,tg.tgy)ot(3,tg.tgz)ot(10,tg.az)ot(11,tg.el)end end;ot(5,#T)m=m+1 end;function onDraw()w=screen.getWidth()h=screen.getHeight()stc(0,255,0,255)for i,b in pairs(T)do dh(b,i)end end;function dh(tg,i)xd,xy=tg.x,tg.y;o=tg.hd;if tg.iff then stc(0,255,255,tg.ttl+150)else stc(0,255,0,tg.ttl+150)end;g=2;if tg.tgz>200 then g=3 elseif tg.tgz>400 then g=5 end;x1,y1=xd+g*c(o),xy+g*s(o)o=o+2*math.pi/3;x2,y2=xd+g*c(o),xy+g*s(o)o=o+2*math.pi/3;x3,y3=xd+g*c(o),xy+g*s(o)if tg.tgz<50 then if tg.lok then stc(255,150,0)screen.drawText(xd-4,xy,"[+\]")else screen.drawText(xd,xy,"+")end else if tg.lok then stc(255,150,0)tria(x1,y1,x2,y2,x3,y3)else screen.drawTriangle(x1,y1,x2,y2,x3,y3)end;dL(x1,y1,x1+4*s(tg.hd+p4),y1-4*c(tg.hd+p4))end end;function cdH(o,n)hd=cm-math.atan(n.spdy-o.spdy,n.spdx-o.spdx)-p4;return hd end;function idx(j,k,p)for e,b in pairs(j)do if k<=b.x+2 and k>=b.x-2 and p<=b.y+2 and p>=b.y-2 then return e end end;return nil end;function idM()return{{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}end;function mxM(j,q)ra=idM()for e=1,4 do for v=1,4 do sum=0;for i=1,4 do sum=sum+j[e\][i\]*q[i\][v\]end;ra[e\][v\]=sum end end;return ra end;function
T={}F={}MT=10;MD=200;pi2=math.pi*2;p4=pi2/4;m=0;w,h=0,0;c=math.cos;r=table.remove;s=math.sin;srt=math.sqrt;tria=screen.drawTriangleF;sdc=screen.drawCircle;ot=output.setNumber;ip=input.getNumber;stc=screen.setColor;dL=screen.drawLine;function clr()for a,b in pairs(T)do b.lok=false end end;sb=output.setBool;function onTick()u,l=0,0;isP=input.getBool(2)tx=ip(23)ty=ip(24)cm=math.fmod((ip(22)+1.25)*pi2,pi2)Gx=ip(25)Gy=ip(26)rg=ip(28)alt=ip(29)ro=ip(30)*pi2;ptc=ip(31)*pi2;n=4;while n<12 do fx=ip(n)fy=ip(n+1)fz=ip(n+2)table.insert(F,{x=fx,y=fy,z=fz})n=n+3 end;if isP then t=idx(T,tx,ty)if t\~=nil then clr()sb(2,true)T[t\].lok=true else clr()sb(2,false)end end
\------------ laser mode start
select_x = input.getNumber(7)
select_y = input.getNumber(8)
if select_x \~= 0 and select_y \~= 0 then
local foundTarget = idx(T, select_x, select_y)
if foundTarget \~= nil then
clr()
T[foundTarget\].lok = true
sb(2, true)
end
end
\---------------laser mode end
;tg={tgt=input.getBool(1),d=ip(1),az=ip(2)*pi2,el=ip(3)*pi2,ttl=100,hd=0,spd=1,spdx=1,spdy=1,spdz=1,ti=m,br=0,lok=false,iff=false}h_dst=tg.d*c(tg.el)tg.tgx,tg.tgy,tg.tgz=cpT(Gx,Gy,alt,tg,ro,ptc,cm)if tg.tgt and h_dst>30 and h_dst<rg then e_t=nil;nrdst=math.huge;ni=nil;for e,f in ipairs(T)do px,py=nil,nil;dlt=(tg.ti-f.ti)/60;dist=srt((f.tgx-tg.tgx)\^2+(f.tgy-tg.tgy)\^2+(f.tgz-tg.tgz)\^2)if f.spd>50 then px=f.tgx+f.spdx*dlt;py=f.tgy+f.spdy*dlt;pz=f.tgz+f.spdz*dlt end;if px==nil or py==nil then if dist<=MD and dist<nrdst then nrdst=dist;e_t=f;ni=e end else sph=srt((tg.tgx-px)\^2+(tg.tgx-py)\^2+(tg.tgx-pz)\^2)if sph<=MD or dist<MD then e_t=f;ni=e end end end;if e_t then rz=tg.d/rg;tg.x=w/2+rz*w*2*math.cos(tg.az-p4)tg.y=h+rz*h*2*math.sin(tg.az-p4)dq=srt((tg.tgx-e_t.tgx)\^2+(tg.tgy-e_t.tgy)\^2+(tg.tgz-e_t.tgz)\^2)dlt=(tg.ti-e_t.ti)/60;spdx=(e_t.tgx-tg.tgx)/dlt;spdy=(e_t.tgy-tg.tgy)/dlt;spdz=(e_t.tgz-tg.tgz)/dlt;spd=srt(spdx\^2+spdy\^2)e_t.d=tg.d;e_t.az=tg.az;e_t.el=tg.el;e_t.x=tg.x;e_t.y=tg.y;e_t.ttl=100;e_t.iff=tg.iff;if dq>20 and math.abs(spd-e_t.spd)<200 then e_t.tgz=tg.tgz;e_t.tgy=tg.tgy;e_t.tgx=tg.tgx;e_t.spd=spd;e_t.spdx=spdx;e_t.spdy=spdy;e_t.spdz=spdz;hdg=cdH(e_t,tg)e_t.hd=hdg end;e_t.ti=tg.ti else if ni then r(T,ni)end;tg.id=#T+1;table.insert(T,tg)end end;if#T>MT then r(T,1)end;for a,tg in pairs(T)do for a,n in ipairs(F)do d=srt((tg.tgx-n.x)\^2+(tg.tgy-n.y)\^2+(tg.tgz-n.z)\^2)if d<50 then tg.iff=true end end;r_=tg.d/rg;h_dst=tg.d*c(tg.el)tg.x=w/2+r_*w*2*c(tg.az-p4)tg.y=h+r_*h*2*s(tg.az-p4)tg.ttl=tg.ttl-1;if tg.ttl<=0 then r(T,a)end;if h_dst>rg then r(T,a)end;if tg.lok then ot(7,tg.spd)ot(8,math.deg(tg.hd))ot(1,tg.tgx)ot(2,tg.tgy)ot(3,tg.tgz)ot(10,tg.az)ot(11,tg.el)end end;ot(5,#T)m=m+1 end;function onDraw()w=screen.getWidth()h=screen.getHeight()stc(0,255,0,255)for i,b in pairs(T)do dh(b,i)end end;function dh(tg,i)xd,xy=tg.x,tg.y;o=tg.hd;if tg.iff then stc(0,255,255,tg.ttl+150)else stc(0,255,0,tg.ttl+150)end;g=2;if tg.tgz>200 then g=3 elseif tg.tgz>400 then g=5 end;x1,y1=xd+g*c(o),xy+g*s(o)o=o+2*math.pi/3;x2,y2=xd+g*c(o),xy+g*s(o)o=o+2*math.pi/3;x3,y3=xd+g*c(o),xy+g*s(o)if tg.tgz<50 then if tg.lok then stc(255,150,0)screen.drawText(xd-4,xy,"[+\]")else screen.drawText(xd,xy,"+")end else if tg.lok then stc(255,150,0)tria(x1,y1,x2,y2,x3,y3)else screen.drawTriangle(x1,y1,x2,y2,x3,y3)end;dL(x1,y1,x1+4*s(tg.hd+p4),y1-4*c(tg.hd+p4))end end;function cdH(o,n)hd=cm-math.atan(n.spdy-o.spdy,n.spdx-o.spdx)-p4;return hd end;function idx(j,k,p)for e,b in pairs(j)do if k<=b.x+2 and k>=b.x-2 and p<=b.y+2 and p>=b.y-2 then return e end end;return nil end;function idM()return{{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}end;function mxM(j,q)ra=idM()for e=1,4 do for v=1,4 do sum=0;for i=1,4 do sum=sum+j[e\][i\]*q[i\][v\]end;ra[e\][v\]=sum end end;return ra end;function
mxapp(m,k,p,x)rx=m[1\][1\]*k+m[1\][2\]*p+m[1\][3\]*x+m[1\][4\]ry=m[2\][1\]*k+m[2\][2\]*p+m[2\][3\]*x+m[2\][4\]rz=m[3\][1\]*k+m[3\][2\]*p+m[3\][3\]*x+m[3\][4\]return rx,ry,rz end;function mRx(j)return{{1,0,0,0},{0,c(j),-s(j),0},{0,s(j),c(j),0},{0,0,0,1}}end;function mRy(j)return{{c(j),0,s(j),0},{0,1,0,0},{-s(j),0,c(j),0},{0,0,0,1}}end;function mRz(j)return{{c(j),-s(j),0,0},{s(j),c(j),0,0},{0,0,1,0},{0,0,0,1}}end;function mxT(k,p,x)return{{1,0,0,k},{0,1,0,p},{0,0,1,x},{0,0,0,1}}end;function cpT(y,z,A,tg,r,B,p)mxc=mxM(mxT(y,-z,A),mxM(mRz(-p),mxM(mRy(-B),mRx(-r))))Txr=tg.d*c(tg.az)*c(tg.el)tyr=tg.d*s(tg.az)*c(tg.el)tzt=tg.d*s(tg.el)Tx,Ty,Tz=mxapp(mxc,Txr,tyr,tzt)return Tx,-Ty,Tz end
https://redd.it/1k84z5n
@r_lua
https://redd.it/1k84z5n
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I made a little rock paper scissors program inspired by a recent post
Idk why but seeing this post https://www.reddit.com/r/lua/s/eWJooyqrJZ
Just gave me an itch to remake it, anyway:
https://redd.it/1k8gezl
@r_lua
Idk why but seeing this post https://www.reddit.com/r/lua/s/eWJooyqrJZ
Just gave me an itch to remake it, anyway:
local moves = {
rock = {rock = "Draw", paper = "Loss", scissors = "Win!"},
paper = {rock = "Win!", paper = "Draw", scissors = "Loss"},
scissors = {rock = "Loss", paper = "Win!", scissors = "Draw"}
}
local function GetRandMove(randNum)
local n = 0
local randNum = math.random(1, 3)
for k, _ in pairs(moves) do
n = n + 1
if randNum == n then return k end
end
end
local function sleep(n)
local t = os.time() + n
while os.time() < t do end
end
print([[
Time to Play:
--------
rock
paper
scissors
--------
]])
while true do
print("\nYour Move: ")
local PlayerInput = io.read()
local BotMove = GetRandMove()
print(BotMove, "\n")
sleep(.2)
print(moves[PlayerInput][BotMove])
sleep(.4)
::playagain::
print("\ntype y to play again or x to quit: \n")
local playAgain = io.read()
if playAgain == "x" then
print("Goodbye!")
break
elseif playAgain == "y" then
print("\nAlright!\n")
else
goto playagain
end
end
https://redd.it/1k8gezl
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Yo guys, I have a question about the book
Is the book still relevant? And do you think it's worth buying or should I focus on learning from the internet?
https://redd.it/1k8jpsx
@r_lua
Is the book still relevant? And do you think it's worth buying or should I focus on learning from the internet?
https://redd.it/1k8jpsx
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I'm trying to make a nice TV weather app, to show the potential and validate my cross-platform framework.
https://redd.it/1k8t3z7
@r_lua
https://redd.it/1k8t3z7
@r_lua
Is there ANY difference between these two Lua snippets?
Snippet 1:
local function f(x,y)
local y = y or 1 -- Note: "local" here.`
do_something(x,y)
end
Snippet 2:
local function f(x,y)
y = y or 1 -- Note: no "local" here.
do_something(x,y)
end
I know why this pattern is often used but is there any situation whatsoever where these two snippets do not behave identically? If Lua version matters, I am specifically interested in LuaJIT. Also, if it matters, let's assume x and y are simple Lua values. They are **not** objects and don't have metatables.
https://redd.it/1k93frj
@r_lua
Snippet 1:
local function f(x,y)
local y = y or 1 -- Note: "local" here.`
do_something(x,y)
end
Snippet 2:
local function f(x,y)
y = y or 1 -- Note: no "local" here.
do_something(x,y)
end
I know why this pattern is often used but is there any situation whatsoever where these two snippets do not behave identically? If Lua version matters, I am specifically interested in LuaJIT. Also, if it matters, let's assume x and y are simple Lua values. They are **not** objects and don't have metatables.
https://redd.it/1k93frj
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community