q217core.asl ‐ Core library for Quest 2.19 - KVonGit/quest5-stuff GitHub Wiki

!library
!asl-version <217>

' q217core library
' for Quest 2.19
' v0.1 alpha
' 2025 KV

!addto game
	command <drop #object#> do <vdropproc>
	command <look at #object#> do <vlookatproc>
	command <look #object#> do <vlookatproc>
	command <l #object#> do <vlookatproc>
	command <examine #object#> do <vlookatproc>
	command <x #object#> do <vlookatproc>
	command <take #object#> do <vtakeproc>
	command <get #object#> do <vtakeproc>
	command <speak to #object#> do <vspeakproc>
	command <talk to #object#> do <vspeakproc>
	command <inventory> do <vinventoryproc>
	command <inv> do <vinventoryproc>
	command <i> do <vinventoryproc>
	command <items> do <vinventoryproc>
	command <give #object1# to #object2#> do <v-giveto-proc>
	command <use #object1# on #object2#> do <v-useon-proc>
	command <use #object1# with #object2#> do <v-useon-proc>
	command <use #object#> do <v-use-proc>
	command <go> msg <Which direction?>
	command <score> msg <This story has no scoring functionality.>
	command <yes> msg <You sound very positive!>
	command <no> msg <You sound rather negative.>
!end

!addto synonyms
	drop the = drop
	look at the = look at
	look the = look
	l the = l
	examine the = examine
	x the = x
	take the = take
	get the = get
	speak to the = speak to
	talk to the = talk to
	to the = to
	on the = on
	in the = in
	into the = into
	under the = under
	with the = with
	from the = from
	give the = give
	use the = use
	walk = go
	run = go
	go s = go south
	go n = go north
	go e = go east
	go w = go west
	go nw = go northwest
	go ne = go northeast
	go sw = go southwest
	go se = go southeast
	go in = in
	go out = out
	info; version = about
	hints; hint; commands; instructions = help
!end

define room <held>
end define

define procedure <vdropproc>
	if not real <#object#> then {
		msg <I don't understand '#object#' in that context.>
	}
	else {
		if got <#object#> then {
      ' TODO - Can I use an object flag here to see if it can be dropped?
      '          Or an ACTION? I need to learn how that works!!!
			lose <#object#>
			moveobject <#object#;#quest.currentroom#>
			msg <Dropped.>
		}
		else {
			msg <You aren't holding any #object#.>
		}
	}
end define

define procedure <vlookatproc>
  if not real <#object#> then {
  	msg <I don't understand '#object#' in that context.>
  }
  else {
	if got <#object#> then {
    setstring <objloc;$locationof(#object#)$>
    moveobject <#object#;#quest.currentroom#>
    showobject <#object#>
    exec <look at #object#;normal>
    moveobject <#object#;#objloc#>
    hideobject <#object#>
    }	
    else {
      if here <#object#> then {
        exec <look at #object#;normal>
      }
      else {
        msg <vlookatproc ERROR: Something went wrong.>
      }
    }
  }
end define

define procedure <vtakeproc>
	if real <#object#> then {
		if here <#object#> then {
			setstring <charshere;#quest.characters#>
			setstring <lcharshere;$lcase(#charshere#)$>
			setstring <obj;$lcase(#object#)$>
			setvar <found;$instr(#lcharshere#;#obj#)$>
			if is <%found%;0> then {
				exec <take #object#;normal>
			}
			else {
				msg <$capfirst(#object#)$ probably wouldn't appreciate that.>
			}
		}
		else {
			if got <#object#> then {
				msg <You already have that!>
			}
			else {
				msg <You can't see any #object# here.>
			}
		}
	}
	else {
		msg <I don't understand '#object#' in that context.>
	}
end define

define procedure <vspeakproc>
	if real <#object#> then {
		if here <#object#> then {
			setstring <charshere;#quest.characters#>
			setstring <lcharshere;$lcase(#charshere#)$>
			setstring <obj;$lcase(#object#)$>
			setvar <found;$instr(#lcharshere#;#obj#)$>
			if is <%found%;0> then {
				msg <Talking to inanimate objects is not permitted.>
			}
			else {
				exec <speak to #object#;normal>
			}
		}
		else {
			if got <#object#> then {
				msg <Talking to inanimate objects is not permitted.>
			}
			else {
				msg <You can't see any #object# here.>
			}
		}
	}
	else {
		msg <I don't understand '#object#' in that context.>
	}
end define

define procedure <vinventoryproc>
	outputoff
	setstring <here;#quest.currentroom#>
	goto <held>
	setstring <inv;#quest.formatobjects#>
	goto <#here#>
	outputon
	if is <#inv#;> then {
		setstring <inv;nothing>
	}
	msg <You are carrying #inv#.>
end define

define procedure <v-giveto-proc>
	if not real <#object2#> then {
		msg <I don't understand '#object2#' in that context.>
	}
	else {
		if not real <#object1#> then {
			msg <I don't understand '#object1#' in that context.>
		}
		else {
			if not here <#object2#> then {
				msg <You can't see any #object2# here.>
			}
			else {
				setstring <charshere;#quest.characters#>
				setstring <lcharshere;$lcase(#charshere#)$>
				if not got <#object1#> then {
					setstring <obj1;$lcase(#object1#)$>
					setvar <found;$instr(#lcharshere#;#obj1#)$>
					if is <%found%;0> then {
						msg <You don't have any #object1#.>
					}
					else {
						msg <$capfirst(#object1#)$ probably wouldn't like that very much.>
					}
				}
				else {
					setstring <obj2;$lcase(#object2#)$>
					setvar <found;$instr(#lcharshere#;#obj2#)$>
					if is <%found%;0> then {
						msg <Giving things to inanimate objects is forbidden.>
					}
					else {
						exec <give #object1# to #object2#;normal>
					}
				}
			}
		}
	}
end define

define procedure <v-use-proc>
	if not real <#object#> then {
	
	}
	else {
		if not got <#object#> then {
			if not here <#object#> then {
				msg <You can't see any #object# here.>
			}
			else {
				setstring <charshere;#quest.characters#>
				setstring <lcharshere;$lcase(#charshere#)$>
				setstring <obj;$lcase(#object#)$>
				setvar <found;$instr(#lcharshere#;#obj#)$>
				if is <%found%;0> then {
					msg <You don't have any #object#.>
				}
				else {
					msg <$capfirst(#object#)$ probably wouldn't appreciate that very much.>
				}
			}
		}
		else {
			exec <use #object#;normal>
		}
	}
end define

define procedure <v-useon-proc>
	if not real <#object2#> then {
		msg <I don't understand '#object2#' in that context.>
	}
	else {
		if not real <#object1#> then {
			msg <I don't understand '#object1#' in that context.>
		}
		else {
			if not here <#object2#> then {
				msg <You can't see any #object2# here.>
			}
			else {
				setstring <charshere;#quest.characters#>
				setstring <lcharshere;$lcase(#charshere#)$>
				if not got <#object1#> then {
					setstring <obj1;$lcase(#object1#)$>
					setvar <found;$instr(#lcharshere#;#obj1#)$>
					if is <%found%;0> then {
						msg <You don't have any #object1#.>
					}
					else {
						msg <$capfirst(#object1#)$ probably wouldn't like that very much.>
					}
				}
				else {
					setstring <obj2;$lcase(#object2#)$>
					setvar <found;$instr(#lcharshere#;#obj2#)$>
					if is <%found%;0> then {
						msg <Giving things to inanimate objects is forbidden.>
					}
					else {
						exec <use #object1# on #object2#;normal>
					}
				}
			}
		}
	}
end define

TODO:

  • containers
  • devices
  • darkness
  • last object (it/him/her/them)
  • take/drop ALL
  • misc functions (i.e. ischaracter) to simplify things
⚠️ **GitHub.com Fallback** ⚠️