mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-08 18:30:35 +00:00
Can now define a Help global function in Outlaw, and it'll get called when '?' is hit in the gme.
This commit is contained in:
parent
30a9f15ae2
commit
bb0a9339fe
@ -2329,7 +2329,8 @@ end
|
|||||||
|
|
||||||
// Translate global scripts to code
|
// Translate global scripts to code
|
||||||
def gsmod = new ScriptModule()
|
def gsmod = new ScriptModule()
|
||||||
gsmod.genScriptDefs(new File("build/src/plasma/gen_globalScripts.plh.new"), dataIn.global.scripts)
|
gsmod.genScriptDefs(new File("build/src/plasma/gen_globalScripts.plh.new"), dataIn.global.scripts,
|
||||||
|
["newGame", "help"] as Set)
|
||||||
replaceIfDiff("build/src/plasma/gen_globalScripts.plh")
|
replaceIfDiff("build/src/plasma/gen_globalScripts.plh")
|
||||||
gsmod.packGlobalScripts(new File("build/src/plasma/gen_globalScripts.pla.new"), dataIn.global.scripts)
|
gsmod.packGlobalScripts(new File("build/src/plasma/gen_globalScripts.pla.new"), dataIn.global.scripts)
|
||||||
replaceIfDiff("build/src/plasma/gen_globalScripts.pla")
|
replaceIfDiff("build/src/plasma/gen_globalScripts.pla")
|
||||||
@ -2528,19 +2529,25 @@ end
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate header for a set of scripts.
|
* Generate header for a set of scripts. If any of the 'required' scripts are not
|
||||||
|
* found, they'll get a special offset of -1.
|
||||||
*/
|
*/
|
||||||
def genScriptDefs(outFile, inScripts)
|
def genScriptDefs(outFile, inScripts, required)
|
||||||
{
|
{
|
||||||
out = new PrintWriter(new FileWriter(outFile))
|
out = new PrintWriter(new FileWriter(outFile))
|
||||||
out << "// Generated code - DO NOT MODIFY BY HAND\n\n"
|
out << "// Generated code - DO NOT MODIFY BY HAND\n\n"
|
||||||
|
|
||||||
// Generate a name for each script, and a constant in the function table.
|
// Generate a name for each script, and a constant in the function table.
|
||||||
|
def found = [] as Set
|
||||||
inScripts.script.eachWithIndex { script, idx ->
|
inScripts.script.eachWithIndex { script, idx ->
|
||||||
def name = getScriptName(script)
|
def name = getScriptName(script)
|
||||||
assert name
|
assert name
|
||||||
scriptNames[script] = "sc_${humanNameToSymbol(name, false)}"
|
scriptNames[script] = "sc_${humanNameToSymbol(name, false)}"
|
||||||
out << "const ${scriptNames[script]} = ${idx*2}\n"
|
out << "const ${scriptNames[script]} = ${idx*2}\n"
|
||||||
|
found.add(humanNameToSymbol(name, false))
|
||||||
|
}
|
||||||
|
(required - found).each { name ->
|
||||||
|
out << "const sc_$name = -1 // not found\n"
|
||||||
}
|
}
|
||||||
out.close()
|
out.close()
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ def newGame()
|
|||||||
globalScriptsModule = mmgr(QUEUE_LOAD, MODULE_GEN_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE)
|
globalScriptsModule = mmgr(QUEUE_LOAD, MODULE_GEN_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE)
|
||||||
mmgr(FINISH_LOAD, LEAVE_OPEN)
|
mmgr(FINISH_LOAD, LEAVE_OPEN)
|
||||||
playersModule()=>makeInitialParty()
|
playersModule()=>makeInitialParty()
|
||||||
globalScriptsModule()=>sc_newGame()
|
if sc_newGame >= 0; globalScriptsModule()=>sc_newGame(); fin
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -33,6 +33,7 @@ include "gen_images.plh"
|
|||||||
include "gen_modules.plh"
|
include "gen_modules.plh"
|
||||||
include "gen_enemies.plh"
|
include "gen_enemies.plh"
|
||||||
include "gen_players.plh"
|
include "gen_players.plh"
|
||||||
|
include "gen_globalScripts.plh"
|
||||||
include "combat.plh"
|
include "combat.plh"
|
||||||
include "party.plh"
|
include "party.plh"
|
||||||
include "diskops.plh"
|
include "diskops.plh"
|
||||||
@ -2022,6 +2023,21 @@ def loadGame
|
|||||||
restoreMapPos()
|
restoreMapPos()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def help
|
||||||
|
word globalScriptsModule
|
||||||
|
|
||||||
|
if sc_help >= 0
|
||||||
|
flipToPage1()
|
||||||
|
setMapWindow(); clearWindow()
|
||||||
|
loadEngine(MODULE_GEN_GLOBAL_SCRIPTS)=>sc_help()
|
||||||
|
restoreMapPos()
|
||||||
|
else
|
||||||
|
scriptDisplayStr("Help not available.\n")
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set up the command table for 3D mode
|
// Set up the command table for 3D mode
|
||||||
def initCmds()
|
def initCmds()
|
||||||
@ -2043,6 +2059,7 @@ def initCmds()
|
|||||||
cmdTbl['3'] = @showPlayer3
|
cmdTbl['3'] = @showPlayer3
|
||||||
cmdTbl[$13] = @saveGame // ctrl-S
|
cmdTbl[$13] = @saveGame // ctrl-S
|
||||||
cmdTbl[$0c] = @loadGame // ctrl-L
|
cmdTbl[$0c] = @loadGame // ctrl-L
|
||||||
|
cmdTbl['?'] = @help
|
||||||
|
|
||||||
// Commands handled differently in 3D vs 2D
|
// Commands handled differently in 3D vs 2D
|
||||||
if mapIs3D
|
if mapIs3D
|
||||||
|
Loading…
x
Reference in New Issue
Block a user