mirror of
https://github.com/tbamud/tbamud.git
synced 2026-04-06 20:35:22 +02:00
Remove DG scripts in favor of Python scripting
This commit is contained in:
parent
5273201d1b
commit
a1976f92dd
80 changed files with 4332 additions and 2430 deletions
26
lib/scripts/sample_fountain.py
Normal file
26
lib/scripts/sample_fountain.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Fountain refill script example (attach to an object trigger)
|
||||
|
||||
def on_trigger(event):
|
||||
# Object entity the script is attached to.
|
||||
fountain = event["self"]
|
||||
# Minimum refill amount per tick.
|
||||
refill_amount = 1
|
||||
|
||||
while True:
|
||||
# Ensure the fountain has object values to read.
|
||||
if fountain and fountain.oval:
|
||||
# oval[0] is capacity, oval[1] is current contents.
|
||||
capacity = fountain.oval[0]
|
||||
contains = fountain.oval[1]
|
||||
if capacity > 0 and contains < capacity:
|
||||
# Calculate the new fill amount without exceeding capacity.
|
||||
new_amount = contains + refill_amount
|
||||
if new_amount > capacity:
|
||||
new_amount = capacity
|
||||
# Update the fountain contents via osetval.
|
||||
mud.do(f"osetval 1 {new_amount}", actor=fountain)
|
||||
# Echo a drip message to the room when refilling.
|
||||
if fountain.room:
|
||||
mud.echo_room(fountain.room, f"water drips from the ceiling into {fountain.name}")
|
||||
# Wait before attempting another refill.
|
||||
mud.sleep(300)
|
||||
Loading…
Add table
Add a link
Reference in a new issue