Altamurenza

LUA Tutorial: String to function

Jan 27th, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. -- Convert string to function
  2.  
  3. -- Setup:
  4. gSetup = {
  5.     -- function (string), function arguments:
  6.     {"TextPrintString",{"Hello World",2,1}},
  7.     {"ClockSet",{8,45}},
  8.     {"PlayerKilled",{""}},
  9.     {"PedSetWeapon",{gPlayer,305,50}},
  10.     {"ForceStartMission",{"6_B"}},
  11. }
  12. -- Main function:
  13. function main()
  14.     Wait(450)
  15.    
  16.     while true do
  17.         if IsButtonBeingPressed(3,0) then
  18.             -- Random call:
  19.             local Random = math.random(1,table.getn(gSetup))
  20.             _G[gSetup[Random][1]](unpack(gSetup[Random][2]))
  21.         end
  22.        
  23.         Wait(0)
  24.     end
  25. end
Add Comment
Please, Sign In to add comment