Im looking at a few methods for battle systems in my rpg and was wondering if anybody had used LUA for this type of process ?. Any feedback welcomed thanks :)
Using Lua For a Battle System
BlitzMax Forums/BlitzMax Programming/Using Lua For a Battle SystemStrict Import axe.lua Global Player:Char=Char.Create(["Bobby","100","10","5","2"]) Global Enemy:Char=Char.Create(["PurpleDragon","100","10","5","2"]) Type Char Global Stat$[]=["Name","HP","STR","DEF","Skill"] Field Stat_Val$[] Function Create:Char(_Val$[]) Local I:Char=New Char i.Stat_Val=_Val Return I End Function Function Player_Stat$(_Stat$) For Local i=0 To Stat$.length-1 If Stat$[i]=_Stat$ Then Return Player.Stat_Val$[i] EndIf Next End Function Function Enemy_Stat$(_Stat$) For Local i=0 To Stat$.length-1 If Stat$[i]=_Stat$ Then Return Enemy.Stat_Val$[i] EndIf Next End Function End Type
I want to set up a Simple combat system
I want the LUA to
Do this Sum
a= Player Str+ (Rnd(10-Player Skill)+Player Skill)
b= Enemy Def+ Rnd(5)
c= b-a
if c>0 then Enemy Hp:-c
Print "hit Enemy for "+c+" Damage"
else
Print "You Missed him ninni"
endif
how would i go about that
Import axe.lua 'In C: 'lua_State* luaVM = lua_open(0); Local luaVM:Byte Ptr = lua_open( ) 'In C: 'lua_baselibopen(luaVM); 'lua_iolibopen(luaVM); 'lua_strlibopen(luaVM); 'lua_mathlibopen(luaVM); luaopen_base(luaVM) luaopen_table(luaVM) luaopen_io(luaVM) luaopen_string(luaVM) luaopen_math(luaVM) Print "Enter Lua commands below. Enter a blank line to quit." Local outfile:TStream Local cmd:String Repeat outfile = WriteFile("temp.lua") cmd = Input ("> ") WriteLine outfile, cmd CloseFile(outfile) lua_dofile(luaVM,"temp.lua".ToCString()) FlushMem Until cmd="" DeleteFile("temp.lua") 'In C: 'lua_close(luaVM); lua_close(luaVM)
What needs to be changed to get this to work with current axe.Lua
Wish I could help. Unfortunately it'll be a while before I need (and have the time) to get up to speed on Lua. :/