mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-06 07:30:35 +07:00
Slightly different implementation of #6910
This commit is contained in:
parent
1c0eff0871
commit
e627008fbc
@ -68,12 +68,14 @@ public class GlobalVars{
|
||||
}
|
||||
|
||||
for(Block block : Vars.content.blocks()){
|
||||
put("@" + block.name, block);
|
||||
//only register blocks that have no item equivalent (this skips sand)
|
||||
if(content.item(block.name) == null){
|
||||
put("@" + block.name, block);
|
||||
}
|
||||
}
|
||||
|
||||
//used as a special value for any environmental solid block
|
||||
put("@solid", Blocks.stoneWall);
|
||||
put("@air", Blocks.air);
|
||||
|
||||
for(UnitType type : Vars.content.units()){
|
||||
put("@" + type.name, type);
|
||||
@ -161,6 +163,12 @@ public class GlobalVars{
|
||||
|
||||
/** Adds a constant value by name. */
|
||||
public int put(String name, Object value){
|
||||
int existingIdx = namesToIds.get(name, -1);
|
||||
if(existingIdx != -1){ //don't overwrite existing vars (see #6910)
|
||||
Log.debug("Failed to add global logic variable '@', as it already exists.", name);
|
||||
return existingIdx;
|
||||
}
|
||||
|
||||
Var var = new Var(name);
|
||||
var.constant = true;
|
||||
if(value instanceof Number num){
|
||||
|
Loading…
Reference in New Issue
Block a user