POV Statuses In Libraries

Sora574
14 Mar 2013, 03:49
Hey there, I've noticed something that kind of... Bothers me.
Why can't we add POV status attributes directly into the game with libraries without making functions?
I know that we could just do something like this:
<function name="InitStatus"><![CDATA[
if (game.status) {
if (game.povstatusattributes = null)
game.povstatusattributes = NewStringDictionary()
}
dictionary add (game.povstatusattributes, "status", "Status: !")
}
]]></function>

But then you have to call the InitStatus function each time you want to show the status...
Not to mention you would also have to have another function like this
<function name="InitPOVStatus" parameters="new, old"><![CDATA[
if (game.showstatus) {
new.status = 10
new.changedstatus => {
if (this.status <= 0) {
this.status = 0
}
}
}
]]></function>

that you have to put into a Turn Script, as well as a script every time you start a game or switch players, which gets annoying fast.

Basically, what I'm suggesting (if you can't already do it) is to be able to edit the game's InitPOV functions and InitStatusAttributes functions from inside of a library. The easiest way I can think of doing this would probably be to use something like 'foreach' in the function, and then make a script dictionary for each of them to run scripts from, instead of hard-coding the scripts into the Core files. Then, from inside the library, all you would have to do is something like...
<type name="gamestatus">
<status />
<start_status type="script">
script => {
if (game.status) {
if (game.povstatusattributes = null)
game.povstatusattributes = NewStringDictionary()
}
dictionary add (game.povstatusattributes, "status", "Status: !")
}
}
dictionary add (InitStatusAttributesDict(), "status", script)
script = null
script => {
if (game.showstatus) {
new.status = 10
new.changedstatus => {
if (this.status <= 0) {
this.status = 0
}
}
}
}
dictionary add (InitPOVDict(), "status", script)
game.original_start = game.start
</start_status>

<!--ALSO: Make scripts combine-able (if they're not already?)-->

<start type="script">
CombineScripts (game.original_start, game.start_status)
</start>
</type>

<!--This reminds me -- also make the 'defaultgame' type inherit something like 'editor_game'-->

<type name="editor_game">
<status type="boolean">false</status>
</type>

<tab>
<parent>_GameEditor</parent>
<caption>Library</caption>

<control>
<controltype>dropdowntypes</controltype>
<caption>Status</caption>
<types>*=Don't show status; gamestatus=Show status</types>
</control>

</tab>


...Of course, all of this is theoretical, BUT if it was possible, it would make life so much simpler for the person using the library, as well as the one coding it.

I don't think I forgot anything... If I did, sorry, I kind of had to come up with that whole pseudo-library off the top of my head.
Also, if there's already a way to do something similar to this, let me know because I looked everywhere on the wiki (and this forum) and couldn't find anything...

That's all for now, thanks for reading.

Alex
14 Mar 2013, 09:41
Good point. I've not really put much thought into how to handle this. I suppose we need some mechanism for a library to register a script to run in response to some event - then when the event is triggered, all those registered scripts will run.

I have added this to the Issue Tracker for v5.5: http://quest.codeplex.com/workitem/1256

Sora574
14 Mar 2013, 20:57
Sounds great. Do you have an ETA for when 5.5 might roll out?