To achieve this, when a new instance of my minigame starts (ShopkeepGame) I pass the AniseStats object to it. This makes AniseStats and shopkeepgame.player the same instance like I expect. However upon save/load AniseStats appears to be a new object and I have to reassign it during the main game loop to get it to update.
- Is there a better way to do this?
- If how I'm doing it is fine, how would I make things resync upon load?
Also, I apologise for the inconsistent code style, I'm used to camel & pascal case and the habit is hard to break.
script.rpy
Code: Select all
init:
$ global AniseStats
$ AniseStats = Anise()
Code: Select all
python early:
class Anise:
charm_level = 0
charm_experience = 0
upsell_level = 0
upsell_experience = 0
pressure_level = 0
pressure_experience = 0
bargain_level = 0
bargain_experience = 0
merchant_reputation = 0
maturity_reputation = 0
honesty_reputation = 0
Code: Select all
label shopkeep_init:
show shop
with dissolve
$ shopkeep = ShopkeepGame(AniseStats)
$ shopkeep.session_time = 40
...(snip)...
label shopkeep_loop:
$ shopkeep.level_up()
if (shopkeep.current_customer.patience <= 0):
call lost_customer
$ cu_mouth = "smile"
$ customer_is(shopkeep.current_customer.face)
cu "[shopkeep.current_customer.response]"
call customer_enter
$ AniseStats = shopkeep.player
if shopkeep.session_time > 0:
jump shopkeep_loop
else:
return
return
Code: Select all
vbox xalign 0.0 yalign 0.5 spacing 10:
text "{color=#000}time [shopkeep.session_time]{/color}"
text "{color=#000}rush! [shopkeep.rush]{/color}"
text "rush customers [shopkeep.rush_customers]"
text ""
text "charm [AniseStats.charm_level]"
text "{color=#000}charm [shopkeep.player.charm_level]([shopkeep.player.charm_experience]){/color}"
text "{color=#000}upsell [shopkeep.player.upsell_level]([shopkeep.player.upsell_experience]){/color}"
text "{color=#000}bargain [shopkeep.player.bargain_level]([shopkeep.player.bargain_experience]){/color}"
text "{color=#000}pressure [shopkeep.player.pressure_level]([shopkeep.player.pressure_experience]){/color}"