Page 1 of 1

Further player_colors discussion

Posted: Fri Jan 30, 2009 9:50 pm
by ian_scho
He he he - I love this:

Code: Select all

player_colors[1] =  {0, 0, 0}
player_colors[2] =  {255, 0, 255}
player_colors[3] =  {255, 1, 255}
dsb_update_system()
The first party memeber has 3 black bars, a black icon top right and has black message text at the bottom... Ooops it's a black background anyway so don't use it if you want to read the messages!
The second party member appears with pink bars and text but the champion image top-right is black... Yep, funky power pink acting against us here, thinking that we wanted a transparent image?
The third one is nice and pink too, and I'm using that one.

I think I need to do something funky after pulling a champion from a mirror, applying the colour change immediately afterwards. We can do this with your third parameter in dsb_offer_champion

Also you lose the 'state' when reloading the game, defaulting back to the standard 4 colours. The following in startup.lua doesnt have any effect:

Code: Select all

dsb_export("player_colors")
dsb_update_system()
Do I need a 'fire-after-loading', event?

I shall play some more.

Posted: Sat Jan 31, 2009 1:20 am
by Sophia
ian_scho wrote:Do I need a 'fire-after-loading', event?

I shall play some more.
It already exists. It's called sys_game_load. :D

Something like this should do what you want:

Code: Select all

function sys_game_load()
   player_colors[x] = blah
   -- and so on...

   dsb_update_system()
end
Your way was clever, but it didn't work because startup.lua is executed before exported variables are restored.

I'm actually not totally sure, but I think that because you need a slight delay it'd work if you did:

Code: Select all

dsb_export("player_colors")
dsb_delay_func(1, dsb_update_system)
Important: Be sure you leave off the () when you write dsb_update_system, as the code says there-- you're passing the function itself, not calling it and passing its output.

Posted: Sat Jan 31, 2009 1:15 pm
by ian_scho
Thanks ever so much, Sophia :)
In summary:-

In startup.lua I have:

Code: Select all

lua_manifest = {
    "system_ian.lua"
}
dsb_export("player_colors") 
In system_ian.lua (when overriding your base funcions, we need to track which ones carefully each time you update the base, system.lua) I have:

Code: Select all

function sys_game_load()
	dsb_delay_func(1, dsb_update_system)
	return nil
end
And somewhere, somehow I'll update the champions colours in the game, thus:

Code: Select all

player_colors[1] =  {255, 1, 255}
dsb_delay_func(1, dsb_update_system)

Posted: Sat Jan 31, 2009 8:27 pm
by Sophia
You don't need the delay if you're using sys_game_load... I think.

What you're trying to do is dynamically change the player_colors and have them preserved, right?

If that's the case, what you were trying to do with dsb_exporting "player_colors" was a good idea. The trick is that you just need a call to dsb_update_system in your sys_game_load so it'll make sure to use the values of "player_colors" it imports from the savegame.