Coding guide
Kevin_Smarts edited this page 4 months ago

QSP is a fairly simple language and quite easy to pick up the basics, the best way is to have a look through the game code. If you are not familiar with it the following will get you set up:

  • You will need the program QGen (http://qsp.su/attachments/qgen400b1.zip), this allows you to open the qsp file and view / edit the game locations
  • From here it is quite simple to copy / paste the locations to a .txt file in notepad++ allowing editing with more advanced editing tools (This is the prefered process)
  • Once you have edited a location and have a .txt file that you would like added to the game, you can post it to Mega (or similar) and post a link in the forum, or PM it to one of the devs and it will be posted to the development version for use in the next release. If you are familiar with Git repositories, you can commit it to the repo here (master branch)

Some coding guidelines:

  • In QSP text will always be separated from code by apostrophes (') and well appear green in QGen.
  • Actions are prefixed by the command act and separated from code by apostrophes (').
  • You can send the player to different locations with gt (goto) followed by the file name (as a string separated by apostrophes) and follow it by upto 9 arguments, the first of which is often used to direct the player to a specific code chunk.
  • You can also use gs (gosub) and dynamic to load additional locations to join the existing location, they will also return to the main location unless an action is used within them. Dynamics must be initialized before they can be call and stay in memory (inc. savegame data) unless cleared. The killvar command is used for this, but be careful with it, it can clear whole arrays in a blick of an eye.
  • When you use apostrophes in text, double them and they will show correctly.
  • After the "if" clause or "act" + text, put a colon then what happens. It's the equivalent of THEN in BBC Basic, ie.

    if a > b and a > c : 'Player A wins!'

    act 'Go to results': gt 'results'

  • Use the word "and" inside the "if" clause and an ampersand between instructions.

  • You only need the "end" if you split it across multiple lines, if command through to instruction all on the same line qsp will assume an end, so you have to spilt when using if - elseif - else even if you drop the elseif or else.

Window cleaning

  • cls = *clr & cla & clr & cmdclear - clear screen and actions and additional_desc and input_line
  • cla - clear action window. ('Actions')
  • clr,clear - clear stat window. ('Additional desc')
  • *clr, *clear - clear main window. ( none )
  • gt, goto clear both main and action window
  • xgt, xgoto clear only action window
  • gs doesn't clear any window

Some Conventions

  • Variables: bankAccount
  • Location Names: blackjackPlay
  • Comments: !!
    • This makes it easier for syntax highlighting

Variable

  1. type:
  2. there are 2 type of variables in QSP system, differ with $

var = value
$var = string

  1. Display
    - If you want display variable, use <<$var>> in texts. The game engine will automatic show $var there.

Common used function

act = action used to give options to player in action window. gt = goto used to send the player to locations. gs = gosub, like goto, but brings you back to same spot if there is no action. if, elseif, else will make bool check and exec corresponding scripts.

if a if or act is more then one line, you need to add a end after the last line



example: These 2 if will do the same. If your are new to coding, I would suggest you to use the 2nd one, and use "tab" or "space" to layout if and exec.

if rand(0,10) > 5 : msg 'rand bigger than 5'  & act 'OK' : gt 'test'
if rand(0,10) > 5 :   
	msg 'rand bigger than 5'  
	act 'OK':
		gt 'test'
	end
end  

Another example for if, elseif, else and display variable

var_rand = rand(0,10)  
if var_rand > 5 :   
	msg '<<var_rand>> may be 10, 9, 8, 7, 6'  
elseif var_rand >= 3 :   
	msg '<<var_rand>> may be 5, 4, 3'  
else  
	msg '<<var_rand>> may be 2, 1, 0'  
end  

Underwear actions

gs 'underwear', 'dispose'

To remove and destroy

gs 'underwear', 'remove'

To remove but keep available

gs 'underwear', 'wear'

To put on anything removed in the remove action

With the bars or panties used you can specify the item using the itemname and number ie.

gs 'panties', 'wear', 'cheap', 14

You can do the same things for just panties or bras by changing the 'underwear' to 'panties' or 'bras'.

Return to the Home page.

Npc quest variables

Main npc quests should use the Axx numbering in a npc_QW format ie:

For more complex npcs where you need other tracked elements then the best practice would be to collect those variables into an array.

artemQW['Num Dates']=2 artemQW['Gave Blowjob']=1 artemQW['Cash Given']=650``` You can use that just like a variable, but... 1) All stay contained together 2) We are less likely to run out of variables 3) You can make the tracked properties more intuitively named, so it is easier for someone else to understand what is happening if they need to fix something later. Obviously not every npc has a unique name so you may need to check and use variant spelling to avoid a clash.

Return location variables

These are in pairs of location and ARG0 within a location They are used by code that can be called from multiple locations to return to where the player started from

Main Location handling

$loc $loc_arg

used in

  • Various to navigate within a set of related locations

Menu handling

$menu_loc $menu_arg

Used in

  • journal to return
  • nichUtil to return from debug
  • obj_din to exit the menu
  • phone_selfies to return from viewing selfies
  • stat_display to check if $menu_loc it is set to allow a link to be displayed to the menu

Mirror

$locM $locM_arg

Used in

  • Various any location that has a mirror to return after using the mirror

$curloc

  • QSP system variable that contains the name of the current location
  • It tends to get used to set the location variables above e.g. $loc = $curloc
  • WARNING this is not set when you load a save, so don't use it unless you know what you are doing

$locclass

  • livingr, bedr, kitr, restroom, city_park, singleroom, beach, school_bathroom, lockeroom, changingroom, classroom
  • Call killvar '$locclass' to clear it otherwise you get to take restroom selfies walking down the street after visiting the restroom

Used in

  • subkid to display contextual descriptions for player's child's location
  • telefon for chosing what selfies folder to use for selfie background / clothes style

$location_type

  • private, indoors, public_indoors, bathroom, event, secluded, public_outdoors, event_outdoors

Used in

  • lact_bp to decide whether to express milk etc
  • outdoors if value is public_outdoors, secluded or event_outdoors sets effect of rain on player
  • telefon to check if you can do a bathroom selfie if $locclass isn't set

Colours for text

See this wiki page for colours that can be used, the extended list names all appear to work: https://en.wikipedia.org/wiki/Web_colors

Use inside the appostrophes in this format: <font color = maroon>