Things are really coming together. I am now able to write a great deal of python code that will import directly into ScriptVM and run without tweaking. By running a python script you can translate a python file to a block of opcodes and parameters which you can run from the UDK console. I'm just pasting from one to the other right now.
This process could be implemented a few ways eventually. The python program could be shelled out from the mission-scripting interface and the pre-translated code is saved in the database, and that code is loaded into UDK to run. We could also have a dll which UDK could call on, which in turn would call on python to translate python text to scriptvm interpereter code real-time as well if needed. The latter seems like it would mainly be necessary if we wanted more in-game editing and debugging abilities. I think I will be wrapping up the ScriptVM for the most part in the next week at the most, so I can shift to working on Dialog and Missions/Objectives again and keep to my goals for August.
Here's a taste of the before and after.
Python file to return a status based on player's physical and stun health:
global character
h = character.gethealth()
if character.hashealth('stun'):
s = character.gethealth('stun')
else:
s = 0
if 0 < s < h:
return 'Feeling pumped up'
elif 0 < s:
return 'Feeling sharp minded'
else:
return 'Feeling bad!'
Here's the output in interpreter code:
GETGLB,character
GETATTR,gethealth
CALL,0
SETLOC,h
IF
GETGLB,character
GETATTR,hashealth
PUSHS,stun
CALL,1
TEST
GETGLB,character
GETATTR,gethealth
PUSHS,stun
CALL,1
SETLOC,s
ELSE
PUSHI,0
SETLOC,s
END
IF
PUSHI,0
GETLOC,s
DUP
ROT_3
CMP,<
JMPF_OR_POP,4
GETLOC,h
CMP,<
JMP_REL,3
ROT_2
POP
TEST
PUSHS,Feeling\_pumped\_up
RETURN
ELSE
IF
PUSHI,0
GETLOC,s
CMP,<
TEST
PUSHS,Feeling\_sharp\_minded
RETURN
ELSE
PUSHS,Feeling\_bad!
RETURN
END
END
Yeah, it's a little like looking at assembly code mixed with basic. That's a virtual machine for ya.