Well, I've spent a good hour just trying to get this to work. Here's my lua code:
Global.lua (Copied from example)
-- This script defines some stuff needed for all other scripts
-- A table to hold ALL entity information
Entities = {}
-- A table to hold ALL weapon information
Weapons = {}
-- Bools
YES = 1
NO = 0
-- Ammo
bullets = 1
shells = 2
rockets = 3
cells = 4
-- Short function names
Obj2Pt = ObjectPointDistance
Weapons.LUA
-- Pistol Definition and Action file
Weapons =
{
Ammotype=1,
Ammopershot=1,
Attack="plrbulattack",
Free=1,
Refireatframe=0,
Model="models/hud/v_dpistol/hud_pistol.MD2",
Texture="models/hud/_vdpistol/hud_pistol.bmp",
Flash="models/hud/_vdpistol/hud_pistol_MF.MD2",
Flash0="models/hud/_vdpistol/hud_pistol_MF0.bmp",
Flash1="models/hud/_vdpistol/hud_pistol_MF1.bmp"
}
DBP Code:
function LoadScripts()
set dir "scripts"
// NULL=load lua("Globals.LUA") //Not needed anymore, auto loaded
perform checklist for files
for k=1 to checklist quantity()
ext$=STR Get File Extension(checklist string$(k))
nam$=STR Extract Filename(checklist string$(k))
if lower$(ext$)="lua"
NULL=load lua(checklist string$(k))
dis$=dis$+";"+checklist string$(k)
endif
next k
set dir ".."
message dis$
endfunction
function LoadWeapons()
//Load Pistol
weapons(1).ammopershot=Lua Array Int("weapons->ammotype")
message str$(weapons(1).ammopershot)
endfunction
It keeps saying the array is invalid.
BTW, I'm using code surge, so I can do '//' for comments. Any help will be greatly apperciated.