Can Somebody please Help me ? Scriptbrains needed :D

22 replies [Last post]
UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

hi again,,, i knew you want to puke reading the title,,,

yeah,,, i need help from somebody, that,,, well,,, Have Scriptbrains,,,

i want to slowly learn lua scripting,,, maybe want to provide me easy sources or information ???
i confuse to learn it by myself,,, i want to learn and want to quit learning if it so troublesome for years and i still can't do it,,, (the years is also a variable Smile,,,

for what you say ?

for yeah,,, creating a script (mission/multiplayer),,,
the name still been secret under FBI's overwatch,,, so ? don't ask it for now Big Grin let me know to do it first :DDD

ok then,,, you have know why i make this troublesome post right ?
then please comment below this, or JUST SAY ANYTHINGS There,,,

MyBrainAsk: allegedly wrote:

--- FIRST PART : "Basic Quantumic"

- How to Start it ??? "Going outside my house"
- Basic Knowledge ??? "I want to walk in the park"
- Examples ??? "Rabbit for our lab ???"
- First Step ??? "not to the moon though"

--- SECOND PART : "The Deployment"

- What i do now ??? "Sit there, wait someone do it"
- How can i do IT ??? "Basically,,, try"
- How to Check ??? "Advanced,,, read"

--- NEW WORLD OF SCRIPTS !!! : "The Life"

- Please Help by answering, comment, critic, or explain my question )
- I ASK YOU GUYS IN THE COMMENT PART,,, THANKS Big Grin
- Further things should be in the comment part ^^

--- Unknown Part,,, "Still in Outer Bound of my Tiny World"

thank you for helping or response to this post :DDDDD

( please warn me to stop XD )

|{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

Are you a noob Ultimaxuseless ???

ASK MR.GOOGLE !!!

THAT ! THAT IS THE SOLUTION !!!

( im not helping myself here :'( ,,,)

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

I didn't try LUA scripting yet, but if you want to learn it, you could look at how other scripts work and experiment with them.

There's also some documentation, with brief explanation on how it works and what can you do: http://hedgewars.org/kb/LuaAPI

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

You not scripting using LUA ???
that is very surprisingly turn the table from what i was thinking before Shocking
nvm,,, my mind never right Smile

KoBeWi allegedly wrote:

... ,but if you want to learn it, you could look at how other scripts work and experiment with them. ...

what that other scripts ??? :/

---

btw,,, thanks for the starting Big Grin

but there is no restriction to comment another starting point guys ^^

( have i say guys ??? )

|{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

Vatten
Vatten's picture
User offline. Last seen 48 weeks 5 days ago. Offline
Joined: 2009-09-02
Posts: 48

Writing scripts for hedgewars is easy (The hardest part is just to get something to work!).

Ill write how ull do it in a few steps:

1. Create the folders:
~/.hedgewars/Data/Scripts/Multiplayer (Linux)
~/Library/Application Support/Hedgewars/Data/Scripts/Multiplayer (OSX/Mac)
My Documents/Hedgewars/Data/Scripts/Multiplayer (Windows)
2. Create a file called myscript.lua (you can change the name later to something u like)
-> in windows, it *can* be hard to create a file with that extension, so its possible to create that file using "save as" in notepad or something.
3. In that file add:

function onNewTurn()
  AddCaption("I WILL GET YAH!")
  AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog)-1000, gtCluster, 0,0,0,30)
end

**For Windows users: Dont use MS Word, or Wordpad to add the content. Maybe it works, maybe ... I recommend notepad or notepad++.
4. Run the script by selecting *myscript in the game!!! Smile Smile

To achieve whatever u want, then just sneak into other scripts and see what they have done :P. More info about functions and such can be found here: http://hedgewars.org/kb/LuaAPI (as KoBeWi wrote).

For Linux users, do everything with:

mkdir -p ~/.hedgewars/Data/Scripts/Multiplayer && echo -e 'function onNewTurn()\nAddCaption("I WILL GET YAH!")\nAddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog)-1000, gtCluster, 0,0,0,30)\nend' > ~/.hedgewars/Data/Scripts/Multiplayer/myscript.lua

Added that just for fun Smile

Good luck!

Vattenania, my beloved motherland, my beloved homeland! You are always with me in my thoughts and in my heart!

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

Vatten allegedly wrote:
**For Windows users: Dont use MS Word, or Wordpad to add the content. Maybe it works, maybe ... I recommend notepad or notepad++.
I can recommend SciTe. It's very small, has all the functions you'd expect from code editor and it's cross-platform too. I'm using it since I started programming and every other editor either lacks something or is too heavy.

Lyberta
Lyberta's picture
User offline. Last seen 3 years 30 weeks ago. Offline
Joined: 2016-09-10
Posts: 177

here's a very good tutorial site: http://lua-users.org/wiki/TutorialDirectory

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381
Quote:

Vatten allegedly wrote:

Writing scripts for hedgewars is easy (The hardest part is just to get something to work!).

LOLZ,,, yes right Big Grin ever had it (WC3 TFT, SC2 WoL),,,,
can anyone suggest to try say : "Writing not Typing" Big Grin

Vatten allegedly wrote:

~/.hedgewars/Data/Scripts/Multiplayer (Linux)
~/Library/Application Support/Hedgewars/Data/Scripts/Multiplayer (OSX/Mac)
My Documents/Hedgewars/Data/Scripts/Multiplayer (Windows)

Im Window user though,,, Shoot !!! old seven,,,

[qoute=Vatten]
**For Windows users: Dont use MS Word, or Wordpad to add the content. Maybe it works, maybe ... I recommend notepad or notepad++.


I Use Notepad++,,, i almost use GIMP XD

KoBeWi allegedly wrote:

I can recommend SciTe. It's very small, has all the functions you'd expect from code editor and it's cross-platform too. I'm using it since I started programming and every other editor either lacks something or is too heavy.

ah,,, downloaded ! shoot !!! Notepad++ get ignored ;/ ,,, i will install it,,,

FaTony allegedly wrote:

here's a very good tutorial site: http://lua-users.org/wiki/TutorialDirectory

Woa !!! its big !!! long way to finish the read though XP

---

And VERY THANKS So much guys ^^
seriously,,, its Full Respect Thanks So Much with a valid @Nexus_rule_#2170023-2043th verified licence about #2170023 thanks rule ^^

i'll try to use all of them C;,,, chance to write/typing NEW HISTORY Of the Great UltiMaxKom (is "Great" meaning "Dumb" ???)!!! (another weirdness,,, lol)

and i move to part two,,,

|[

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

Remember when I suggested you to check other scripts?

I just managed to modify one of FaTony's scripts and create my "own weapon". You could try this too, if you get familiar enough with LUA. Experimenting is one of the best ways to learn.

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

KoBeWi allegedly wrote:

Remember when I suggested you to check other scripts?

I just managed to modify one of FaTony's scripts and create my "own weapon". You could try this too, if you get familiar enough with LUA. Experimenting is one of the best ways to learn.


Please Applause to this dude guys !!! Clown Crossed!
Thanks and nice to say ; "... Experimenting is one of the best ways to learn." and as i know,,, Experience is the best teacher in the world for all the time tho Big Grin

ok then,,, as you know,,,i working on A Project codename "The Dead" ,,, and its SCRIPTS (Include,,, and many complex aspect too),,,

}[

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

Hey guys Smile
I have question please ^^

Q : How to "Change The [Damage Percent] (like in schemes costumization : Damage Percent) ??? But guys,,, i mean, when after i set the initialization of [onInit] event,,, i want to change the Damage percent again Sad Smiley ,,, but i try it and can't,,, please help or explain what happen,,, maybe this can be my mistake ;/

Thank you for reading and even response this little question Big Grin

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

DamagePercent can only be set on initialization. However, there's one hack you could try. There's a method that can set multiple values of a gear, including damage. So the idea would be to change the damage of each gear that is created. It could look like this:

function onGearAdd(gear)
    local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce,
    ImpactSound, ImpactSounds, Tint, Damage, Boom = GetGearValues(gear);
    if Damage != nil then
        SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
        Damage * yourDamageFactor)
    end
end

nemo
nemo's picture
User offline. Last seen 23 hours 50 min ago. Offline
Joined: 2009-01-28
Posts: 1861

Damage tracks damage *to* a gear, not damage inflicted by it.

Unless you're trying to reduce damage to an object?

https://hg.hedgewars.org/hedgewars/file/f6d33710baff/hedgewars/uGearsList.pas#l220
"Boom" would be the one that lets a script mess w/ the damage dealt.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

I Quite still don't understand :S
About "Boom" ;/

i want to "Change Damage Output of Hog" ... or sounds like "When THIS HOG Take turn,,, the hog attacked by it get more damage, like Extra Damage" ... or mb yes, reduce too,,, and increase... Simply, change Damage Output/Input to Hog except in "onInit" event.

OK ! I Have ask sheepluva but she (?) tell me to ask nemo for this ( she say nemo smarter than her XD ,,, and i think that not true (Devs should be a horizontal title)) ...
She give some way but it still not clear...

Maybe this case should be closed ? it kinda "Dead End" to my question ? i think it still has alternatives though,,, i thinking it later Big Grin

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

Ok then,,, if that one was done,,, i got another :X
this :

Q allegedly wrote:

function Q_Asking_Something takes nothing return nothing

--[[

?_! . GOT BAD ENDING D; BUT FINISHED ;D

?_2 . [CAN AND HOW?] To "ADD or CHANGE" the "Music" that NOT from original Theme music in Normal or SD Music while ingame with scripts use specified event that can be reverted plus not replacing any files (/// If there no other way,,, this should be the altarnatives) ...

?_3 . [CAN AND HOW?] Stop or Play the ORIGINAL Theme music while ingame using scripts with specified event at any time ? (/// If there no other way (AGAIN) ,,, Then ANY OTHER THAN THE CONDITION FOR THE 100% MATCHING ANSWER REQUIREMENT IS IGNORED FOR THE ALTERNATIVES...) ...

?_4 . [CAN?] We stop exiting sound/music/ambient/SFX While ingame using scripts ?

?_5 . [CAN?] We Import or Export or Both with Lua ? i mean, like adding other pictures/animation that we can add with scripts as NEW FILE OR ADD-ONS or adding sounds for something or anything else WITHOUT REPLACING EXITING DATAs ??? maybe there a day, that i want to add a Nuclear Blast Animation in the game...

!_1 . [I THINK!] this quite, still limiting for new bigger creation for those want make something out the bound of this,,, but honestly, i not too make this serious because, maybe i not use it all when it available (?) ... but i have some little experience in "JASS", "JASS2", And "Galaxy" programming language which is REALLY POWERFUL,,, Quote from Wikipedia "The language provides an extensive API that gives programmers control over nearly every aspect of the game world." ... This sounds overconfidence, though who say it was me,,, and i really bad at these things...

O_1 . Yeah, this sounds troublesome, and REALLY NOT IMPORTANT TO BE TAKEN SERIOUSLY,,, I believe Developer CAN AND CAN Do it all with only some of Hedgewars player who support and even not support it (directly into here) that brings a little but powerful hope... why can't ? yup,,, i serious about this one...

/// NOTE : I really, REALLY BAD AT THOSE Coding things D; ... SO PLEASE BE REMEMBER I NOT, NOT, NOT SAY THIS WITHOUT CONCERN ABOUT THAT !!!

--]]

[eof]

Yeah,,, that quite a lot for me,,,

BUT REMEMBER !!!
I WILL REPEAT THIS MOVES WHEN I GOT NEW QUESTION OR FEEDBACK Big Grin !!!
I Mean,,, i use that quote with different content inside,,, so please be know and not annoyed at it,,,

im done asking some little question and feedbacks...

][

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

Ulti, after our little chat today, I went to see if there's some way to fix the damage popups when you "deal" the damage yourself.

And I found a small problem and a bug.
First, there's a visual gear called vgtSmallDamageTag, which is the one that pops on hedgehog damage. However, there's no such function as onVisualGearAdd, and normal onGearAdd doesn't seem to detect visual gears.
Second, when you try to create the vgtSmallDamageTag yourself, the game crashes. I dug into game's source to find the cause of this, and I found a procedure called AddDamageTag. It creates the tag and then creates and appends texture. Which means that when you add it manually, it doesn't have texture, thus the game crashes when trying to draw it.

To sum up, hijacking damage tags and changing their value (or removing and adding yours) would probably work for what you want to achieve, but it's impossible right now. I'll see if I can do something to allow this (no promises though).

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

I got what can be work in this problem Smile

After i talking to Sheepluva yesterday after we talking (this timezone things a bit confusing @_@)
I asking her for a Long-Midnight-Scripts-Story about this (too)

And the answer was an alternative,,, and that really familiar with yours.
Btw,,, i have same idea as you Big Grin . before we found nother path.

by using
vgtHealthTag

we create it with
AddVisualGear(x, y, visualGearType, state, critical)
(not addGear though)
[kb]

i have check in other scripts that use it,,,
like Sheepluva ask me
and most use it XD (like Mutant, Contimental, Battalion, etc)

then i realize that the state should be gst# (see Gear State) but in those scripts use it, the state was a sort of integers, i ask sheepluva and she say that 0 is nil value for the state, yeah,,, i later try something, and i realize again that the state for vgtHealthTag (each/some vgt# has its own specific things) is the number will be shown,,, so it is number though...

then i try to use it,,, the result is good,,, like this how i use (maybe a bit different ;/) :
e.g if i want to show 172 damage to Hoggy H :
AddVisualGear(GetX(Hoggy H), GetY(Hoggy H), vgtHealthTag, 172, true)

then this case have melted,,,

function onGearDamage(gear, damage)
if GetHealth(gear) - damage > 0 then
local BonusDamage = 0
BonusDamage = (damage) * 0.2
SetHealth(gear, GetHealth(gear) - BonusDamage)
AddVisualGear(GetX(gear), GetY(gear), vgtHealthTag, BonusDamage, true)
end
end

BUT HEY !!! Idk how to write function like you guys D;

ok then,,, thanks everybody Big Grin ... and sorry for asking silly question ;/ (if it is)

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

Your solution with vgtHealthTag is viable, HOWEVER it still can be improved. It's still confusing when you see multiple numbers on hedgehog damage and only one is actually real.

I checked if I can do something about it, and I managed to add some functions to allow for deleting/changing visual gear on creation. And it's totally possible to remove all unnecessary number popups and leave only the ones you created. If everything goes well, this option will be available for you in Hedgewars 0.9.23

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

Ok Big Grin,,,
Btw, i make the Damage Popups with different place and different colour
though, i is very epic for Popups Type

There are 4 Different Damage type with its own effect and colour and place,,,
maybe it still good for now Big Grin...

GL With v0.9.23 Contributions ^^

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

Guys !!!

Got another Question !!!

?_6 : [CAN AND HOW?] Stop an exiting specific played sound ? or theme music can be stopped ? or can i pause SFX ? Any ???

?_7 : [CAN AND HOW?] To add score after a match to scoreboard within local or even global (in record here) that the player itself can check its own score ??? and can this be automated for writing the new score ??? or at least,,, how to save the score after a match ??? or ANY alternatives...

?_8 : How to Spawn hog that will perfectly above the landmass but not too high and not be spawned inside the terrain itself ??? or how to spawn crates lke that ??? these is random place that NOT Inside the terrain and one more +NOT ABOVE OR BELOW WATER,,, so the gear land PERFECTLY ??? or any Solution or alternatives ???

Can someone bring me the answer please ??? thank you for paying attention ^^

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

UltiMaxKom allegedly wrote:

?_7 : [CAN AND HOW?] To add score after a match to scoreboard within local or even global (in record here) that the player itself can check its own score ??? and can this be automated for writing the new score ??? or at least,,, how to save the score after a match ??? or ANY alternatives...

Use ShowMission to show the in-game scoreboard (which then can be displayed by pressing ESC). It can't be really automated though, you need to update the scoreboard each time you want it to change.

SendStat function is used for stats after match.

(check their API for description)

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

Ah Big Grin ...

Right,,, hmmm,,,

But OMG Shocking !!!
I Write like some donkey searching their tail,,,

REALLY XD

I Wrote WRONG Question (i mean,,, wrong word to show expression of my true question)

I rewind <<

?_7 : To Add Score LIKE "Trophy Races" THAT SEND THE RESULT TO "Records" in "Hedgewars.org" [http://www.hedgewars.org/records] ??? and automatically do that,,, or if it can't, then at least we can RECORD IT On locally of player's computer,,, mean to be "Scoreboard" and "Rankings" through all modes Player,,, ["Hope this one right D:"] ,,, AND ! This USE LUA SCRIPTS METHOD ... Not Manually... ty

But KoBeWi 100% RIGHT AND I THE WRONG,,, No Off really srly,,,

If can,,, please re-answer it,,, sorry, my bad :C

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 4 years 10 weeks ago. Offline
Joined: 2016-06-26
Posts: 381

One Another Little Question :

?_8 : [HOW?] To know "is the game is end" , i mean, check the game is ended than sendstat for ONCE to EACH TEAM at the END OF THE GAME,,, But idk "How to know WHEN The Game wll Ended" cuz this is not a training mission...

thank you for reading and more thanks for answering Big Grin

]{

╟───NW──────┼──────N╢

╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜

Copyright © 2004-2023 Hedgewars Project. All rights reserved. [ contact ]