Help making a special power
Moderator: Moderators
Help making a special power
I need advice, what im trying to do is a satelite scan power that globally reveals the map once the player presses a button.
Now i use a unit as special object for that, for the time being it does the job.
My problem however is right now that i dont know how to attach a button to trigger said power.
I looked in the synced and unsynced control section of the lua reference, but i couldnt come up with an idea on how to make one.
Now i use a unit as special object for that, for the time being it does the job.
My problem however is right now that i dont know how to attach a button to trigger said power.
I looked in the synced and unsynced control section of the lua reference, but i couldnt come up with an idea on how to make one.
Re: Help making a special power
I'd do it by creating a (chili) button (unsynced widget) that sends a message to synced Lua (synced gadget), and there I would check if I've received the correct message, and if so I'd do the 'special power' logic you already have.
Pinpoint the part you are struggling with exactly if you want help.
Pinpoint the part you are struggling with exactly if you want help.
Re: Help making a special power
Sorry, I read your post too fast and bit wrong.
I read scanning as scanning like in Starcraft, where it only reveals a small part of the map instead of "global."
But also not quite clear from your question what kind of "button" you want: A button in menu of unit or a button that is always there.
Maybe still somewhat helpful
www.youtube.com/watch?v=uZy6h6XLNsQ
There is two places where it says "YOUR UNIT NAME HERE", put unit names them there. First the unit that can scan (like radarcenter) then a invisible unit that will get spawned to provide the los. (this unit should probally also remove itself after a while)
I read scanning as scanning like in Starcraft, where it only reveals a small part of the map instead of "global."
But also not quite clear from your question what kind of "button" you want: A button in menu of unit or a button that is always there.
Maybe still somewhat helpful
www.youtube.com/watch?v=uZy6h6XLNsQ
There is two places where it says "YOUR UNIT NAME HERE", put unit names them there. First the unit that can scan (like radarcenter) then a invisible unit that will get spawned to provide the los. (this unit should probally also remove itself after a while)
- Attachments
-
- tp_scannertest.lua
- (1.88 KiB) Downloaded 9 times
Re: Help making a special power
Il try this and see how that goes.gajop wrote:I'd do it by creating a (chili) button (unsynced widget) that sends a message to synced Lua (synced gadget), and there I would check if I've received the correct message, and if so I'd do the 'special power' logic you already have.
Pinpoint the part you are struggling with exactly if you want help.
Tough if there is a way to simply add a button straight from the gadget this might be preferable in my case.
Yes, stupid of me, the button i need is faction global, so one button per player that is not tied to a unit.knorke wrote: But also not quite clear from your question what kind of "button" you want: A button in menu of unit or a button that is always there.
Already made such a thing myself, but thanks.
Re: Help making a special power
Is there a clean way to reveal the map? Because having to lay an array of units over the map isn't : it's hard to make them really invisible and non-interacting.
Re: Help making a special power
Well im using an invisible aircraft with high altitude and enormous view range, so that pins it down to a single unit.zwzsg wrote:Is there a clean way to reveal the map? Because having to lay an array of units over the map isn't : it's hard to make them really invisible and non-interacting.
But i havent a lua function to reveal terrain to teams would be nice, i havent found one in the documentaion.
Re: Help making a special power
Can't reveal terrain but you can make all units act as in permanent LOS. i.e. you can't change LOS status of terrain but you can of units.
btw you can use http://springrts.com/wiki/Gamedev:UnitD ... EmitHeight on a ground based unit if you want to avoid the vtol.
btw you can use http://springrts.com/wiki/Gamedev:UnitD ... EmitHeight on a ground based unit if you want to avoid the vtol.
Re: Help making a special power
http://springrts.com/wiki/Lua_SyncedCtrl#Unit_LOS
Spring.SetUnitLosMask or Spring.SetUnitLosState (hm, not quite sure atm what the difference is)
Spring.SetUnitLosMask or Spring.SetUnitLosState (hm, not quite sure atm what the difference is)
Re: Help making a special power
State sets current state, Mask sets what engine will automatically update.
Example usage:
https://sourceforge.net/p/mwspring/code ... _radar.lua
Example usage:
https://sourceforge.net/p/mwspring/code ... _radar.lua
Re: Help making a special power
Ok i couldnt work on my game for a while but now im back in the action.
So far i managed to make a chilly button, but thats it, i have no idea how to connect it to the a gadget.
I did look at the reference ofc but i could make much out of it. If someone could post an example it would help me much.
Another thing is i want a image button, but i only made a text button.
So far i managed to make a chilly button, but thats it, i have no idea how to connect it to the a gadget.
I did look at the reference ofc but i could make much out of it. If someone could post an example it would help me much.
Another thing is i want a image button, but i only made a text button.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Help making a special power
For the chili button you'll need to add an image as a child to the button.
Something like..
Something like..
Code: Select all
local yourButton = Chili.Button:New{
caption = '',
x = 0,
y = 0,
height = 40,
width = 40,
children = {
Chili.Image:New{
height = '100%',
width = '100%',
file = 'luaUI/images/yourimage.png',
},
}
Re: Help making a special power
Ok, good news and bad news.
Good news is adding the image worked just fine, so one less thing to do.
Bad news is i remembered that i also need a way to highlight how long it takes for the superpower to charge and if its ready. Which makes things even more complicated as this information must come from the gadget itself logically.
Good news is adding the image worked just fine, so one less thing to do.
Bad news is i remembered that i also need a way to highlight how long it takes for the superpower to charge and if its ready. Which makes things even more complicated as this information must come from the gadget itself logically.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Help making a special power
Reading around it sounds like SetUnitParams is what you need
http://springrts.com/wiki/Lua_SyncedCtrl#RulesParams
It allows you to tie a new param to a specific unit (unit with power) that is then readable in all lua environments. Or at least can be depending on how you set it.
Some other ways
http://springrts.com/phpbb/viewtopic.ph ... 38#p513838
http://springrts.com/phpbb/viewtopic.ph ... 57#p462457
If you give me a sec I'll try work out a basic example with a chili button
http://springrts.com/wiki/Lua_SyncedCtrl#RulesParams
It allows you to tie a new param to a specific unit (unit with power) that is then readable in all lua environments. Or at least can be depending on how you set it.
Some other ways
http://springrts.com/phpbb/viewtopic.ph ... 38#p513838
http://springrts.com/phpbb/viewtopic.ph ... 57#p462457
If you give me a sec I'll try work out a basic example with a chili button
Re: Help making a special power
I use something like this in gadget:
mana=mana+1 --mana energy recharges or whatever
Spring.SetUnitRulesParam(unitID,"manaEnergy",mana)
In widget can read it like:
local mana = Spring.GetUnitRulesParam(unitID,"manaEnergy")
For complete example maybe look at jumpjets in zK, the gadget and how it "jumpReload" is read in unit_healtbars.lua
If you do not want it tied to a unit but rather global to the team can use:
Spring.SetTeamRulesParam
mana=mana+1 --mana energy recharges or whatever
Spring.SetUnitRulesParam(unitID,"manaEnergy",mana)
In widget can read it like:
local mana = Spring.GetUnitRulesParam(unitID,"manaEnergy")
For complete example maybe look at jumpjets in zK, the gadget and how it "jumpReload" is read in unit_healtbars.lua
If you do not want it tied to a unit but rather global to the team can use:
Spring.SetTeamRulesParam
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Help making a special power
okay, so this might at least gives you some ideas
Code: Select all
local function onClick()
label = Spring.GetUnitRuleParam(unitID, 'yourParamName') or ''
buttonlabel:SetCaption(label)
end
buttonlabel = Chili.Label:New{
caption = '',
x = 0,
bottom = 0,
}
image = Chili.Image:New{
height = '100%,,
width = '100%',
file = 'luaUI/images/yourimage.png',
children = {label},
}
button = Chili.Button:New{
caption = '',
x = 0,
y = 0,
height = 60,
width = 40,
OnClick = {onClick},
children = {image}
}
Re: Help making a special power
Ok nice, i got it to work thanks guys.
The only thing i need now is to actually call the function of the gadget to trigger the thing and i need the teamid of the one who clicks the button.
The only thing i need now is to actually call the function of the gadget to trigger the thing and i need the teamid of the one who clicks the button.
Re: Help making a special power
in widget:The only thing i need now is to actually call the function of the gadget to trigger the thing and i need the teamid of the one who clicks the button.
Spring.SendLuaRulesMsg("blabla i clicked a button")
gadget:
Code: Select all
function gadget:RecvLuaMsg(msg, playerID)
local active, spectator, teamID = Spring.GetPlayerInfo (playerID)
if not spectator and active then ... do things
...
So for the actual message you could think of some system, like "buttonclick_scanner" "buttonclick_nuke" or something.
Re: Help making a special power
Ok i tried that but now im getting this error.
Code: Select all
Error: LuaRules::RunCallIn: error = 2, RecvLuaMsg, [string "LuaRules/Gadgets/satelite_scan.lua"]:28: Unsafe attempt to change game state
Re: Help making a special power
and what is at line 28..?
Re: Help making a special power
guess: Try to move the CreateUnit (or whatever you do there) from RecvLuaMsg into GameFrame.