ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: wreckdumb on February 06, 2011, 10:11:12 PM
-
hello, my goal here is to create a simple Curseweapon(CW) Timing script for my first script. what i wanna do now with this script is make a little menu with a CW count down. also i want the script to "read" when CW is recast so the timer can reset itself. please help with this.
all constructionism welcome since i know there mistakes. just no making fun of my first script =P
SET %NegativeCW 120 ; change this value 20 for every 1s you want to hear the Sound before Curse weapon expires. 100=5s
SET %Hotkey q ; Change this to the key you wish to press to cast Curse weapon
;
;
; No need to edit below here
;
keyloop:
onhotkey %Hotkey
gosub curseweapon
sub curseweapon
event macro 15 104 ; Cast Curse weapon
chooseskill Spir
set %SS ( #skill * 10 ) / 34 + 1
set %finaltime ( %SS * 2 ) - %NegativeCW
gosub Sound
sub sound ; plays sound and message popup!
wait %finaltime
sound
wait 60
event ExMsg # 3 60 3...
wait 20
event ExMsg # 3 55 2...
wait 20
event ExMsg # 3 50 1...
wait 40
event ExMsg # 3 33 -=Curse Weapon Faded=-
return
if im doing anything wrong please tell me, so i can learn the right way the first time around!
-
All those waits are hurting you. If I remember correctly Curse Weapon is karma based too right? So you can't really use a strict timer to time Curse Weapon casting because your karma goes up and down. What I would do, is make an editable timer on a menu. One you can fine tune as the script is RUNNING. So it's a variable wait instead of a hard coded wait. Then if you happen to die, or take a murder count lets say, and your karma drops or raises, whatever the case may be, you can just edit the timer and poof, it casts on time again. Now for menus, I suggest you goto www.easyuo.com and download the old version of easyuo and the menu designer. Those are the easiest ways to create simple menus for new scripters. :)
-
Also, you can check out my old version of PVM Dexer on this site to see some examples of ways to script timers for sampires. There's a ton of good info in that script for you, you'll just have to dig through 3k+ lines to find it. :)
-
Your loop is incomplete, if you're using a keyloop: tag you need a Goto in there to loop back:
keyloop:
onhotkey %Hotkey
gosub curseweapon
GOTO KEYLOOP
Alternatively you could ditch the goto and do something like:
repeat
on hotkey %HotKey
gosub curseweapon
until The_Cows_Come_Home
Still the same number of lines however you'll take no flack from the GoTo-Haters club ;)
X
-
Still the same number of lines however you'll take no flack from the GoTo-Haters club ;)
X
It's ironic that some of the supporters of GoTo also support OEUO, which doesn't support GoTo.
-
Still the same number of lines however you'll take no flack from the GoTo-Haters club ;)
X
It's ironic that some of the supporters of GoTo also support OEUO, which doesn't support GoTo.
I'm not a member of that particular demographic myself although I'm a fan of using the tools you have at your disposal to get the job done in the most efficient way possible ;) Some toolboxes simply have different, and even better tools but the job will get done just the same...
X
-
Once you call a menu sub, you don't need to call it again. You'll have to experiment with it menus because it's too big of a topic to explain to you in a couple sentences. :)
-
I wrote a tutorial to show how to make changes within a menu without having to reload the entire menu.
Just stroll over to the tutorials forum and you should be able to find it in there.... if not just post back and I'll look it up for you.
-
It's ironic that some of the supporters of GoTo also support OEUO, which doesn't support GoTo.
Umm well my official bitches about Lua flow control have been lodged HERE (http://www.scriptuo.com/index.php?topic=5880.msg50643#msg50643) It's 1/2 thought through and makes for some wonky code when you want to short-circuit a loop your stuck in.
-
I wrote a tutorial to show how to make changes within a menu without having to reload the entire menu.
Just stroll over to the tutorials forum and you should be able to find it in there.... if not just post back and I'll look it up for you.
dang posted 1 minute too late lol, ill check out your guide! ty
-
Don't forget to include your RETURN's after every sub!! Do what I do, start every sub with:
Sub NameOfMySub
Return
THEN and ONLY THEN go back and fill out the space in between ;)
X
much appriciated guys!. ty for quick response! now one more quick question.
should i be creating a sub to "update countdown" before i loop back to KEYLOOP?
Not totally sure I get the goal but if your countdown is to tell you when it's time to cast Curse Weapon again then you would flow through the countdown BEFORE returning back to your loop, maybe something like:
Gosub Displaymenu
repeat
on hotkey %Hotkey
gosub CastCurseWeapon
gosub Countdown
until #FALSE
Sub CastCurseWeapon
Event Macro Whatever
Return
Sub Countdown
Do your countdown stuff
Update menu
Ring sound
Return
-
FYI - the use of:
Repeat
Until #FALSE
...is nothing more than a replacement for your "goto" loop. You don't want both.
The "Until #FALSE" is a criteria that will not be met thus the loop will run indefinitely. Goto's, when used correctly, are fine but they should never be used across subs. You should be able to get rid of your Keyloop: and goto Keyloop lines. Each Return will ALWAYS return back to the line following the line that called the sub. If you want to use your GOTO instead it would replace the Repeat Until #FALSE:
keyloop:
onhotkey %CW_HOTKEY
gosub curseweapon
gosub updatetimer
goto keyloop
...is the same as...
Repeat
onhotkey %CW_HOTKEY
gosub curseweapon
gosub updatetimer
Until #FALSE
X
-
okay i got this script working exactly how i want it to run
just wanna make it visually better before i give it out to public
what i wanna do is when %Curseweap > 5 seconds i want background font to be default black
and when %Curseweap <= 5 background to change to red.
i tried doing this, but i dont know how to specify which control font to change.
after that its pretty much done. so please help finish up my first script!
;=================================================================
; Script Name: Curse Weapon Timer!
; Author: Wreckdumb and the rest of the kick ass team at scriptuo lol.
; Version: 1.0
; Shard OSI / FS: OSI / FS OK
; Revision Date: 2/8/2011
; Purpose: SMALL Menu Countdown timer for Curse weapon, and maybe more later on =P
; Globals: None
;=================================================================
; Special Instructions:
;
;
;
;--------------SETUP--------------
SET %CW_HOTKEY 9 ; Hotkey you wish to use to cast curseweapon
SET %CWTUNE 2 ; Adds 1s per 1,
;------------END SETUP------------
gosub CWMenu1
;
;
;
;
;
repeat
onhotkey %CW_HOTKEY
gosub curseweapon
gosub updatetimer
SET %Curseweap %CW - #SCNT
until #FALSE
sub curseweapon
event macro 15 104 ; Cast Curse weapon
chooseskill Spir ;choose spirit speak
SET %SS ( #skill * 10 ) / 34 + 1
SET %CW #SCNT + %SS * 2 / 20 + %CWTUNE
gosub updatetimer
return
sub updatetimer
if %Curseweap = 5 ; change this value to how many seconds before curse weapon ends for it to play sound.
sound
if %Curseweap <= 0
menu set RECAST RECAST
else
menu set RECAST %Curseweap
return
;--------- EasyUO Menu Designer Code Begin ---------
sub CWMenu1
menu Clear
menu hideEUO
menu Window Title CW
menu Window Color Black
menu Window Size 113 14
menu Font Transparent #true
menu Font Align Right
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Style
menu Font Color White
menu Font Transparent #false
menu Font Align Left
menu Font BGColor Black
menu Text Curseweapon 0 0 Curseweapon
menu Font Align Right
menu Font BGColor Red
menu Text RECAST 112 0 RECAST
menu Show 421 270
return
;--------- EasyUO Menu Designer Code End ---------