Skip to content

Commit

Permalink
Merge pull request #81 from DRincs-Productions/79-move-into-renpy-che…
Browse files Browse the repository at this point in the history
…ckifisactivebytag

79 move into renpy checkifisactivebytag
  • Loading branch information
BlackRam-oss committed Sep 21, 2023
2 parents f76df32 + 9b302b9 commit 74a232c
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 102 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# LTS Version

## Install

You can install this library manually: download the zip and extract it in your project folder.
But I recommend you to use git submodule:

```bash
# renpy-utility-lib
git submodule add -b python-lib -- https://github.com/DRincs-Productions/renpy-utility-lib 'pythonpackages/renpy_utility'
Expand All @@ -26,7 +28,7 @@ label after_load:
# ...
# renpy-utility-lib
$ update_flags()
call update_current_flags(update_dictionary = True)
# nqtr
python:
Expand All @@ -40,8 +42,8 @@ label after_load:
# recheck the character's events and commitments in current location
from pythonpackages.nqtr.routine import characters_events_in_current_location
from pythonpackages.nqtr.routine import characters_commitment_in_current_location
cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm)
commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm)
cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm, flags)
commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm, flags)
# update the quest levels, if ypu add a new stage in the quest, you can use this function to start the new stage
update_quests_levels()
return
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ In order to simplify the update work and avoid errors in saving I created functi

Feel free to contribute, fork this and send a pull request. 😄

----

## TO DOWNLOAD THIS TEST PROJECT

```shell
# Basic command to download projects from git
git clone https://github.com/DRincs-Productions/NQTR-System
# IMPORTANT -> Will add the libraries needed to run the program
cd NQTR-System
git submodule update --init --recursive

```

----

## Documentation

**[Wiki](https://github.com/DRincs-Productions/NQTR-System/wiki)**
Expand Down Expand Up @@ -49,15 +64,14 @@ git submodule add -b interface-images -- https://github.com/DRincs-Productions/N

**AND** create a empty file `__init__.py` into `pythonpackages/` so `pythonpackages/__init__.py`.


add `after_load` into `core.rpy` for update values after game update:

```renpy
label after_load:
# ...
# renpy-utility-lib
$ update_flags()
call update_current_flags(update_dictionary = True)
# nqtr
python:
Expand All @@ -71,8 +85,8 @@ label after_load:
# recheck the character's events and commitments in current location
from pythonpackages.nqtr.routine import characters_events_in_current_location
from pythonpackages.nqtr.routine import characters_commitment_in_current_location
cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm)
commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm)
cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm, flags)
commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm, flags)
# update the quest levels, if ypu add a new stage in the quest, you can use this function to start the new stage
update_quests_levels()
return
Expand Down
6 changes: 3 additions & 3 deletions game/core.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define config.log = "log.txt"

label after_load:
# renpy-utility-lib
$ update_flags()
call update_current_flags(update_dictionary = True)

# nqtr
python:
Expand All @@ -16,8 +16,8 @@ label after_load:
# recheck the character's events and commitments in current location
from pythonpackages.nqtr.routine import characters_events_in_current_location
from pythonpackages.nqtr.routine import characters_commitment_in_current_location
cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm)
commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm)
cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm, flags)
commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm, flags)
# update the quest levels, if ypu add a new stage in the quest, you can use this function to start the new stage
update_quests_levels()
return
13 changes: 12 additions & 1 deletion game/flags_value.rpy
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# https://github.com/DRincs-Productions/renpy-utility-lib/wiki/Flags
# Wiki: https://github.com/DRincs-Productions/renpy-utility-lib/wiki/Flags
define flag_keys = [
# Block all spend_time
"not_can_spend_time",
"goout",
"weekend",
]

# Wiki: https://github.com/DRincs-Productions/renpy-utility-lib/wiki/Flags#update_current_flags
label update_current_flags_custom:
# Custom code
$ log_info("is_weekend: " + str(tm.is_weekend))
if tm.is_weekend:
$ set_flags("weekend", True)
else:
$ set_flags("weekend", False)
return
9 changes: 6 additions & 3 deletions game/nqtr_tool/time_label_fun.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ label wait(wait_hour=DEFAULT_WAIT_HOUR, is_check_event=True):
"[DEFAULT_BLOCK_SPENDTIME_DIALOGUE]"
return

# Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Time-system#after-spending-time
# is a label that is called always after spending time,
# or into special cases before checking the event, or routine...
# this label is used to update all the variables that are used in the time system
label after_spending_time(is_check_event=False, is_check_routines=True):
call update_current_flags
if(is_check_routines):
# this step is to change the background based on the presence of a ch
$ commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm)
$ commitments_in_cur_location = characters_commitment_in_current_location(cur_location.id, routine | df_routine, tm, flags)
# check event
if (is_check_event):
$ cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm)
$ cur_events_location = characters_events_in_current_location(cur_location.id, routine, tm, flags)
call check_event
call set_background_nqtr
return
13 changes: 7 additions & 6 deletions game/nqtr_values/routine_value.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ define df_routine = {
location_id="house", room_id="alice_room",
background ="bg alice roomsleep",
),
"alice_lounge" : Commitment(
hour_start=10, hour_stop=14,
location_id="house", room_id="lounge",
),
# alice_go_school have more priority than alice_read, because it is before in the dictionary
"alice_go_school" : Commitment(
ch_talkobj_dict={
"alice" : None,
},
hour_start=10, hour_stop=14,
location_id="school", tag="no_week",
location_id="school",
disabled="weekend",
),
"alice_read" : Commitment(
ch_talkobj_dict={
Expand All @@ -32,7 +33,7 @@ define df_routine = {
conversation_background ="bg alice terrace talk"
),
},
hour_start=14, hour_stop=20,
hour_start=10, hour_stop=20,
location_id="house", room_id="terrace",
background ="bg alice terrace",
),
Expand Down
2 changes: 1 addition & 1 deletion game/renpy_utility_tool
23 changes: 5 additions & 18 deletions pythonpackages/nqtr/button.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import Optional, Union
from pythonpackages.nqtr.disabled_solution import DisabledClass

from pythonpackages.renpy_utility.flags import *
from pythonpackages.renpy_utility.renpy_custom_log import *
from pythonpackages.renpy_utility.utility import *


class Button(object):
class Button(DisabledClass):
"""Wiki: https://github.com/DRincs-Productions/NQTR-toolkit/wiki/Button"""

def __init__(
Expand All @@ -22,6 +23,9 @@ def __init__(
hidden: Union[bool, str] = False,
default_label_name: Optional[str] = None,
):
# DisabledClass init
super().__init__(disabled=disabled)
# Button init
self.align = None

self.name = name
Expand All @@ -34,7 +38,6 @@ def __init__(
self.xalign = xalign
if not yalign == None:
self.yalign = yalign
self.disabled = disabled
self.hidden = hidden
self.default_label_name = default_label_name

Expand Down Expand Up @@ -194,15 +197,6 @@ def yalign(self, value: Optional[Union[int, float]]):
else:
self._align = (self._align[0], value)

@property
def disabled(self) -> Union[bool, str]:
"""Disabled"""
return self._disabled

@disabled.setter
def disabled(self, value: Union[bool, str]):
self._disabled = value

@property
def hidden(self) -> Union[bool, str]:
"""Hidden"""
Expand Down Expand Up @@ -231,13 +225,6 @@ def is_picture_in_background(self) -> bool:
"""This is a is picture in background?"""
return not isNullOrEmpty(self._picture_in_background)

def is_disabled(self, flags: dict[str, bool] = {}) -> bool:
""" "If disabled is a string: get the value of the flags system"""
if isinstance(self.disabled, str):
return get_flags(self.disabled, flags)
else:
return self.disabled

def is_hidden(
self, flags: dict[str, bool] = {}, check_if_has_icon: bool = True
) -> bool:
Expand Down
29 changes: 29 additions & 0 deletions pythonpackages/nqtr/disabled_solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Union

from pythonpackages.renpy_utility.flags import *
from pythonpackages.renpy_utility.renpy_custom_log import *
from pythonpackages.renpy_utility.utility import *


class DisabledClass(object):
def __init__(
self,
disabled: Union[bool, str] = False,
):
self.disabled = disabled

@property
def disabled(self) -> Union[bool, str]:
"""Disabled"""
return self._disabled

@disabled.setter
def disabled(self, value: Union[bool, str]):
self._disabled = value

def is_disabled(self, flags: dict[str, bool] = {}) -> bool:
""" "If disabled is a string: get the value of the flags system"""
if isinstance(self.disabled, str):
return get_flags(self.disabled, flags)
else:
return self.disabled
12 changes: 0 additions & 12 deletions pythonpackages/nqtr/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ def __init__(
icon: Optional[str] = None,
info_image: Optional[str] = None,
stage_ids: list[str] = [],
tag: Optional[str] = None,
development: bool = False,
):
self.id = id
Expand All @@ -405,7 +404,6 @@ def __init__(
self.icon = icon
self.info_image = info_image
self.stage_ids = self.stage_ids = stage_ids
self.tag = tag
self.development = development

@property
Expand Down Expand Up @@ -472,16 +470,6 @@ def stage_ids(self) -> list[str]:
def stage_ids(self, value: list[str]):
self._stage_ids = value

@property
def tag(self) -> Optional[str]:
"""Quest tag
#TODO: implement this"""
return self._tag

@tag.setter
def tag(self, value: Optional[str]):
self._tag = value

@property
def development(self) -> bool:
"""Quest development"""
Expand Down
Loading

0 comments on commit 74a232c

Please sign in to comment.