News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

Creating useful Lua Scripts

Started by Plexa, 08, August, 2015, 02:21:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Daddy Poi's Oily Gorillas

#20
Awesome! It's looking even better now... I do see room for more optimization... maybe... Like have the effectproc data collected before the loop, and process the value along with the random number within the loop...
(However, it might not matter(?), because a max of 500 (100x5) loops isn't much. Then again, this is for each frame (GBA should be just short of 60 frames/sec.), so I don't know...)
If you do decide to go this route, I can see the unleash function having a second arg for chance, and that one being called twice per while loop. One to process unleash, and the other to process with the chance value retrieved from effectproc.
I recommend also having a small infinite loop (while true do) that the vba.frameadvance() would be in... and in that loop, to also have draw commands... and specific checks for when data should be collected (i.e. Have a counter every time it reaches... say 2-60, or when the RNG changes (As a second cond. since you will have it on display), set counter to 0 and collect. Although numbers like the RNG should probably be collected every frame.)... That way, we could have a small amount of operations per frame.
Would also have been nice if LUA supported pre/post-increment (Like C++/C#/Java....), though, unfortunately it doesn't seem to. Oh well.

I do have two bug-related questions, though.

1. Is this part fully correct?
Quoteif el4 ~= 0 then
        ela = (el1+el2+el3+el4)/4
elseif el3 ~=0 then
        ela = (el1+el2+el3)/3
elseif el2 ~=0 then
        ela = (el1+el2)/2
else
        ela = el1
end
*Looks back at my documentation to see I put in "0811A188 = List living PCs (Arg=1), or enemies (Arg=2) ; I think?" (Function that is called from the Flee Check function.)
*Also looks at the function's assembly real quick to see that it retrieves the HP values to see if they're alive or not.

So... If you KO some enemies, this might turn out incorrect, since those should be removed from the list, I believe.  Same for the Party side as well.


2. Possible mismatch with Elm == U check?
0 = Venus, 1 = Mercury, 2= Mars, 3 = Jupiter,
0 = Isaac, 1 = Garet, 2 = Ivan, 3 = Mia
Quoteif Elm == U then
                elmaff = 5
        else
                elmaff = 0
        end
Try something more like...
if memory.readbyte(0x080844EC + (U * 0xB4) + 0x92 + Elm) == 54 then elmaff = 5
(Or you could divide by 10 with flooring. -- That way it could also be compatible with hacks... as long as the table wasn't moved.)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Plexa

#21
Regarding average level; you're correct that if you kill something that things it might return incorrect results. On the other hand for our purposes we just don't flat out fight anything non-essential so that's never an issue.

I'll replace the elmaff code with yours, you're correct that it doesn't work :P

Placing the functions outside of the while true do loop makes the script stop working :(