Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Chains
Newbie


Joined: 17 Oct 2022
Posts: 4

PostPosted: Mon Oct 17, 2022 4:58 pm   

Creating a counting loop
 
So currently I'm using a really simple trigger setup between 2 skills with multiple lines of text when it reads the end of one line of text, it starts the other. I'd like to set it up to include more skills and to count up on each skill so that i can do multiple of the same then back to the original. I saw a suggestion to use an array to count integers and execute commands based on the integer but I've never really messed with much coding. Does anyone have an example of something similar I can modify or mess around with? I can figure it out just having trouble getting it started
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Mon Oct 17, 2022 5:32 pm   
 
That explanation seems a bit vague.
I am sure it could be done, but iI would need more information about the intended result.
As well as some example MUD output to better understand the issue.
_________________
Discord: Shalimarwildcat
Reply with quote
Chains
Newbie


Joined: 17 Oct 2022
Posts: 4

PostPosted: Mon Oct 17, 2022 6:00 pm   
 
Sure, I was hesitant to make it too wordy. The idea is I have a loop of buffs on repeat:
I use sing song of the spider which generates

You sing: The speed at which a spider fights,
You sing: Makes fighting one a task of fright;
You sing: Faster yet than normal man,
You sing: Fight the devil if you can.

sing song of the soul
You sing: The power of mind,
You sing: The movement of soul;
You sing: The speed that is needed,
You sing: To defeat your foe.

sing song of the body
You sing: The strength of a body,
You sing: The power within;
You sing: Heal the world,
You sing: And those without sin.

Right now I just have triggers off the last line of each song to do the next one rotating between the the three. The spider song lasts 120 seconds and the others can be used at any time, but you can't use another till the song is finished singing. I'd like to be able to start with spider, which gives me enough time to sing 10 more songs before I need to refresh the spider buff. The post mentioned using triggers for each song to increase an integer count so that you could use 'if' statements to check the count and sing different songs at each count up to the tenth(Including 0?) and then reset it back to 0 to start the loop over or do something else. The example he gave was "So when your integer variable is 0, sing spider. I mostly sing soul, but I like to have a body song in there for some stuff, so when my integer variable is 1 or 7, I sing body. When my integer variable is 2-6 or 8-10, I sing soul." It doesnt have to be exactly that but looking for a basic version I can tinker with and get a better feel for so I can make my own things moving forward. I have little experience with coding but can reverse engineer it and modify once I can get it going
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Mon Oct 17, 2022 8:16 pm   
 
If it is all based on the integer count, this will be easy.

Code:
#EVENT onNextSong {
  #SWITCH (@songCounter)
    (0) {sing song of the spider}
    (1) {sing body}
    (2) {sing soul}
  //And so on
  }

#TRIGGER {{song one ends|song two ends|song 3 end|etc}} {
  songCounter=(@songcounter+1)
  #IF (@songcounter>10) {songCounter=0}
  #RAISE onNextSong
  }
_________________
Discord: Shalimarwildcat
Reply with quote
Chains
Newbie


Joined: 17 Oct 2022
Posts: 4

PostPosted: Tue Oct 18, 2022 1:37 am   
 
Hey thanks for the quick replies just got home from work. The script makes sense to me.. Though maybe I've jumped ahead too far do i put this in as a custom trigger? Or maybe I'm missing something I've tried a few variations https://i.imgur.com/6PU322I.png
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Tue Oct 18, 2022 1:42 am   
 
The code i provided can be entered on the command line.
_________________
Discord: Shalimarwildcat
Reply with quote
Chains
Newbie


Joined: 17 Oct 2022
Posts: 4

PostPosted: Tue Oct 18, 2022 2:19 am   
 
nevermind I got a similar version working
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net