CoriBoom Lua Coding to Trigger Multiple Game Effects (Such as Disasters)
Please Note:
Cori's discovery detailed in this topic was originally posted in the Oddities thread, but is split to here for clarity of discussion.
Message added by Cyclone Boom
52 posts in this topic Last Reply
Highlighted Posts
(Kind of sucks for an acronym tho.) First off, here's the file:
Cori Calls the Create Effect Function - v0.01.dat Second, this is released as public code and you are free to edit it and share it. The main rule is that any code you share is also released in the same free manner to be modified by anyone else. (Ofc, do name your file something different than mine.) Things to be aware of when using the mod: The city must be established so it's in Mayor Mode or the Advisor popup won't popup. (That's where the linkys to click are located.)
Many of the effects need game time to be running. I recommend centering your tile where you want, start time at Turtle speed, and save.
The popup can take a game month or two before it appears depending on the amount of plugins you have as well as how complex you've made the effect iterations in the Lua code. (If you run Rhino or Cheetah it can take several more months.)
Once an effect group is triggered by clicking a linky, that, too, can take a long while to appear. This part is based on the complexity and number of effects.
When we get to the modifying the code part, keep in mind that there is a limit of 32,767 characters total (including comments). It's currently around 16k so there's wiggle room, but once we start expanding the menu and having multiple other options we could run out of room in this one Lua entry. No worries tho. We can make as many separate 32k Lua entries as we need. Functions do not need to all be in the same code section to work. I've added a bunch of comments in the code. Reading all them might give you a general idea of the important parts of the code.
Y'all have already seen some of the other effects in pics posted previously so these will focus on the Forest Fire Meadow Creation since it has the most actual potential useful use in the game.
Here's what it will look like when the message box appears: I've made the function place secondary effects of smoke clouds so we can see where the little fires will be: And then after waiting until all the fires burn themselves out: Btw, if you zoom in close before they all burn out, you can see them aflame: Once they are all done, you'll be left with tree trunk stubble: ^ Unlike stubble from regular game fires, these don't fade away after time. (But, they can be bulldozed or removed with my Flora Eraser Brush.) For those of you who will be tweaking the code, here's a CB Tip™. You can access the same linkys in the News Box so you can click them again if you want. Like so: ^ Btw, the first two are named generically since the idea is for changing the code multiple times and testing. For the Code Tweakers Open the .dat file in Reader 0.9.3. Click the LUA file entry and then click the Edit button: For your very first code edit scroll down to this part: ^ Any text following -- is a comment and the interpreter does not process them. I use --w to tell myself that code worked. The --x is my note that it didn't work. And --wx means it worked, but wasn't useful. For some of the --x ones, I may not have yet realized time needs to be running so re-testing those might be something y'all want to try. So, all we'll do to start is remove the --w from one line and add it to another: After the edit, click the Apply button. (Forgetting this is the number one cause of frustration when editing Lua code.) Then Save the file: The change we made can be triggered in the game using the second linky in the popup box. Go try that now. (I'll wait.) . . . . . . Ah, you're back. Pretty cool? Yes? You can also get a list of all the effects that might be worth testing from the EffectDir, Section 13 in SimCity_1.dat. I'll attach that as a text file in case you want it the easy way: EffectDir Section 13 Effect Names List.txt So now the part that most of you will be interested in tweaking. Here's where the Meadows Fire function starts with the important parts numbered: ^ The annotated parts are for: The actual name of the effects. How many separate meadows to create. This is the outer do loop. Changing the 42 and 87 is how you can set the lower and upper boundaries for the random number of times the loop will execute. Here is where the random size of a meadow is determined. Changing the 16 and 96 would be where to test. This is the inner do loop. The More_Cleared determines if additional fires are set close to each initial fire. The Nearby_Distance is how far in meters from said initial fire. Another CB Tip™ is to copy the code from Reader to Notepad++ for editing so you can have even better syntax highlighting and editing tools. Ofc, you then need to copy and paste it back into Reader, Apply, and Save. (For simple things I just edit in Reader, but don't tell CB that.) As always, special thanks to @Cyclone Boom. He's helped test from my very first version where all it did was trigger a single fireworks up thru all the code you'll see in the .dat file. The in game pics were created by CB and he tweaked mine from Reader for better clarity. So, tweak, apply, save, and test in the game. Feel free to post code changes you make and show pics of what you come up with.
In this post Cori precisely explains the technical details in the Lua code for her Effect triggering method. Many possibilities here to explore, so we invite you to give it a try! ;-)
Recommended by Cyclone Boom
-
Similar Content
-
Recently Browsing 0 members
No registered users viewing this page.


